Skip to content

Commit 34f8c58

Browse files
committed
Merge branch 'bnxt_en-devlink-param-updates'
Vasundhara Volam says: ==================== bnxt_en: devlink param updates This patchset adds support for 3 generic and 1 driver-specific devlink parameters. Add documentation for these configuration parameters. Also, this patchset adds support to return proper error code if HWRM_NVM_GET/SET_VARIABLE commands return error code HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED. v3->v4: -Remove extra definition of NVM_OFF_HW_TC_OFFLOAD from bnxt_devlink.h -Remove type information for generic parameters from devlink-params-bnxt.txt v2->v3: -Remove description of generic parameters from devlink-params-bnxt.txt v1->v2: -Remove hw_tc_offload parameter. -Update all patches with Cc of MAINTAINERS. -Add more description in commit message for device specific parameter. -Add a new Documentation/networking/devlink-params.txt with some generic devlink parameters information. -Add a new Documentation/networking/devlink-params-bnxt.txt with devlink parameters information that are supported by bnxt_en driver. ==================== Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2 parents 8fa74e3 + 53e233e commit 34f8c58

File tree

6 files changed

+176
-4
lines changed

6 files changed

+176
-4
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
enable_sriov [DEVICE, GENERIC]
2+
Configuration mode: Permanent
3+
4+
ignore_ari [DEVICE, GENERIC]
5+
Configuration mode: Permanent
6+
7+
msix_vec_per_pf_max [DEVICE, GENERIC]
8+
Configuration mode: Permanent
9+
10+
msix_vec_per_pf_min [DEVICE, GENERIC]
11+
Configuration mode: Permanent
12+
13+
gre_ver_check [DEVICE, DRIVER-SPECIFIC]
14+
Generic Routing Encapsulation (GRE) version check will
15+
be enabled in the device. If disabled, device skips
16+
version checking for incoming packets.
17+
Type: Boolean
18+
Configuration mode: Permanent
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Devlink configuration parameters
2+
================================
3+
Following is the list of configuration parameters via devlink interface.
4+
Each parameter can be generic or driver specific and are device level
5+
parameters.
6+
7+
Note that the driver-specific files should contain the generic params
8+
they support to, with supported config modes.
9+
10+
Each parameter can be set in different configuration modes:
11+
runtime - set while driver is running, no reset required.
12+
driverinit - applied while driver initializes, requires restart
13+
driver by devlink reload command.
14+
permanent - written to device's non-volatile memory, hard reset
15+
required.
16+
17+
Following is the list of parameters:
18+
====================================
19+
enable_sriov [DEVICE, GENERIC]
20+
Enable Single Root I/O Virtualisation (SRIOV) in
21+
the device.
22+
Type: Boolean
23+
24+
ignore_ari [DEVICE, GENERIC]
25+
Ignore Alternative Routing-ID Interpretation (ARI)
26+
capability. If enabled, adapter will ignore ARI
27+
capability even when platforms has the support
28+
enabled and creates same number of partitions when
29+
platform does not support ARI.
30+
Type: Boolean
31+
32+
msix_vec_per_pf_max [DEVICE, GENERIC]
33+
Provides the maximum number of MSIX interrupts that
34+
a device can create. Value is same across all
35+
physical functions (PFs) in the device.
36+
Type: u32
37+
38+
msix_vec_per_pf_min [DEVICE, GENERIC]
39+
Provides the minimum number of MSIX interrupts required
40+
for the device initialization. Value is same across all
41+
physical functions (PFs) in the device.
42+
Type: u32

drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,22 @@ static const struct devlink_ops bnxt_dl_ops = {
2121
#endif /* CONFIG_BNXT_SRIOV */
2222
};
2323

