diff --git a/drivers/net/ethernet/nvidia/nvethernet/macsec.c b/drivers/net/ethernet/nvidia/nvethernet/macsec.c index 2ac9b9d3..2e0e8f86 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/macsec.c +++ b/drivers/net/ethernet/nvidia/nvethernet/macsec.c @@ -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__, diff --git a/drivers/net/ethernet/nvidia/nvethernet/macsec.h b/drivers/net/ethernet/nvidia/nvethernet/macsec.h index cb3ceefe..82ee3035 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/macsec.h +++ b/drivers/net/ethernet/nvidia/nvethernet/macsec.h @@ -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); diff --git a/drivers/net/ethernet/nvidia/nvethernet/sysfs.c b/drivers/net/ethernet/nvidia/nvethernet/sysfs.c index c0a0b533..2b9fc1d9 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/sysfs.c +++ b/drivers/net/ethernet/nvidia/nvethernet/sysfs.c @@ -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,