Skip to content

Commit

Permalink
net/ngbe: support VLAN offload and VLAN filter
Browse files Browse the repository at this point in the history
Support to set VLAN and QinQ offload, and filter of a VLAN tag
identifier.

Signed-off-by: Jiawen Wu <[email protected]>
  • Loading branch information
Jiawen Wu authored and Ferruh Yigit committed Oct 29, 2021
1 parent 586e602 commit 59b4643
Show file tree
Hide file tree
Showing 11 changed files with 610 additions and 7 deletions.
3 changes: 3 additions & 0 deletions doc/guides/nics/features/ngbe.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ Queue start/stop = Y
Burst mode info = Y
Scattered Rx = Y
TSO = Y
VLAN filter = Y
CRC offload = Y
VLAN offload = Y
QinQ offload = Y
L3 checksum offload = Y
L4 checksum offload = Y
Inner L3 checksum = Y
Expand Down
2 changes: 2 additions & 0 deletions doc/guides/nics/ngbe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ for Wangxun 1 Gigabit Ethernet NICs.
Features
--------

- VLAN filtering
- Packet type information
- Checksum offload
- VLAN/QinQ stripping and inserting
- TSO offload
- Jumbo frames
- Link state information
Expand Down
1 change: 1 addition & 0 deletions doc/guides/rel_notes/release_21_11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ New Features
* **Updated Wangxun ngbe driver.**

* Added offloads and packet type on RxTx.
* Added VLAN filters.

* **Updated Marvell cnxk crypto PMD.**

