From dc3d0a02f71961e5f28f4697e2768719e3b01268 Mon Sep 17 00:00:00 2001 From: Sanath Kumar Gampa Date: Fri, 24 Sep 2021 17:59:21 +0530 Subject: [PATCH] nvethernet:MACSEC preempt/ctrl-port config via LUT Issue: There is no provision to program the preempt or control-port fields in SCI or BYP LUTs Fix: Added changes in sysfs programming to add this support Bug 200778243 Change-Id: I60f5bb3f21a0bf5aeb72ffdbb9db376812bef4fa Signed-off-by: Sanath Kumar Gampa Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2600109 Tested-by: mobile promotions Reviewed-by: Bhadram Varka Reviewed-by: Mahesh Patil Reviewed-by: Srinivas Ramachandran Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit --- .../net/ethernet/nvidia/nvethernet/macsec.h | 11 ++++++++ .../net/ethernet/nvidia/nvethernet/sysfs.c | 26 ++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/nvidia/nvethernet/macsec.h b/drivers/net/ethernet/nvidia/nvethernet/macsec.h index 5ce63a56..7f856961 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/macsec.h +++ b/drivers/net/ethernet/nvidia/nvethernet/macsec.h @@ -28,6 +28,17 @@ #include #include + +/** + * @brief Expected number of inputs in BYP or SCI LUT sysfs config + */ +#define LUT_INPUTS_LEN 39 + +/** + * @brief Expected number of extra inputs in BYP LUT sysfs config + */ +#define BYP_LUT_INPUTS 1 + /** * @brief Size of Macsec IRQ name. */ diff --git a/drivers/net/ethernet/nvidia/nvethernet/sysfs.c b/drivers/net/ethernet/nvidia/nvethernet/sysfs.c index 692eb3e2..a02b80a3 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/sysfs.c +++ b/drivers/net/ethernet/nvidia/nvethernet/sysfs.c @@ -15,6 +15,7 @@ */ #include "ether_linux.h" +#include "macsec.h" #ifdef CONFIG_DEBUG_FS /* As per IAS Docs */ @@ -568,7 +569,6 @@ static void format_output(char **buf_p, return; } -#define LUT_INPUTS_LEN 37 static int parse_inputs(const char *buf, struct osi_macsec_lut_config *lut_config, int *bufp) @@ -587,6 +587,7 @@ static int parse_inputs(const char *buf, unsigned short controller; int mac_da_valid, mac_sa_valid, ethtype_valid, vlan_valid; int dvlan, dvlan_outer_tag; + int prempt, prempt_valid; int byte_valid[OSI_LUT_BYTE_PATTERN_MAX]; int i, valid, index;; @@ -599,7 +600,8 @@ static int parse_inputs(const char *buf, "%x %u %d " "%x %u %d " "%x %u %d " - "%u %u %d %d %d%n", + "%u %u %d %d %d " + "%d %d%n", &valid, &index, &controller, &temp[0], &temp[1], &temp[2], &temp[3], &temp[4], &temp[5], &mac_da_valid, @@ -610,7 +612,8 @@ static int parse_inputs(const char *buf, &temp3[1], &byte_offset[1], &byte_valid[1], &temp3[2], &byte_offset[2], &byte_valid[2], &temp3[3], &byte_offset[3], &byte_valid[3], - &vlan_pcp, &vlan_id, &vlan_valid, &dvlan, &dvlan_outer_tag, bufp); + &vlan_pcp, &vlan_id, &vlan_valid, &dvlan, &dvlan_outer_tag, + &prempt, &prempt_valid, bufp); if (i != LUT_INPUTS_LEN) { pr_err("%s: Invalid LUT inputs(read %d)", __func__, i); @@ -707,6 +710,12 @@ static int parse_inputs(const char *buf, } } + if (prempt_valid) { + flags |= OSI_LUT_FLAGS_PREEMPT_VALID; + if (prempt) + flags |= OSI_LUT_FLAGS_PREEMPT; + } + if (valid) { flags |= OSI_LUT_FLAGS_ENTRY_VALID; } @@ -808,7 +817,7 @@ static ssize_t macsec_byp_lut_store(struct device *dev, struct ether_priv_data *pdata = netdev_priv(ndev); struct osi_core_priv_data *osi_core = pdata->osi_core; struct osi_macsec_lut_config lut_config; - int ret, bufp; + int ret, bufp, ctrl_port; if (!netif_running(ndev)) { dev_err(pdata->dev, "Not Allowed. Ether interface is not up\n"); @@ -821,6 +830,15 @@ static ssize_t macsec_byp_lut_store(struct device *dev, goto exit; } + ret = sscanf(buf + bufp, " %d", &ctrl_port); + + if (ret != BYP_LUT_INPUTS) { + dev_err(pdata->dev, "Failed to parse BYP LUT arguments"); + goto exit; + } + if (ctrl_port) + lut_config.flags |= OSI_LUT_FLAGS_CONTROLLED_PORT; + lut_config.lut_sel = OSI_LUT_SEL_BYPASS; lut_config.table_config.rw = OSI_LUT_WRITE; /* Rest of LUT attributes are filled by parse_inputs() */