Skip to content

Commit ef83e18

Browse files
rkannoth1kuba-moo
authored andcommitted
octeontx2-af: devlink configuration support
CN10KB silicon supports Exact match feature. This feature can be disabled through devlink configuration. Devlink command fails if DMAC filter rules are already present. Once disabled, legacy RPM based DMAC filters will be configured. Signed-off-by: Ratheesh Kannoth <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 812103e commit ef83e18

File tree

3 files changed

+101
-2
lines changed

3 files changed

+101
-2
lines changed

drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "rvu.h"
1111
#include "rvu_reg.h"
1212
#include "rvu_struct.h"
13+
#include "rvu_npc_hash.h"
1314

1415
#define DRV_NAME "octeontx2-af"
1516

@@ -1436,14 +1437,75 @@ static int rvu_af_dl_dwrr_mtu_get(struct devlink *devlink, u32 id,
14361437
enum rvu_af_dl_param_id {
14371438
RVU_AF_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
14381439
RVU_AF_DEVLINK_PARAM_ID_DWRR_MTU,
1440+
RVU_AF_DEVLINK_PARAM_ID_NPC_EXACT_FEATURE_DISABLE,
14391441
};
14401442

1443+
static int rvu_af_npc_exact_feature_get(struct devlink *devlink, u32 id,
1444+
struct devlink_param_gset_ctx *ctx)
1445+
{
1446+
struct rvu_devlink *rvu_dl = devlink_priv(devlink);
1447+
struct rvu *rvu = rvu_dl->rvu;
1448+
bool enabled;
1449+
1450+
enabled = rvu_npc_exact_has_match_table(rvu);
1451+
1452+
snprintf(ctx->val.vstr, sizeof(ctx->val.vstr), "%s",
1453+
enabled ? "enabled" : "disabled");
1454+
1455+
return 0;
1456+
}
1457+
1458+
static int rvu_af_npc_exact_feature_disable(struct devlink *devlink, u32 id,
1459+
struct devlink_param_gset_ctx *ctx)
1460+
{
1461+
struct rvu_devlink *rvu_dl = devlink_priv(devlink);
1462+
struct rvu *rvu = rvu_dl->rvu;
1463+
1464+
rvu_npc_exact_disable_feature(rvu);
1465+
1466+
return 0;
1467+
}
1468+
1469+
static int rvu_af_npc_exact_feature_validate(struct devlink *devlink, u32 id,
1470+
union devlink_param_value val,
1471+
struct netlink_ext_ack *extack)
1472+
{
1473+
struct rvu_devlink *rvu_dl = devlink_priv(devlink);
1474+
struct rvu *rvu = rvu_dl->rvu;
1475+
u64 enable;
1476+
1477+
if (kstrtoull(val.vstr, 10, &enable)) {
1478+
NL_SET_ERR_MSG_MOD(extack,
1479+
"Only 1 value is supported");
1480+
return -EINVAL;
1481+
}
1482+
1483+
if (enable != 1) {
1484+
NL_SET_ERR_MSG_MOD(extack,
1485+
"Only disabling exact match feature is supported");
1486+
return -EINVAL;
1487+
}
1488+
1489+
if (rvu_npc_exact_can_disable_feature(rvu))
1490+
return 0;
1491+
1492+
NL_SET_ERR_MSG_MOD(extack,
1493+
"Can't disable exact match feature; Please try before any configuration");
1494+
return -EFAULT;
1495+
}
1496+
14411497
static const struct devlink_param rvu_af_dl_params[] = {
14421498
DEVLINK_PARAM_DRIVER(RVU_AF_DEVLINK_PARAM_ID_DWRR_MTU,
14431499
"dwrr_mtu", DEVLINK_PARAM_TYPE_U32,
14441500
BIT(DEVLINK_PARAM_CMODE_RUNTIME),
14451501
rvu_af_dl_dwrr_mtu_get, rvu_af_dl_dwrr_mtu_set,
14461502
rvu_af_dl_dwrr_mtu_validate),
1503+
DEVLINK_PARAM_DRIVER(RVU_AF_DEVLINK_PARAM_ID_NPC_EXACT_FEATURE_DISABLE,
1504+
"npc_exact_feature_disable", DEVLINK_PARAM_TYPE_STRING,
1505+
BIT(DEVLINK_PARAM_CMODE_RUNTIME),
1506+
rvu_af_npc_exact_feature_get,
1507+
rvu_af_npc_exact_feature_disable,
1508+
rvu_af_npc_exact_feature_validate),
14471509
};
14481510

14491511
/* Devlink switch mode */
@@ -1501,6 +1563,7 @@ int rvu_register_dl(struct rvu *rvu)
15011563
{
15021564
struct rvu_devlink *rvu_dl;
15031565
struct devlink *dl;
1566+
size_t size;
15041567
int err;
15051568

15061569
dl = devlink_alloc(&rvu_devlink_ops, sizeof(struct rvu_devlink),
@@ -1522,8 +1585,12 @@ int rvu_register_dl(struct rvu *rvu)
15221585
goto err_dl_health;
15231586
}
15241587

1525-
err = devlink_params_register(dl, rvu_af_dl_params,
1526-
ARRAY_SIZE(rvu_af_dl_params));
1588+
/* Register exact match devlink only for CN10K-B */
1589+
size = ARRAY_SIZE(rvu_af_dl_params);
1590+
if (!rvu_npc_exact_has_match_table(rvu))
1591+
size -= 1;
1592+
1593+
err = devlink_params_register(dl, rvu_af_dl_params, size);
15271594
if (err) {
15281595
dev_err(rvu->dev,
15291596
"devlink params register failed with error %d", err);

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,35 @@ static int __maybe_unused rvu_npc_exact_update_table_entry(struct rvu *rvu, u8 c
11541154
return 0;
11551155
}
11561156

1157+
/**
1158+
* rvu_npc_exact_can_disable_feature - Check if feature can be disabled.
1159+
* @rvu: resource virtualization unit.
1160+
* Return: True if exact match feature is supported.
1161+
*/
1162+
bool rvu_npc_exact_can_disable_feature(struct rvu *rvu)
1163+
{
1164+
struct npc_exact_table *table = rvu->hw->table;
1165+
bool empty;
1166+
1167+
if (!rvu->hw->cap.npc_exact_match_enabled)
1168+
return false;
1169+
1170+
mutex_lock(&table->lock);
1171+
empty = list_empty(&table->lhead_gbl);
1172+
mutex_unlock(&table->lock);
1173+
1174+
return empty;
1175+
}
1176+
1177+
/**
1178+
* rvu_npc_exact_disable_feature - Disable feature.
1179+
* @rvu: resource virtualization unit.
1180+
*/
1181+
void rvu_npc_exact_disable_feature(struct rvu *rvu)
1182+
{
1183+
rvu->hw->cap.npc_exact_match_enabled = false;
1184+
}
1185+
11571186
/**
11581187
* rvu_npc_exact_init - initialize exact match table
11591188
* @rvu: resource virtualization unit.

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,7 @@ int rvu_npc_exact_del_table_entry_by_id(struct rvu *rvu, u32 seq_id);
185185
u32 rvu_npc_exact_get_max_entries(struct rvu *rvu);
186186
int rvu_npc_exact_init(struct rvu *rvu);
187187

188+
bool rvu_npc_exact_can_disable_feature(struct rvu *rvu);
189+
void rvu_npc_exact_disable_feature(struct rvu *rvu);
190+
188191
#endif /* RVU_NPC_HASH_H */

0 commit comments

Comments
 (0)