Skip to content

Commit 74dd5aa

Browse files
vishalsdkdavem330
authored andcommitted
cxgb4: Enable hash filter with offload
Hash (exact-match) filters used for offloading flows share the same active region resources on the chip with upper layer drivers, like iw_cxgb4, chcr, etc. Currently, only either Hash filters or ULDs can use the active region resources, but not both. Hence, use the new firmware configuration parameters (when available) to allow both the Hash filters and ULDs to share the active region simultaneously. Signed-off-by: Vishal Kulkarni <vishal@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2bb0f3b commit 74dd5aa

8 files changed

Lines changed: 110 additions & 22 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ struct port_info {
600600
u8 vin;
601601
u8 vivld;
602602
u8 smt_idx;
603+
u8 rx_cchan;
603604
};
604605

605606
struct dentry;

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

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ static void mk_act_open_req6(struct filter_entry *f, struct sk_buff *skb,
10411041
RSS_QUEUE_V(f->fs.iq) |
10421042
TX_QUEUE_V(f->fs.nat_mode) |
10431043
T5_OPT_2_VALID_F |
1044-
RX_CHANNEL_F |
1044+
RX_CHANNEL_V(cxgb4_port_e2cchan(f->dev)) |
10451045
CONG_CNTRL_V((f->fs.action == FILTER_DROP) |
10461046
(f->fs.dirsteer << 1)) |
10471047
PACE_V((f->fs.maskhash) |
@@ -1081,7 +1081,7 @@ static void mk_act_open_req(struct filter_entry *f, struct sk_buff *skb,
10811081
RSS_QUEUE_V(f->fs.iq) |
10821082
TX_QUEUE_V(f->fs.nat_mode) |
10831083
T5_OPT_2_VALID_F |
1084-
RX_CHANNEL_F |
1084+
RX_CHANNEL_V(cxgb4_port_e2cchan(f->dev)) |
10851085
CONG_CNTRL_V((f->fs.action == FILTER_DROP) |
10861086
(f->fs.dirsteer << 1)) |
10871087
PACE_V((f->fs.maskhash) |
@@ -1833,24 +1833,38 @@ void filter_rpl(struct adapter *adap, const struct cpl_set_tcb_rpl *rpl)
18331833
}
18341834
}
18351835

1836-
int init_hash_filter(struct adapter *adap)
1836+
void init_hash_filter(struct adapter *adap)
18371837
{
1838+
u32 reg;
1839+
18381840
/* On T6, verify the necessary register configs and warn the user in
18391841
* case of improper config
18401842
*/
18411843
if (is_t6(adap->params.chip)) {
1842-
if (TCAM_ACTV_HIT_G(t4_read_reg(adap, LE_DB_RSP_CODE_0_A)) != 4)
1843-
goto err;
1844+
if (is_offload(adap)) {
1845+
if (!(t4_read_reg(adap, TP_GLOBAL_CONFIG_A)
1846+
& ACTIVEFILTERCOUNTS_F)) {
1847+
dev_err(adap->pdev_dev, "Invalid hash filter + ofld config\n");
1848+
return;
1849+
}
1850+
} else {
1851+
reg = t4_read_reg(adap, LE_DB_RSP_CODE_0_A);
1852+
if (TCAM_ACTV_HIT_G(reg) != 4) {
1853+
dev_err(adap->pdev_dev, "Invalid hash filter config\n");
1854+
return;
1855+
}
1856+
1857+
reg = t4_read_reg(adap, LE_DB_RSP_CODE_1_A);
1858+
if (HASH_ACTV_HIT_G(reg) != 4) {
1859+
dev_err(adap->pdev_dev, "Invalid hash filter config\n");
1860+
return;
1861+
}
1862+
}
18441863

1845-
if (HASH_ACTV_HIT_G(t4_read_reg(adap, LE_DB_RSP_CODE_1_A)) != 4)
1846-
goto err;
18471864
} else {
18481865
dev_err(adap->pdev_dev, "Hash filter supported only on T6\n");
1849-
return -EINVAL;
1866+
return;
18501867
}
1868+
18511869
adap->params.hash_filter = 1;
1852-
return 0;
1853-
err:
1854-
dev_warn(adap->pdev_dev, "Invalid hash filter config!\n");
1855-
return -EINVAL;
18561870
}

‎drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int delete_filter(struct adapter *adapter, unsigned int fidx);
5050

5151
int writable_filter(struct filter_entry *f);
5252
void clear_all_filters(struct adapter *adapter);
53-
int init_hash_filter(struct adapter *adap);
53+
void init_hash_filter(struct adapter *adap);
5454
bool is_filter_exact_match(struct adapter *adap,
5555
struct ch_filter_specification *fs);
5656
#endif /* __CXGB4_FILTER_H */

‎drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c‎

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,18 @@ unsigned int cxgb4_port_chan(const struct net_device *dev)
16461646
}
16471647
EXPORT_SYMBOL(cxgb4_port_chan);
16481648

1649+
/**
1650+
* cxgb4_port_e2cchan - get the HW c-channel of a port
1651+
* @dev: the net device for the port
1652+
*
1653+
* Return the HW RX c-channel of the given port.
1654+
*/
1655+
unsigned int cxgb4_port_e2cchan(const struct net_device *dev)
1656+
{
1657+
return netdev2pinfo(dev)->rx_cchan;
1658+
}
1659+
EXPORT_SYMBOL(cxgb4_port_e2cchan);
1660+
16491661
unsigned int cxgb4_dbfifo_count(const struct net_device *dev, int lpfifo)
16501662
{
16511663
struct adapter *adap = netdev2adap(dev);
@@ -3905,14 +3917,14 @@ static int adap_init0_phy(struct adapter *adap)
39053917
*/
39063918
static int adap_init0_config(struct adapter *adapter, int reset)
39073919
{
3920+
char *fw_config_file, fw_config_file_path[256];
3921+
u32 finiver, finicsum, cfcsum, param, val;
39083922
struct fw_caps_config_cmd caps_cmd;
3909-
const struct firmware *cf;
39103923
unsigned long mtype = 0, maddr = 0;
3911-
u32 finiver, finicsum, cfcsum;
3912-
int ret;
3913-
int config_issued = 0;
3914-
char *fw_config_file, fw_config_file_path[256];
3924+
const struct firmware *cf;
39153925
char *config_name = NULL;
3926+
int config_issued = 0;
3927+
int ret;
39163928

39173929
/*
39183930
* Reset device if necessary.
@@ -4020,6 +4032,24 @@ static int adap_init0_config(struct adapter *adapter, int reset)
40204032
goto bye;
40214033
}
40224034

4035+
val = 0;
4036+
4037+
/* Ofld + Hash filter is supported. Older fw will fail this request and
4038+
* it is fine.
4039+
*/
4040+
param = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
4041+
FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_HASHFILTER_WITH_OFLD));
4042+
ret = t4_set_params(adapter, adapter->mbox, adapter->pf, 0,
4043+
1, &param, &val);
4044+
4045+
/* FW doesn't know about Hash filter + ofld support,
4046+
* it's not a problem, don't return an error.
4047+
*/
4048+
if (ret < 0) {
4049+
dev_warn(adapter->pdev_dev,
4050+
"Hash filter with ofld is not supported by FW\n");
4051+
}
4052+
40234053
/*
40244054
* Issue a Capability Configuration command to the firmware to get it
40254055
* to parse the Configuration File. We don't use t4_fw_config_file()
@@ -4580,6 +4610,13 @@ static int adap_init0(struct adapter *adap)
45804610
if (ret < 0)
45814611
goto bye;
45824612

4613+
/* hash filter has some mandatory register settings to be tested and for
4614+
* that it needs to test whether offload is enabled or not, hence
4615+
* checking and setting it here.
4616+
*/
4617+
if (caps_cmd.ofldcaps)
4618+
adap->params.offload = 1;
4619+
45834620
if (caps_cmd.ofldcaps ||
45844621
(caps_cmd.niccaps & htons(FW_CAPS_CONFIG_NIC_HASHFILTER))) {
45854622
/* query offload-related parameters */
@@ -4619,11 +4656,8 @@ static int adap_init0(struct adapter *adap)
46194656
adap->params.ofldq_wr_cred = val[5];
46204657

46214658
if (caps_cmd.niccaps & htons(FW_CAPS_CONFIG_NIC_HASHFILTER)) {
4622-
ret = init_hash_filter(adap);
4623-
if (ret < 0)
4624-
goto bye;
4659+
init_hash_filter(adap);
46254660
} else {
4626-
adap->params.offload = 1;
46274661
adap->num_ofld_uld += 1;
46284662
}
46294663
}

‎drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ int cxgb4_immdata_send(struct net_device *dev, unsigned int idx,
393393
int cxgb4_crypto_send(struct net_device *dev, struct sk_buff *skb);
394394
unsigned int cxgb4_dbfifo_count(const struct net_device *dev, int lpfifo);
395395
unsigned int cxgb4_port_chan(const struct net_device *dev);
396+
unsigned int cxgb4_port_e2cchan(const struct net_device *dev);
396397
unsigned int cxgb4_port_viid(const struct net_device *dev);
397398
unsigned int cxgb4_tp_smt_idx(enum chip_type chip, unsigned int viid);
398399
unsigned int cxgb4_port_idx(const struct net_device *dev);

‎drivers/net/ethernet/chelsio/cxgb4/t4_hw.c‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6208,6 +6208,37 @@ unsigned int t4_get_mps_bg_map(struct adapter *adapter, int pidx)
62086208
return mps_bg_map[pidx];
62096209
}
62106210

6211+
/**
6212+
* t4_get_tp_e2c_map - return the E2C channel map associated with a port
6213+
* @adapter: the adapter
6214+
* @pidx: the port index
6215+
*/
6216+
unsigned int t4_get_tp_e2c_map(struct adapter *adapter, int pidx)
6217+
{
6218+
unsigned int nports;
6219+
u32 param, val = 0;
6220+
int ret;
6221+
6222+
nports = 1 << NUMPORTS_G(t4_read_reg(adapter, MPS_CMN_CTL_A));
6223+
if (pidx >= nports) {
6224+
CH_WARN(adapter, "TP E2C Channel Port Index %d >= Nports %d\n",
6225+
pidx, nports);
6226+
return 0;
6227+
}
6228+
6229+
/* FW version >= 1.16.44.0 can determine E2C channel map using
6230+
* FW_PARAMS_PARAM_DEV_TPCHMAP API.
6231+
*/
6232+
param = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
6233+
FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_TPCHMAP));
6234+
ret = t4_query_params_ns(adapter, adapter->mbox, adapter->pf,
6235+
0, 1, &param, &val);
6236+
if (!ret)
6237+
return (val >> (8 * pidx)) & 0xff;
6238+
6239+
return 0;
6240+
}
6241+
62116242
/**
62126243
* t4_get_tp_ch_map - return TP ingress channels associated with a port
62136244
* @adapter: the adapter
@@ -9583,6 +9614,7 @@ int t4_init_portinfo(struct port_info *pi, int mbox,
95839614
pi->tx_chan = port;
95849615
pi->lport = port;
95859616
pi->rss_size = rss_size;
9617+
pi->rx_cchan = t4_get_tp_e2c_map(pi->adapter, port);
95869618

95879619
/* If fw supports returning the VIN as part of FW_VI_CMD,
95889620
* save the returned values.

‎drivers/net/ethernet/chelsio/cxgb4/t4_regs.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,10 @@
13341334
#define TP_OUT_CONFIG_A 0x7d04
13351335
#define TP_GLOBAL_CONFIG_A 0x7d08
13361336

1337+
#define ACTIVEFILTERCOUNTS_S 22
1338+
#define ACTIVEFILTERCOUNTS_V(x) ((x) << ACTIVEFILTERCOUNTS_S)
1339+
#define ACTIVEFILTERCOUNTS_F ACTIVEFILTERCOUNTS_V(1U)
1340+
13371341
#define TP_CMM_TCB_BASE_A 0x7d10
13381342
#define TP_CMM_MM_BASE_A 0x7d14
13391343
#define TP_CMM_TIMER_BASE_A 0x7d18

‎drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,10 +1250,12 @@ enum fw_params_param_dev {
12501250
FW_PARAMS_PARAM_DEV_RI_FR_NSMR_TPTE_WR = 0x1C,
12511251
FW_PARAMS_PARAM_DEV_FILTER2_WR = 0x1D,
12521252
FW_PARAMS_PARAM_DEV_MPSBGMAP = 0x1E,
1253+
FW_PARAMS_PARAM_DEV_TPCHMAP = 0x1F,
12531254
FW_PARAMS_PARAM_DEV_HMA_SIZE = 0x20,
12541255
FW_PARAMS_PARAM_DEV_RDMA_WRITE_WITH_IMM = 0x21,
12551256
FW_PARAMS_PARAM_DEV_RI_WRITE_CMPL_WR = 0x24,
12561257
FW_PARAMS_PARAM_DEV_OPAQUE_VIID_SMT_EXTN = 0x27,
1258+
FW_PARAMS_PARAM_DEV_HASHFILTER_WITH_OFLD = 0x28,
12571259
FW_PARAMS_PARAM_DEV_DBQ_TIMER = 0x29,
12581260
FW_PARAMS_PARAM_DEV_DBQ_TIMERTICK = 0x2A,
12591261
};

0 commit comments

Comments
 (0)