Skip to content

Commit a59618b

Browse files
pkaminskanguy11
authored andcommitted
ice: Add support for devlink local_forwarding param
Add support for driver-specific devlink local_forwarding param. Supported values are "enabled", "disabled" and "prioritized". Default configuration is set to "enabled". Add documentation in networking/devlink/ice.rst. In previous generations of Intel NICs the transmit scheduler was only limited by PCIe bandwidth when scheduling/assigning hairpin-bandwidth between VFs. Changes to E810 HW design introduced scheduler limitation, so that available hairpin-bandwidth is bound to external port speed. In order to address this limitation and enable NFV services such as "service chaining" a knob to adjust the scheduler config was created. Driver can send a configuration message to the FW over admin queue and internal FW logic will reconfigure HW to prioritize and add more BW to VF to VF traffic. An end result, for example, 10G port will no longer limit hairpin-bandwidth to 10G and much higher speeds can be achieved. Devlink local_forwarding param set to "prioritized" enables higher hairpin-bandwitdh on related PFs. Configuration is applicable only to 8x10G and 4x25G cards. Changing local_forwarding configuration will trigger CORER reset in order to take effect. Example command to change current value: devlink dev param set pci/0000:b2:00.3 name local_forwarding \ value prioritized \ cmode runtime Co-developed-by: Michal Wilczynski <[email protected]> Signed-off-by: Michal Wilczynski <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Signed-off-by: Pawel Kaminski <[email protected]> Signed-off-by: Wojciech Drewek <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 4c8c36f commit a59618b

File tree

5 files changed

+166
-1
lines changed

5 files changed

+166
-1
lines changed

Documentation/networking/devlink/ice.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Parameters
1111
==========
1212

1313
.. list-table:: Generic parameters implemented
14+
:widths: 5 5 90
1415

1516
* - Name
1617
- Mode
@@ -68,6 +69,30 @@ Parameters
6869

6970
To verify that value has been set:
7071
$ devlink dev param show pci/0000:16:00.0 name tx_scheduling_layers
72+
.. list-table:: Driver specific parameters implemented
73+
:widths: 5 5 90
74+
75+
* - Name
76+
- Mode
77+
- Description
78+
* - ``local_forwarding``
79+
- runtime
80+
- Controls loopback behavior by tuning scheduler bandwidth.
81+
It impacts all kinds of functions: physical, virtual and
82+
subfunctions.
83+
Supported values are:
84+
85+
``enabled`` - loopback traffic is allowed on port
86+
87+
``disabled`` - loopback traffic is not allowed on this port
88+
89+
``prioritized`` - loopback traffic is prioritized on this port
90+
91+
Default value of ``local_forwarding`` parameter is ``enabled``.
92+
``prioritized`` provides ability to adjust loopback traffic rate to increase
93+
one port capacity at cost of the another. User needs to disable
94+
local forwarding on one of the ports in order have increased capacity
95+
on the ``prioritized`` port.
7196

7297
Info versions
7398
=============

drivers/net/ethernet/intel/ice/devlink/devlink.c

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,9 +1381,129 @@ ice_devlink_enable_iw_validate(struct devlink *devlink, u32 id,
13811381
return 0;
13821382
}
13831383