24+
enum bnxt_dl_param_id {
25+
BNXT_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
26+
BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK,
27+
};
28+
2429
static const struct bnxt_dl_nvm_param nvm_params[] = {
2530
{DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV, NVM_OFF_ENABLE_SRIOV,
2631
BNXT_NVM_SHARED_CFG, 1},
32+
{DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI, NVM_OFF_IGNORE_ARI,
33+
BNXT_NVM_SHARED_CFG, 1},
34+
{DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX,
35+
NVM_OFF_MSIX_VEC_PER_PF_MAX, BNXT_NVM_SHARED_CFG, 10},
36+
{DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN,
37+
NVM_OFF_MSIX_VEC_PER_PF_MIN, BNXT_NVM_SHARED_CFG, 7},
38+
{BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK, NVM_OFF_DIS_GRE_VER_CHECK,
39+
BNXT_NVM_SHARED_CFG, 1},
2740
};
2841

2942
static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,
@@ -55,8 +68,22 @@ static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,
5568
idx = bp->pf.fw_fid - BNXT_FIRST_PF_FID;
5669

5770
bytesize = roundup(nvm_param.num_bits, BITS_PER_BYTE) / BITS_PER_BYTE;
58-
if (nvm_param.num_bits == 1)
59-
buf = &val->vbool;
71+
switch (bytesize) {
72+
case 1:
73+
if (nvm_param.num_bits == 1)
74+
buf = &val->vbool;
75+
else
76+
buf = &val->vu8;
77+
break;
78+
case 2:
79+
buf = &val->vu16;
80+
break;
81+
case 4:
82+
buf = &val->vu32;
83+
break;
84+
default:
85+
return -EFAULT;
86+
}
6087

6188
data_addr = dma_zalloc_coherent(&bp->pdev->dev, bytesize,
6289
&data_dma_addr, GFP_KERNEL);
@@ -78,8 +105,12 @@ static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,
78105
memcpy(buf, data_addr, bytesize);
79106

80107
dma_free_coherent(&bp->pdev->dev, bytesize, data_addr, data_dma_addr);
81-
if (rc)
108+
if (rc == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) {
109+
netdev_err(bp->dev, "PF does not have admin privileges to modify NVM config\n");
110+
return -EACCES;
111+
} else if (rc) {
82112
return -EIO;
113+
}
83114
return 0;
84115
}
85116

@@ -88,9 +119,15 @@ static int bnxt_dl_nvm_param_get(struct devlink *dl, u32 id,
88119
{
89120
struct hwrm_nvm_get_variable_input req = {0};
90121
struct bnxt *bp = bnxt_get_bp_from_dl(dl);
122+
int rc;
91123

92124
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_NVM_GET_VARIABLE, -1, -1);
93-
return bnxt_hwrm_nvm_req(bp, id, &req, sizeof(req), &ctx->val);
125+
rc = bnxt_hwrm_nvm_req(bp, id, &req, sizeof(req), &ctx->val);
126+
if (!rc)
127+
if (id == BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK)
128+
ctx->val.vbool = !ctx->val.vbool;
129+
130+
return rc;
94131
}
95132

96133
static int bnxt_dl_nvm_param_set(struct devlink *dl, u32 id,
@@ -100,14 +137,55 @@ static int bnxt_dl_nvm_param_set(struct devlink *dl, u32 id,
100137
struct bnxt *bp = bnxt_get_bp_from_dl(dl);
101138

102139
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_NVM_SET_VARIABLE, -1, -1);
140+
141+
if (id == BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK)
142+
ctx->val.vbool = !ctx->val.vbool;
143+
103144
return bnxt_hwrm_nvm_req(bp, id, &req, sizeof(req), &ctx->val);
104145
}
105146

