Skip to content

Commit 5c31254

Browse files
Kumar Sanghvidavem330
authored andcommitted
cxgb4: initialize hash-filter configuration
Add support for hash-filter configuration on T6. Also, do basic checks for the related initialization. Signed-off-by: Kumar Sanghvi <[email protected]> Signed-off-by: Rahul Lakkireddy <[email protected]> Signed-off-by: Ganesh Goudar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0ba9a3b commit 5c31254

File tree

6 files changed

+54
-4
lines changed

6 files changed

+54
-4
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ struct adapter_params {
366366
unsigned char crypto; /* HW capability for crypto */
367367

368368
unsigned char bypass;
369+
unsigned char hash_filter;
369370

370371
unsigned int ofldq_wr_cred;
371372
bool ulptx_memwrite_dsgl; /* use of T5 DSGL allowed */
@@ -1140,6 +1141,11 @@ static inline int is_offload(const struct adapter *adap)
11401141
return adap->params.offload;
11411142
}
11421143

1144+
static inline int is_hashfilter(const struct adapter *adap)
1145+
{
1146+
return adap->params.hash_filter;
1147+
}
1148+
11431149
static inline int is_pci_uld(const struct adapter *adap)
11441150
{
11451151
return adap->params.crypto;

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,3 +915,25 @@ void filter_rpl(struct adapter *adap, const struct cpl_set_tcb_rpl *rpl)
915915
complete(&ctx->completion);
916916
}
917917
}
918+
919+
int init_hash_filter(struct adapter *adap)
920+
{
921+
/* On T6, verify the necessary register configs and warn the user in
922+
* case of improper config
923+
*/
924+
if (is_t6(adap->params.chip)) {
925+
if (TCAM_ACTV_HIT_G(t4_read_reg(adap, LE_DB_RSP_CODE_0_A)) != 4)
926+
goto err;
927+
928+
if (HASH_ACTV_HIT_G(t4_read_reg(adap, LE_DB_RSP_CODE_1_A)) != 4)
929+
goto err;
930+
} else {
931+
dev_err(adap->pdev_dev, "Hash filter supported only on T6\n");
932+
return -EINVAL;
933+
}
934+
adap->params.hash_filter = 1;
935+
return 0;
936+
err:
937+
dev_warn(adap->pdev_dev, "Invalid hash filter config!\n");
938+
return -EINVAL;
939+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ int delete_filter(struct adapter *adapter, unsigned int fidx);
4545

4646
int writable_filter(struct filter_entry *f);
4747
void clear_all_filters(struct adapter *adapter);
48+
int init_hash_filter(struct adapter *adap);
4849
#endif /* __CXGB4_FILTER_H */

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3963,7 +3963,8 @@ static int adap_init0(struct adapter *adap)
39633963
if (ret < 0)
39643964
goto bye;
39653965

3966-
if (caps_cmd.ofldcaps) {
3966+
if (caps_cmd.ofldcaps ||
3967+
(caps_cmd.niccaps & htons(FW_CAPS_CONFIG_NIC_HASHFILTER))) {
39673968
/* query offload-related parameters */
39683969
params[0] = FW_PARAM_DEV(NTID);
39693970
params[1] = FW_PARAM_PFVF(SERVER_START);
@@ -4000,8 +4001,13 @@ static int adap_init0(struct adapter *adap)
40004001
adap->vres.ddp.size = val[4] - val[3] + 1;
40014002
adap->params.ofldq_wr_cred = val[5];
40024003

4003-
adap->params.offload = 1;
4004-
adap->num_ofld_uld += 1;
4004+
if (caps_cmd.niccaps & htons(FW_CAPS_CONFIG_NIC_HASHFILTER)) {
4005+
if (init_hash_filter(adap) < 0)
4006+
goto bye;
4007+
} else {
4008+
adap->params.offload = 1;
4009+
adap->num_ofld_uld += 1;
4010+
}
40054011
}
40064012
if (caps_cmd.rdmacaps) {
40074013
params[0] = FW_PARAM_PFVF(STAG_START);
@@ -5171,7 +5177,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
51715177
cxgb4_init_tc_flower(adapter);
51725178
}
51735179

5174-
if (is_offload(adapter)) {
5180+
if (is_offload(adapter) || is_hashfilter(adapter)) {
51755181
if (t4_read_reg(adapter, LE_DB_CONFIG_A) & HASHEN_F) {
51765182
u32 hash_base, hash_reg;
51775183

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2933,6 +2933,20 @@
29332933
#define SSRAMINTPERR_V(x) ((x) << SSRAMINTPERR_S)
29342934
#define SSRAMINTPERR_F SSRAMINTPERR_V(1U)
29352935

2936+
#define LE_DB_RSP_CODE_0_A 0x19c74
2937+
2938+
#define TCAM_ACTV_HIT_S 0
2939+
#define TCAM_ACTV_HIT_M 0x1fU
2940+
#define TCAM_ACTV_HIT_V(x) ((x) << TCAM_ACTV_HIT_S)
2941+
#define TCAM_ACTV_HIT_G(x) (((x) >> TCAM_ACTV_HIT_S) & TCAM_ACTV_HIT_M)
2942+
2943+
#define LE_DB_RSP_CODE_1_A 0x19c78
2944+
2945+
#define HASH_ACTV_HIT_S 25
2946+
#define HASH_ACTV_HIT_M 0x1fU
2947+
#define HASH_ACTV_HIT_V(x) ((x) << HASH_ACTV_HIT_S)
2948+
#define HASH_ACTV_HIT_G(x) (((x) >> HASH_ACTV_HIT_S) & HASH_ACTV_HIT_M)
2949+
29362950
#define LE_3_DB_HASH_MASK_GEN_IPV4_T6_A 0x19eac
29372951
#define LE_4_DB_HASH_MASK_GEN_IPV4_T6_A 0x19eb0
29382952

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,7 @@ enum fw_caps_config_switch {
10921092
enum fw_caps_config_nic {
10931093
FW_CAPS_CONFIG_NIC = 0x00000001,
10941094
FW_CAPS_CONFIG_NIC_VM = 0x00000002,
1095+
FW_CAPS_CONFIG_NIC_HASHFILTER = 0x00000020,
10951096
};
10961097

10971098
enum fw_caps_config_ofld {

0 commit comments

Comments
 (0)