1384+
#define DEVLINK_LOCAL_FWD_DISABLED_STR "disabled"
1385+
#define DEVLINK_LOCAL_FWD_ENABLED_STR "enabled"
1386+
#define DEVLINK_LOCAL_FWD_PRIORITIZED_STR "prioritized"
1387+
1388+
/**
1389+
* ice_devlink_local_fwd_mode_to_str - Get string for local_fwd mode.
1390+
* @mode: local forwarding for mode used in port_info struct.
1391+
*
1392+
* Return: Mode respective string or "Invalid".
1393+
*/
1394+
static const char *
1395+
ice_devlink_local_fwd_mode_to_str(enum ice_local_fwd_mode mode)
1396+
{
1397+
switch (mode) {
1398+
case ICE_LOCAL_FWD_MODE_ENABLED:
1399+
return DEVLINK_LOCAL_FWD_ENABLED_STR;
1400+
case ICE_LOCAL_FWD_MODE_PRIORITIZED:
1401+
return DEVLINK_LOCAL_FWD_PRIORITIZED_STR;
1402+
case ICE_LOCAL_FWD_MODE_DISABLED:
1403+
return DEVLINK_LOCAL_FWD_DISABLED_STR;
1404+
}
1405+
1406+
return "Invalid";
1407+
}
1408+
1409+
/**
1410+
* ice_devlink_local_fwd_str_to_mode - Get local_fwd mode from string name.
1411+
* @mode_str: local forwarding mode string.
1412+
*
1413+
* Return: Mode value or negative number if invalid.
1414+
*/
1415+
static int ice_devlink_local_fwd_str_to_mode(const char *mode_str)
1416+
{
1417+
if (!strcmp(mode_str, DEVLINK_LOCAL_FWD_ENABLED_STR))
1418+
return ICE_LOCAL_FWD_MODE_ENABLED;
1419+
else if (!strcmp(mode_str, DEVLINK_LOCAL_FWD_PRIORITIZED_STR))
1420+
return ICE_LOCAL_FWD_MODE_PRIORITIZED;
1421+
else if (!strcmp(mode_str, DEVLINK_LOCAL_FWD_DISABLED_STR))
1422+
return ICE_LOCAL_FWD_MODE_DISABLED;
1423+
1424+
return -EINVAL;
1425+
}
1426+
1427+
/**
1428+
* ice_devlink_local_fwd_get - Get local_fwd parameter.
1429+
* @devlink: Pointer to the devlink instance.
1430+
* @id: The parameter ID to set.
1431+
* @ctx: Context to store the parameter value.
1432+
*
1433+
* Return: Zero.
1434+
*/
1435+
static int ice_devlink_local_fwd_get(struct devlink *devlink, u32 id,
1436+
struct devlink_param_gset_ctx *ctx)
1437+
{
1438+
struct ice_pf *pf = devlink_priv(devlink);
1439+
struct ice_port_info *pi;
1440+
const char *mode_str;
1441+
1442+
pi = pf->hw.port_info;
1443+
mode_str = ice_devlink_local_fwd_mode_to_str(pi->local_fwd_mode);
1444+
snprintf(ctx->val.vstr, sizeof(ctx->val.vstr), "%s", mode_str);
1445+
1446+
return 0;
1447+
}
1448+
1449+
/**
1450+
* ice_devlink_local_fwd_set - Set local_fwd parameter.
1451+
* @devlink: Pointer to the devlink instance.
1452+
* @id: The parameter ID to set.
1453+
* @ctx: Context to get the parameter value.
1454+
* @extack: Netlink extended ACK structure.
1455+
*
1456+
* Return: Zero.
1457+
*/
1458+
static int ice_devlink_local_fwd_set(struct devlink *devlink, u32 id,
1459+
struct devlink_param_gset_ctx *ctx,
1460+
struct netlink_ext_ack *extack)
1461+
{
1462+
int new_local_fwd_mode = ice_devlink_local_fwd_str_to_mode(ctx->val.vstr);
1463+
struct ice_pf *pf = devlink_priv(devlink);
1464+
struct device *dev = ice_pf_to_dev(pf);
1465+
struct ice_port_info *pi;
1466+
1467+
pi = pf->hw.port_info;
1468+
if (pi->local_fwd_mode != new_local_fwd_mode) {
1469+
pi->local_fwd_mode = new_local_fwd_mode;
1470+
dev_info(dev, "Setting local_fwd to %s\n", ctx->val.vstr);
1471+
ice_schedule_reset(pf, ICE_RESET_CORER);
1472+
}
1473+
1474+
return 0;
1475+
}
1476+
1477+
/**
1478+
* ice_devlink_local_fwd_validate - Validate passed local_fwd parameter value.
1479+
* @devlink: Unused pointer to devlink instance.
1480+
* @id: The parameter ID to validate.
1481+
* @val: Value to validate.
1482+
* @extack: Netlink extended ACK structure.
1483+
*
1484+
* Supported values are:
1485+
* "enabled" - local_fwd is enabled, "disabled" - local_fwd is disabled
1486+
* "prioritized" - local_fwd traffic is prioritized in scheduling.
1487+
*
1488+
* Return: Zero when passed parameter value is supported. Negative value on
1489+
* error.
1490+
*/
1491+
static int ice_devlink_local_fwd_validate(struct devlink *devlink, u32 id,
1492+
union devlink_param_value val,
1493+
struct netlink_ext_ack *extack)
1494+
{
1495+
if (ice_devlink_local_fwd_str_to_mode(val.vstr) < 0) {
1496+
NL_SET_ERR_MSG_MOD(extack, "Error: Requested value is not supported.");
1497+
return -EINVAL;
1498+
}
1499+
1500+
return 0;
1501+
}
1502+
13841503
enum ice_param_id {
13851504
ICE_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
13861505
ICE_DEVLINK_PARAM_ID_TX_SCHED_LAYERS,
1506+
ICE_DEVLINK_PARAM_ID_LOCAL_FWD,
13871507
};
13881508