147+
static int bnxt_dl_msix_validate(struct devlink *dl, u32 id,
148+
union devlink_param_value val,
149+
struct netlink_ext_ack *extack)
150+
{
151+
int max_val;
152+
153+
if (id == DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX)
154+
max_val = BNXT_MSIX_VEC_MAX;
155+
156+
if (id == DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN)
157+
max_val = BNXT_MSIX_VEC_MIN_MAX;
158+
159+
if (val.vu32 < 0 || val.vu32 > max_val) {
160+
NL_SET_ERR_MSG_MOD(extack, "MSIX value is exceeding the range");
161+
return -EINVAL;
162+
}
163+
164+
return 0;
165+
}
166+
106167
static const struct devlink_param bnxt_dl_params[] = {
107168
DEVLINK_PARAM_GENERIC(ENABLE_SRIOV,
108169
BIT(DEVLINK_PARAM_CMODE_PERMANENT),
109170
bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set,
110171
NULL),
172+
DEVLINK_PARAM_GENERIC(IGNORE_ARI,
173+
BIT(DEVLINK_PARAM_CMODE_PERMANENT),
174+
bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set,
175+
NULL),
176+
DEVLINK_PARAM_GENERIC(MSIX_VEC_PER_PF_MAX,
177+
BIT(DEVLINK_PARAM_CMODE_PERMANENT),
178+
bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set,
179+
bnxt_dl_msix_validate),
180+
DEVLINK_PARAM_GENERIC(MSIX_VEC_PER_PF_MIN,
181+
BIT(DEVLINK_PARAM_CMODE_PERMANENT),
182+
bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set,
183+
bnxt_dl_msix_validate),
184+
DEVLINK_PARAM_DRIVER(BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK,
185+
"gre_ver_check", DEVLINK_PARAM_TYPE_BOOL,
186+
BIT(DEVLINK_PARAM_CMODE_PERMANENT),
187+
bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set,
188+
NULL),
111189
};
112190

113191
int bnxt_dl_register(struct bnxt *bp)

drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@ static inline void bnxt_link_bp_to_dl(struct bnxt *bp, struct devlink *dl)
3333
}
3434
}
3535

36+
#define NVM_OFF_MSIX_VEC_PER_PF_MAX 108
37+
#define NVM_OFF_MSIX_VEC_PER_PF_MIN 114
38+
#define NVM_OFF_IGNORE_ARI 164
39+
#define NVM_OFF_DIS_GRE_VER_CHECK 171
3640
#define NVM_OFF_ENABLE_SRIOV 401
3741

42+
#define BNXT_MSIX_VEC_MAX 1280
43+
#define BNXT_MSIX_VEC_MIN_MAX 128
44+
3845
enum bnxt_nvm_dir_type {
3946
BNXT_NVM_SHARED_CFG = 40,
4047
BNXT_NVM_PORT_CFG,

include/net/devlink.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ enum devlink_param_generic_id {
362362
DEVLINK_PARAM_GENERIC_ID_MAX_MACS,
363363
DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV,
364364
DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT,
365+
DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI,
366+
DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX,
367+
DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN,
365368

366369
/* add new param generic ids above here*/
367370
__DEVLINK_PARAM_GENERIC_ID_MAX,
@@ -380,6 +383,15 @@ enum devlink_param_generic_id {
380383
#define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME "region_snapshot_enable"
381384
#define DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE DEVLINK_PARAM_TYPE_BOOL
382385

386+
#define DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME "ignore_ari"
387+
#define DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE DEVLINK_PARAM_TYPE_BOOL
388+
389+
#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME "msix_vec_per_pf_max"
390+
#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE DEVLINK_PARAM_TYPE_U32
391+
392+
#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME "msix_vec_per_pf_min"
393+
#define DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE DEVLINK_PARAM_TYPE_U32
394+
383395
#define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \
384396
{ \
385397
.id = DEVLINK_PARAM_GENERIC_ID_##_id, \

net/core/devlink.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,6 +2677,21 @@ static const struct devlink_param devlink_param_generic[] = {
26772677
.name = DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_NAME,
26782678
.type = DEVLINK_PARAM_GENERIC_REGION_SNAPSHOT_TYPE,
26792679
},
2680+
{
2681+
.id = DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI,
2682+
.name = DEVLINK_PARAM_GENERIC_IGNORE_ARI_NAME,
2683+
.type = DEVLINK_PARAM_GENERIC_IGNORE_ARI_TYPE,
2684+
},
2685+
{
2686+
.id = DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX,
2687+
.name = DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_NAME,
2688+
.type = DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MAX_TYPE,
2689+
},
2690+
{
2691+
.id = DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN,
2692+
.name = DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_NAME,
2693+
.type = DEVLINK_PARAM_GENERIC_MSIX_VEC_PER_PF_MIN_TYPE,
2694+
},
26802695
};
26812696

26822697
static int devlink_param_generic_verify(const struct devlink_param *param)

0 commit comments

Comments
 (0)