Skip to content

Commit 185161b

Browse files
RajuRangojugregkh
authored andcommitted
cxgb4: set up filter action after rewrites
[ Upstream commit 937d842 ] The current code sets up the filter action field before rewrites are set up. When the action 'switch' is used with rewrites, this may result in initial few packets that get switched out don't have rewrites applied on them. So, make sure filter action is set up along with rewrites or only after everything else is set up for rewrites. Fixes: 12b276f ("cxgb4: add support to create hash filters") Signed-off-by: Raju Rangoju <rajur@chelsio.com> Link: https://lore.kernel.org/r/20201023115852.18262-1-rajur@chelsio.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 676a2b8 commit 185161b

2 files changed

Lines changed: 31 additions & 29 deletions

File tree

drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ static int configure_filter_smac(struct adapter *adap, struct filter_entry *f)
145145
int err;
146146

147147
/* do a set-tcb for smac-sel and CWR bit.. */
148-
err = set_tcb_tflag(adap, f, f->tid, TF_CCTRL_CWR_S, 1, 1);
149-
if (err)
150-
goto smac_err;
151-
152148
err = set_tcb_field(adap, f, f->tid, TCB_SMAC_SEL_W,
153149
TCB_SMAC_SEL_V(TCB_SMAC_SEL_M),
154150
TCB_SMAC_SEL_V(f->smt->idx), 1);
151+
if (err)
152+
goto smac_err;
153+
154+
err = set_tcb_tflag(adap, f, f->tid, TF_CCTRL_CWR_S, 1, 1);
155155
if (!err)
156156
return 0;
157157

@@ -865,6 +865,7 @@ int set_filter_wr(struct adapter *adapter, int fidx)
865865
FW_FILTER_WR_DIRSTEERHASH_V(f->fs.dirsteerhash) |
866866
FW_FILTER_WR_LPBK_V(f->fs.action == FILTER_SWITCH) |
867867
FW_FILTER_WR_DMAC_V(f->fs.newdmac) |
868+
FW_FILTER_WR_SMAC_V(f->fs.newsmac) |
868869
FW_FILTER_WR_INSVLAN_V(f->fs.newvlan == VLAN_INSERT ||
869870
f->fs.newvlan == VLAN_REWRITE) |
870871
FW_FILTER_WR_RMVLAN_V(f->fs.newvlan == VLAN_REMOVE ||
@@ -882,7 +883,7 @@ int set_filter_wr(struct adapter *adapter, int fidx)
882883
FW_FILTER_WR_OVLAN_VLD_V(f->fs.val.ovlan_vld) |
883884
FW_FILTER_WR_IVLAN_VLDM_V(f->fs.mask.ivlan_vld) |
884885
FW_FILTER_WR_OVLAN_VLDM_V(f->fs.mask.ovlan_vld));
885-
fwr->smac_sel = 0;
886+
fwr->smac_sel = f->smt->idx;
886887
fwr->rx_chan_rx_rpl_iq =
887888
htons(FW_FILTER_WR_RX_CHAN_V(0) |
888889
FW_FILTER_WR_RX_RPL_IQ_V(adapter->sge.fw_evtq.abs_id));
@@ -1326,11 +1327,8 @@ static void mk_act_open_req6(struct filter_entry *f, struct sk_buff *skb,
13261327
TX_QUEUE_V(f->fs.nat_mode) |
13271328
T5_OPT_2_VALID_F |
13281329
RX_CHANNEL_V(cxgb4_port_e2cchan(f->dev)) |
1329-
CONG_CNTRL_V((f->fs.action == FILTER_DROP) |
1330-
(f->fs.dirsteer << 1)) |
13311330
PACE_V((f->fs.maskhash) |
1332-
((f->fs.dirsteerhash) << 1)) |
1333-
CCTRL_ECN_V(f->fs.action == FILTER_SWITCH));
1331+
((f->fs.dirsteerhash) << 1)));
13341332
}
13351333

13361334
static void mk_act_open_req(struct filter_entry *f, struct sk_buff *skb,
@@ -1366,11 +1364,8 @@ static void mk_act_open_req(struct filter_entry *f, struct sk_buff *skb,
13661364
TX_QUEUE_V(f->fs.nat_mode) |
13671365
T5_OPT_2_VALID_F |
13681366
RX_CHANNEL_V(cxgb4_port_e2cchan(f->dev)) |
1369-
CONG_CNTRL_V((f->fs.action == FILTER_DROP) |
1370-
(f->fs.dirsteer << 1)) |
13711367
PACE_V((f->fs.maskhash) |
1372-
((f->fs.dirsteerhash) << 1)) |
1373-
CCTRL_ECN_V(f->fs.action == FILTER_SWITCH));
1368+
((f->fs.dirsteerhash) << 1)));
13741369
}
13751370

13761371
static int cxgb4_set_hash_filter(struct net_device *dev,
@@ -2042,6 +2037,20 @@ void hash_filter_rpl(struct adapter *adap, const struct cpl_act_open_rpl *rpl)
20422037
}
20432038
return;
20442039
}
2040+
switch (f->fs.action) {
2041+
case FILTER_PASS:
2042+
if (f->fs.dirsteer)
2043+
set_tcb_tflag(adap, f, tid,
2044+
TF_DIRECT_STEER_S, 1, 1);
2045+
break;
2046+
case FILTER_DROP:
2047+
set_tcb_tflag(adap, f, tid, TF_DROP_S, 1, 1);
2048+
break;
2049+
case FILTER_SWITCH:
2050+
set_tcb_tflag(adap, f, tid, TF_LPBK_S, 1, 1);
2051+
break;
2052+
}
2053+
20452054
break;
20462055

20472056
default:
@@ -2109,22 +2118,11 @@ void filter_rpl(struct adapter *adap, const struct cpl_set_tcb_rpl *rpl)
21092118
if (ctx)
21102119
ctx->result = 0;
21112120
} else if (ret == FW_FILTER_WR_FLT_ADDED) {
2112-
int err = 0;
2113-
2114-
if (f->fs.newsmac)
2115-
err = configure_filter_smac(adap, f);
2116-
2117-
if (!err) {
2118-
f->pending = 0; /* async setup completed */
2119-
f->valid = 1;
2120-
if (ctx) {
2121-
ctx->result = 0;
2122-
ctx->tid = idx;
2123-
}
2124-
} else {
2125-
clear_filter(adap, f);
2126-
if (ctx)
2127-
ctx->result = err;
2121+
f->pending = 0; /* async setup completed */
2122+
f->valid = 1;
2123+
if (ctx) {
2124+
ctx->result = 0;
2125+
ctx->tid = idx;
21282126
}
21292127
} else {
21302128
/* Something went wrong. Issue a warning about the

drivers/net/ethernet/chelsio/cxgb4/t4_tcb.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
#define TCB_T_FLAGS_M 0xffffffffffffffffULL
5151
#define TCB_T_FLAGS_V(x) ((__u64)(x) << TCB_T_FLAGS_S)
5252

53+
#define TF_DROP_S 22
54+
#define TF_DIRECT_STEER_S 23
55+
#define TF_LPBK_S 59
56+
5357
#define TF_CCTRL_ECE_S 60
5458
#define TF_CCTRL_CWR_S 61
5559
#define TF_CCTRL_RFR_S 62

0 commit comments

Comments
 (0)