13891509
static const struct devlink_param ice_dvl_rdma_params[] = {
@@ -1405,6 +1525,12 @@ static const struct devlink_param ice_dvl_sched_params[] = {
14051525
ice_devlink_tx_sched_layers_get,
14061526
ice_devlink_tx_sched_layers_set,
14071527
ice_devlink_tx_sched_layers_validate),
1528+
DEVLINK_PARAM_DRIVER(ICE_DEVLINK_PARAM_ID_LOCAL_FWD,
1529+
"local_forwarding", DEVLINK_PARAM_TYPE_STRING,
1530+
BIT(DEVLINK_PARAM_CMODE_RUNTIME),
1531+
ice_devlink_local_fwd_get,
1532+
ice_devlink_local_fwd_set,
1533+
ice_devlink_local_fwd_validate),
14081534
};
14091535

14101536
static void ice_devlink_free(void *devlink_ptr)

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ struct ice_aqc_get_sw_cfg_resp_elem {
232232
#define ICE_AQC_GET_SW_CONF_RESP_IS_VF BIT(15)
233233
};
234234

235+
/* Loopback port parameter mode values. */
236+
enum ice_local_fwd_mode {
237+
ICE_LOCAL_FWD_MODE_ENABLED = 0,
238+
ICE_LOCAL_FWD_MODE_DISABLED = 1,
239+
ICE_LOCAL_FWD_MODE_PRIORITIZED = 2,
240+
};
241+
235242
/* Set Port parameters, (direct, 0x0203) */
236243
struct ice_aqc_set_port_params {
237244
__le16 cmd_flags;
@@ -240,7 +247,9 @@ struct ice_aqc_set_port_params {
240247
__le16 swid;
241248
#define ICE_AQC_PORT_SWID_VALID BIT(15)
242249
#define ICE_AQC_PORT_SWID_M 0xFF
243-
u8 reserved[10];
250+
u8 local_fwd_mode;
251+
#define ICE_AQC_SET_P_PARAMS_LOCAL_FWD_MODE_VALID BIT(2)
252+
u8 reserved[9];
244253
};
245254

246255
/* These resource type defines are used for all switch resource

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,7 @@ int ice_init_hw(struct ice_hw *hw)
10861086
goto err_unroll_cqinit;
10871087
}
10881088

1089+
hw->port_info->local_fwd_mode = ICE_LOCAL_FWD_MODE_ENABLED;
10891090
/* set the back pointer to HW */
10901091
hw->port_info->hw = hw;
10911092

@@ -3071,6 +3072,9 @@ ice_aq_set_port_params(struct ice_port_info *pi, bool double_vlan,
30713072
cmd_flags |= ICE_AQC_SET_P_PARAMS_DOUBLE_VLAN_ENA;
30723073
cmd->cmd_flags = cpu_to_le16(cmd_flags);
30733074

3075+
cmd->local_fwd_mode = pi->local_fwd_mode |
3076+
ICE_AQC_SET_P_PARAMS_LOCAL_FWD_MODE_VALID;
3077+
30743078
return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
30753079
}
30763080

drivers/net/ethernet/intel/ice/ice_type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ struct ice_port_info {
738738
u16 sw_id; /* Initial switch ID belongs to port */
739739
u16 pf_vf_num;
740740
u8 port_state;
741+
u8 local_fwd_mode;
741742
#define ICE_SCHED_PORT_STATE_INIT 0x0
742743
#define ICE_SCHED_PORT_STATE_READY 0x1
743744
u8 lport;

0 commit comments

Comments
 (0)