Skip to content

Commit 05cc5a3

Browse files
Yuval Mintzdavem330
authored andcommitted
bnx2x: add vlan filtering offload
Current driver always uses vlan-promisc mode, i.e., it receives both tagged and untagged traffic and lets the network stack drop packets tagged with unrequested vlan tags. This patch implements vlan-filtering offload in the driver - Unless explicitly configured to promisc mode, only untagged packets or packets tagged with requested vlans would reach the Rx flow. Signed-off-by: Yuval Mintz <[email protected]> Signed-off-by: Ariel Elior <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e82a08b commit 05cc5a3

File tree

10 files changed

+905
-290
lines changed

10 files changed

+905
-290
lines changed

drivers/net/ethernet/broadcom/bnx2x/bnx2x.h

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,10 @@ struct bnx2x_slowpath {
12281228
struct eth_classify_rules_ramrod_data e2;
12291229
} mac_rdata;
12301230

1231+
union {
1232+
struct eth_classify_rules_ramrod_data e2;
1233+
} vlan_rdata;
1234+
12311235
union {
12321236
struct tstorm_eth_mac_filter_config e1x;
12331237
struct eth_filter_rules_ramrod_data e2;
@@ -1410,6 +1414,9 @@ struct bnx2x_sp_objs {
14101414

14111415
/* Queue State object */
14121416
struct bnx2x_queue_sp_obj q_obj;
1417+
1418+
/* VLANs object */
1419+
struct bnx2x_vlan_mac_obj vlan_obj;
14131420
};
14141421

14151422
struct bnx2x_fp_stats {
@@ -1427,6 +1434,12 @@ enum {
14271434
SUB_MF_MODE_BD,
14281435
};
14291436

1437+
struct bnx2x_vlan_entry {
1438+
struct list_head link;
1439+
u16 vid;
1440+
bool hw;
1441+
};
1442+
14301443
struct bnx2x {
14311444
/* Fields used in the tx and intr/napi performance paths
14321445
* are grouped together in the beginning of the structure
@@ -1865,8 +1878,6 @@ struct bnx2x {
18651878
int dcb_version;
18661879

18671880
/* CAM credit pools */
1868-
1869-
/* used only in sriov */
18701881
struct bnx2x_credit_pool_obj vlans_pool;
18711882

18721883
struct bnx2x_credit_pool_obj macs_pool;
@@ -1929,6 +1940,11 @@ struct bnx2x {
19291940
u16 rx_filter;
19301941

19311942
struct bnx2x_link_report_data vf_link_vars;
1943+
struct list_head vlan_reg;
1944+
u16 vlan_cnt;
1945+
u16 vlan_credit;
1946+
u16 vxlan_dst_port;
1947+
bool accept_any_vlan;
19321948
};
19331949

19341950
/* Tx queues may be less or equal to Rx queues */
@@ -1956,23 +1972,14 @@ extern int num_queues;
19561972
#define RSS_IPV6_TCP_CAP_MASK \
19571973
TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY
19581974

1959-
/* func init flags */
1960-
#define FUNC_FLG_RSS 0x0001
1961-
#define FUNC_FLG_STATS 0x0002
1962-
/* removed FUNC_FLG_UNMATCHED 0x0004 */
1963-
#define FUNC_FLG_TPA 0x0008
1964-
#define FUNC_FLG_SPQ 0x0010
1965-
#define FUNC_FLG_LEADING 0x0020 /* PF only */
1966-
#define FUNC_FLG_LEADING_STATS 0x0040
19671975
struct bnx2x_func_init_params {
19681976
/* dma */
1969-
dma_addr_t fw_stat_map; /* valid iff FUNC_FLG_STATS */
1970-
dma_addr_t spq_map; /* valid iff FUNC_FLG_SPQ */
1977+
bool spq_active;
1978+
dma_addr_t spq_map;
1979+
u16 spq_prod;
19711980

1972-
u16 func_flgs;
19731981
u16 func_id; /* abs fid */
19741982
u16 pf_id;
1975-
u16 spq_prod; /* valid iff FUNC_FLG_SPQ */
19761983
};
19771984

19781985
#define for_each_cnic_queue(bp, var) \
@@ -2082,6 +2089,11 @@ struct bnx2x_func_init_params {
20822089
int bnx2x_set_mac_one(struct bnx2x *bp, u8 *mac,
20832090
struct bnx2x_vlan_mac_obj *obj, bool set,
20842091
int mac_type, unsigned long *ramrod_flags);
2092+
2093+
int bnx2x_set_vlan_one(struct bnx2x *bp, u16 vlan,
2094+
struct bnx2x_vlan_mac_obj *obj, bool set,
2095+
unsigned long *ramrod_flags);
2096+
20852097
/**
20862098
* bnx2x_del_all_macs - delete all MACs configured for the specific MAC object
20872099
*
@@ -2486,6 +2498,7 @@ void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, u8 idu_sb_id,
24862498
#define VF_ACQUIRE_THRESH 3
24872499
#define VF_ACQUIRE_MAC_FILTERS 1
24882500
#define VF_ACQUIRE_MC_FILTERS 10
2501+
#define VF_ACQUIRE_VLAN_FILTERS 2 /* VLAN0 + 'real' VLAN */
24892502

24902503
#define GOOD_ME_REG(me_reg) (((me_reg) & ME_REG_VF_VALID) && \
24912504
(!((me_reg) & ME_REG_VF_ERR)))
@@ -2596,4 +2609,9 @@ void bnx2x_set_rx_ts(struct bnx2x *bp, struct sk_buff *skb);
25962609
#define BNX2X_MAX_PHC_DRIFT 31000000
25972610
#define BNX2X_PTP_TX_TIMEOUT
25982611

2612+
/* Re-configure all previously configured vlan filters.
2613+
* Meant for implicit re-load flows.
2614+
*/
2615+
int bnx2x_vlan_reconfigure_vid(struct bnx2x *bp);
2616+
25992617
#endif /* bnx2x.h */

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,6 +2848,11 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
28482848

28492849
/* Start fast path */
28502850

2851+
/* Re-configure vlan filters */
2852+
rc = bnx2x_vlan_reconfigure_vid(bp);
2853+
if (rc)
2854+
LOAD_ERROR_EXIT(bp, load_error3);
2855+
28512856
/* Initialize Rx filter. */
28522857
bnx2x_set_rx_mode_inner(bp);
28532858

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,15 @@ static inline void bnx2x_init_vlan_mac_fp_objs(struct bnx2x_fastpath *fp,
10661066
BNX2X_FILTER_MAC_PENDING,
10671067
&bp->sp_state, obj_type,
10681068
&bp->macs_pool);
1069+
1070+
if (!CHIP_IS_E1x(bp))
1071+
bnx2x_init_vlan_obj(bp, &bnx2x_sp_obj(bp, fp).vlan_obj,
1072+
fp->cl_id, fp->cid, BP_FUNC(bp),
1073+
bnx2x_sp(bp, vlan_rdata),
1074+
bnx2x_sp_mapping(bp, vlan_rdata),
1075+
BNX2X_FILTER_VLAN_PENDING,
1076+
&bp->sp_state, obj_type,
1077+
&bp->vlans_pool);
10691078
}
10701079

10711080
/**
@@ -1125,7 +1134,7 @@ static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
11251134
bnx2x_init_mac_credit_pool(bp, &bp->macs_pool, BP_FUNC(bp),
11261135
bnx2x_get_path_func_num(bp));
11271136

1128-
bnx2x_init_vlan_credit_pool(bp, &bp->vlans_pool, BP_ABS_FUNC(bp)>>1,
1137+
bnx2x_init_vlan_credit_pool(bp, &bp->vlans_pool, BP_FUNC(bp),
11291138
bnx2x_get_path_func_num(bp));
11301139

11311140
/* RSS configuration object */
@@ -1135,6 +1144,8 @@ static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
11351144
bnx2x_sp_mapping(bp, rss_rdata),
11361145
BNX2X_FILTER_RSS_CONF_PENDING, &bp->sp_state,
11371146
BNX2X_OBJ_TYPE_RX);
1147+
1148+
bp->vlan_credit = PF_VLAN_CREDIT_E2(bp, bnx2x_get_path_func_num(bp));
11381149
}
11391150

11401151
static inline u8 bnx2x_fp_qzone_id(struct bnx2x_fastpath *fp)

0 commit comments

Comments
 (0)