Expand Down
5 changes: 5 additions & 0 deletions drivers/net/ngbe/base/ngbe_dummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ static inline s32 ngbe_mac_init_rx_addrs_dummy(struct ngbe_hw *TUP0)
{
return NGBE_ERR_OPS_DUMMY;
}
static inline s32 ngbe_mac_clear_vfta_dummy(struct ngbe_hw *TUP0)
{
return NGBE_ERR_OPS_DUMMY;
}
static inline s32 ngbe_mac_init_thermal_ssth_dummy(struct ngbe_hw *TUP0)
{
return NGBE_ERR_OPS_DUMMY;
Expand Down Expand Up @@ -192,6 +196,7 @@ static inline void ngbe_init_ops_dummy(struct ngbe_hw *hw)
hw->mac.set_vmdq = ngbe_mac_set_vmdq_dummy;
hw->mac.clear_vmdq = ngbe_mac_clear_vmdq_dummy;
hw->mac.init_rx_addrs = ngbe_mac_init_rx_addrs_dummy;
hw->mac.clear_vfta = ngbe_mac_clear_vfta_dummy;
hw->mac.init_thermal_sensor_thresh = ngbe_mac_init_thermal_ssth_dummy;
hw->mac.check_overtemp = ngbe_mac_check_overtemp_dummy;
hw->phy.identify = ngbe_phy_identify_dummy;
Expand Down
31 changes: 30 additions & 1 deletion drivers/net/ngbe/base/ngbe_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ s32 ngbe_start_hw(struct ngbe_hw *hw)
{
DEBUGFUNC("ngbe_start_hw");

/* Clear the VLAN filter table */
hw->mac.clear_vfta(hw);

/* Clear adapter stopped flag */
hw->adapter_stopped = false;

Expand Down Expand Up @@ -676,6 +679,30 @@ s32 ngbe_init_uta_tables(struct ngbe_hw *hw)
return 0;
}

/**
* ngbe_clear_vfta - Clear VLAN filter table
* @hw: pointer to hardware structure
*
* Clears the VLAN filer table, and the VMDq index associated with the filter
**/
s32 ngbe_clear_vfta(struct ngbe_hw *hw)
{
u32 offset;

DEBUGFUNC("ngbe_clear_vfta");

for (offset = 0; offset < hw->mac.vft_size; offset++)
wr32(hw, NGBE_VLANTBL(offset), 0);

for (offset = 0; offset < NGBE_NUM_POOL; offset++) {
wr32(hw, NGBE_PSRVLANIDX, offset);
wr32(hw, NGBE_PSRVLAN, 0);
wr32(hw, NGBE_PSRVLANPLM(0), 0);
}

return 0;
}

/**
* ngbe_check_mac_link_em - Determine link and speed status
* @hw: pointer to hardware structure
Expand Down Expand Up @@ -996,12 +1023,13 @@ s32 ngbe_init_ops_pf(struct ngbe_hw *hw)

mac->disable_sec_rx_path = ngbe_disable_sec_rx_path;
mac->enable_sec_rx_path = ngbe_enable_sec_rx_path;
/* RAR */
/* RAR, VLAN */
mac->set_rar = ngbe_set_rar;
mac->clear_rar = ngbe_clear_rar;
mac->init_rx_addrs = ngbe_init_rx_addrs;
mac->set_vmdq = ngbe_set_vmdq;
mac->clear_vmdq = ngbe_clear_vmdq;
mac->clear_vfta = ngbe_clear_vfta;

/* Link */
mac->get_link_capabilities = ngbe_get_link_capabilities_em;
Expand All @@ -1017,6 +1045,7 @@ s32 ngbe_init_ops_pf(struct ngbe_hw *hw)
rom->validate_checksum = ngbe_validate_eeprom_checksum_em;

mac->mcft_size = NGBE_EM_MC_TBL_SIZE;
mac->vft_size = NGBE_EM_VFT_TBL_SIZE;
mac->num_rar_entries = NGBE_EM_RAR_ENTRIES;
mac->max_rx_queues = NGBE_EM_MAX_RX_QUEUES;
mac->max_tx_queues = NGBE_EM_MAX_TX_QUEUES;
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ngbe/base/ngbe_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define NGBE_EM_MAX_RX_QUEUES 8
#define NGBE_EM_RAR_ENTRIES 32
#define NGBE_EM_MC_TBL_SIZE 32
#define NGBE_EM_VFT_TBL_SIZE 128

s32 ngbe_init_hw(struct ngbe_hw *hw);
s32 ngbe_start_hw(struct ngbe_hw *hw);
Expand Down Expand Up @@ -44,6 +45,7 @@ void ngbe_release_swfw_sync(struct ngbe_hw *hw, u32 mask);
s32 ngbe_set_vmdq(struct ngbe_hw *hw, u32 rar, u32 vmdq);
s32 ngbe_clear_vmdq(struct ngbe_hw *hw, u32 rar, u32 vmdq);
s32 ngbe_init_uta_tables(struct ngbe_hw *hw);
s32 ngbe_clear_vfta(struct ngbe_hw *hw);

s32 ngbe_init_thermal_sensor_thresh(struct ngbe_hw *hw);
s32 ngbe_mac_check_overtemp(struct ngbe_hw *hw);
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/ngbe/base/ngbe_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define NGBE_LINK_UP_TIME 90 /* 9.0 Seconds */

#define NGBE_FRAME_SIZE_DFT (1522) /* Default frame size, +FCS */
#define NGBE_NUM_POOL (32)

#define NGBE_ALIGN 128 /* as intel did */
#define NGBE_ISB_SIZE 16
Expand Down Expand Up @@ -118,6 +119,7 @@ struct ngbe_mac_info {
s32 (*set_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
s32 (*clear_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
s32 (*init_rx_addrs)(struct ngbe_hw *hw);
s32 (*clear_vfta)(struct ngbe_hw *hw);

/* Manageability interface */
s32 (*init_thermal_sensor_thresh)(struct ngbe_hw *hw);
Expand All @@ -128,6 +130,7 @@ struct ngbe_mac_info {
u8 perm_addr[ETH_ADDR_LEN];
s32 mc_filter_type;
u32 mcft_size;
u32 vft_size;
u32 num_rar_entries;
u32 max_tx_queues;
u32 max_rx_queues;
Expand Down
Loading

0 comments on commit 59b4643

Please sign in to comment.