nvethernet: Update the sysfs with macsec an status

Bug 3757857

Signed-off-by: Sanath Kumar Gampa <sgampa@nvidia.com>
Change-Id: I61101fcd1d8229c5e0b8e9f85aae4cea8320ef07
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2765063
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Mahesh Patil <maheshp@nvidia.com>
Reviewed-by: Bhadram Varka <vbhadram@nvidia.com>
Reviewed-by: Srinivas Ramachandran <srinivasra@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Sanath Kumar Gampa
2022-08-23 08:48:19 +05:30
committed by Revanth Kumar Uppala
parent d4e9ecf359
commit 1cb18af637
3 changed files with 60 additions and 5 deletions

View File

@@ -793,6 +793,8 @@ static int macsec_dis_rx_sa(struct sk_buff *skb, struct genl_info *info)
goto exit;
}
#endif /* !MACSEC_KEY_PROGRAM */
/* Update the macsec pdata when AN is disabled */
macsec_pdata->macsec_rx_an_map &= ~((1U) << (rx_sa.curr_an & 0xFU));
exit:
PRINT_EXIT();
return ret;
@@ -978,7 +980,8 @@ static int macsec_en_rx_sa(struct sk_buff *skb, struct genl_info *info)
goto exit;
}
mutex_unlock(&macsec_pdata->lock);
/* Update the macsec pdata when AN is enabled */
macsec_pdata->macsec_rx_an_map |= ((1U) << (rx_sa.curr_an & 0xFU));
exit:
PRINT_EXIT();
return ret;
@@ -1057,6 +1060,8 @@ static int macsec_dis_tx_sa(struct sk_buff *skb, struct genl_info *info)
}
#endif /* !MACSEC_KEY_PROGRAM */
/* Update the macsec pdata when AN is disbled */
macsec_pdata->macsec_tx_an_map &= ~((1U) << (tx_sa.curr_an & 0xFU));
exit:
PRINT_EXIT();
return ret;
@@ -1204,7 +1209,8 @@ static int macsec_en_tx_sa(struct sk_buff *skb, struct genl_info *info)
}
mutex_unlock(&macsec_pdata->lock);
/* Update the macsec pdata when AN is enabled */
macsec_pdata->macsec_tx_an_map |= ((1U) << (tx_sa.curr_an & 0xFU));
exit:
PRINT_EXIT();
return ret;
@@ -1311,11 +1317,12 @@ static int macsec_init(struct sk_buff *skb, struct genl_info *info)
goto exit;
}
mutex_lock(&macsec_pdata->lock);
if (macsec_pdata->next_supp_idx >= OSI_MAX_NUM_SC) {
/* only one supplicant is allowed per VF */
if (macsec_pdata->next_supp_idx >= MAX_SUPPLICANTS_ALLOWED) {
ret = -EPROTO;
mutex_unlock(&macsec_pdata->lock);
dev_err(dev, "%s: Reached max supported supplicants", __func__);
dev_err(dev, "%s: Reached max supported supplicants %u", __func__,
macsec_pdata->next_supp_idx);
goto exit;
}
@@ -1341,6 +1348,8 @@ static int macsec_init(struct sk_buff *skb, struct genl_info *info)
ret = -EPROTO;
goto exit;
}
macsec_pdata->macsec_rx_an_map = 0U;
macsec_pdata->macsec_tx_an_map = 0U;
done:
atomic_inc(&macsec_pdata->ref_count);
dev_info(dev, "%s: ref_count %d", __func__,

View File

@@ -49,6 +49,11 @@
*/
#define MACSEC_IRQ_NAME_SZ 32
/**
* @brief Maximum number of supplicants allowed per VF
*/
#define MAX_SUPPLICANTS_ALLOWED 1
#define NV_MACSEC_GENL_VERSION 1
#ifdef MACSEC_KEY_PROGRAM
@@ -228,6 +233,10 @@ struct macsec_priv_data {
struct genl_family nv_macsec_fam;
/** Flag to check if nv macsec nl registered */
unsigned int is_nv_macsec_fam_registered;
/** Macsec TX currently enabled AN */
unsigned int macsec_tx_an_map;
/** Macsec RX currently enabled AN */
unsigned int macsec_rx_an_map;
};
int macsec_probe(struct ether_priv_data *pdata);

View File

@@ -182,6 +182,42 @@ static ssize_t ether_mac_loopback_store(struct device *dev,
}
#ifdef MACSEC_SUPPORT
/**
* @brief Shows the current setting of MACsec AN status
*
* Algorithm: Display the current MACsec AN enable status
*
* @param[in] dev: Device data.
* @param[in] attr: Device attribute
* @param[in] buf: Buffer to store the current macsec an status
*/
static ssize_t macsec_an_status_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct net_device *ndev = (struct net_device *)dev_get_drvdata(dev);
struct ether_priv_data *pdata = netdev_priv(ndev);
struct macsec_priv_data *macsec_pdata = pdata->macsec_pdata;
unsigned int macsec_status = 0;
if ((macsec_pdata->macsec_tx_an_map != 0U) &&
(macsec_pdata->macsec_rx_an_map != 0U)) {
macsec_status = OSI_ENABLE;
}
return scnprintf(buf, PAGE_SIZE, "%s\n",
(macsec_status == OSI_ENABLE) ?
"1" : "0");
}
/**
* @brief Sysfs attribute for MACsec irq stats
*
*/
static DEVICE_ATTR(macsec_an_status, (S_IRUGO | S_IWUSR),
macsec_an_status_show,
NULL);
/**
* @brief Shows the current setting of MACsec controllers enabled
*
@@ -2630,6 +2666,7 @@ static struct attribute *ether_sysfs_attrs[] = {
&dev_attr_macsec_sc_param_lut.attr,
&dev_attr_macsec_cipher.attr,
&dev_attr_macsec_enable.attr,
&dev_attr_macsec_an_status.attr,
&dev_attr_macsec_mmc_counters.attr,
#ifdef DEBUG_MACSEC
&dev_attr_macsec_loopback.attr,