mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-23 17:55:05 +03:00
nvethernet: Support macsec enablement via DT
Issue: Name of the nl_family is nv_macsec for all the interfaces hence even if the macsec is enabled for one interface and disabled for other interfaces, supplicant can be launched for all the interfaces. Fix: Use the interface name for the nl_family name hence supplicant can check if macsec is enabled in DT before initializing supplicant for that particular interface Bug 3673434 Change-Id: I33d62a0ab2b74f7f53abcd8e6629c1b013eede86 Signed-off-by: Sanath Kumar Gampa <sgampa@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2726483 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Revanth Kumar Uppala
parent
4c8ec560fa
commit
0913e1b2ed
@@ -6533,6 +6533,12 @@ static int ether_probe(struct platform_device *pdev)
|
|||||||
ether_tx_usecs_hrtimer;
|
ether_tx_usecs_hrtimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = register_netdev(ndev);
|
||||||
|
if (ret < 0) {
|
||||||
|
dev_err(&pdev->dev, "failed to register netdev\n");
|
||||||
|
goto err_netdev;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef MACSEC_SUPPORT
|
#ifdef MACSEC_SUPPORT
|
||||||
ret = macsec_probe(pdata);
|
ret = macsec_probe(pdata);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -6540,7 +6546,7 @@ static int ether_probe(struct platform_device *pdev)
|
|||||||
goto err_macsec;
|
goto err_macsec;
|
||||||
} else if (ret == 1) {
|
} else if (ret == 1) {
|
||||||
/* Nothing to do, macsec is not supported */
|
/* Nothing to do, macsec is not supported */
|
||||||
dev_info(&pdev->dev, "Macsec not supported\n");
|
dev_info(&pdev->dev, "Macsec not supported/Not enabled in DT\n");
|
||||||
} else {
|
} else {
|
||||||
dev_info(&pdev->dev, "Macsec not enabled\n");
|
dev_info(&pdev->dev, "Macsec not enabled\n");
|
||||||
/* Macsec is supported, reduce MTU */
|
/* Macsec is supported, reduce MTU */
|
||||||
@@ -6550,12 +6556,6 @@ static int ether_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
#endif /* MACSEC_SUPPORT */
|
#endif /* MACSEC_SUPPORT */
|
||||||
|
|
||||||
ret = register_netdev(ndev);
|
|
||||||
if (ret < 0) {
|
|
||||||
dev_err(&pdev->dev, "failed to register netdev\n");
|
|
||||||
goto err_netdev;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Register sysfs entry */
|
/* Register sysfs entry */
|
||||||
ret = ether_sysfs_register(pdata);
|
ret = ether_sysfs_register(pdata);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -6614,11 +6614,11 @@ static int ether_probe(struct platform_device *pdev)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_sysfs:
|
err_sysfs:
|
||||||
unregister_netdev(ndev);
|
|
||||||
err_netdev:
|
|
||||||
#ifdef MACSEC_SUPPORT
|
#ifdef MACSEC_SUPPORT
|
||||||
err_macsec:
|
err_macsec:
|
||||||
#endif /* MACSEC_SUPPORT */
|
#endif /* MACSEC_SUPPORT */
|
||||||
|
unregister_netdev(ndev);
|
||||||
|
err_netdev:
|
||||||
err_dma_mask:
|
err_dma_mask:
|
||||||
ether_disable_clks(pdata);
|
ether_disable_clks(pdata);
|
||||||
ether_put_clks(pdata);
|
ether_put_clks(pdata);
|
||||||
|
|||||||
@@ -22,10 +22,6 @@
|
|||||||
#ifdef HSI_SUPPORT
|
#ifdef HSI_SUPPORT
|
||||||
#include <linux/tegra-epl.h>
|
#include <linux/tegra-epl.h>
|
||||||
#endif
|
#endif
|
||||||
/**
|
|
||||||
* @brief is_nv_macsec_fam_registered - Is nv macsec nl registered
|
|
||||||
*/
|
|
||||||
static int is_nv_macsec_fam_registered = OSI_DISABLE;
|
|
||||||
static int macsec_get_tx_next_pn(struct sk_buff *skb, struct genl_info *info);
|
static int macsec_get_tx_next_pn(struct sk_buff *skb, struct genl_info *info);
|
||||||
|
|
||||||
#ifndef MACSEC_KEY_PROGRAM
|
#ifndef MACSEC_KEY_PROGRAM
|
||||||
@@ -1472,16 +1468,6 @@ static const struct genl_ops nv_macsec_genl_ops[] = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct genl_family nv_macsec_fam = {
|
|
||||||
.name = NV_MACSEC_GENL_NAME,
|
|
||||||
.hdrsize = 0,
|
|
||||||
.version = NV_MACSEC_GENL_VERSION,
|
|
||||||
.maxattr = NV_MACSEC_ATTR_MAX,
|
|
||||||
.module = THIS_MODULE,
|
|
||||||
.ops = nv_macsec_genl_ops,
|
|
||||||
.n_ops = ARRAY_SIZE(nv_macsec_genl_ops),
|
|
||||||
};
|
|
||||||
|
|
||||||
void macsec_remove(struct ether_priv_data *pdata)
|
void macsec_remove(struct ether_priv_data *pdata)
|
||||||
{
|
{
|
||||||
struct macsec_priv_data *macsec_pdata = NULL;
|
struct macsec_priv_data *macsec_pdata = NULL;
|
||||||
@@ -1509,9 +1495,9 @@ void macsec_remove(struct ether_priv_data *pdata)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Unregister generic netlink */
|
/* Unregister generic netlink */
|
||||||
if (is_nv_macsec_fam_registered == OSI_ENABLE) {
|
if (macsec_pdata->is_nv_macsec_fam_registered == OSI_ENABLE) {
|
||||||
genl_unregister_family(&nv_macsec_fam);
|
genl_unregister_family(&macsec_pdata->nv_macsec_fam);
|
||||||
is_nv_macsec_fam_registered = OSI_DISABLE;
|
macsec_pdata->is_nv_macsec_fam_registered = OSI_DISABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release platform resources */
|
/* Release platform resources */
|
||||||
@@ -1550,7 +1536,7 @@ int macsec_probe(struct ether_priv_data *pdata)
|
|||||||
tz_addr = (res->start - MACSEC_SIZE);
|
tz_addr = (res->start - MACSEC_SIZE);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* MACsec not enabled in DT, nothing more to do */
|
/* MACsec not supported per DT config, nothing more to do */
|
||||||
osi_core->macsec_base = NULL;
|
osi_core->macsec_base = NULL;
|
||||||
osi_core->tz_base = NULL;
|
osi_core->tz_base = NULL;
|
||||||
pdata->macsec_pdata = NULL;
|
pdata->macsec_pdata = NULL;
|
||||||
@@ -1577,6 +1563,17 @@ int macsec_probe(struct ether_priv_data *pdata)
|
|||||||
}
|
}
|
||||||
macsec_pdata->ether_pdata = pdata;
|
macsec_pdata->ether_pdata = pdata;
|
||||||
pdata->macsec_pdata = macsec_pdata;
|
pdata->macsec_pdata = macsec_pdata;
|
||||||
|
|
||||||
|
/* Read if macsec is enabled in DT */
|
||||||
|
ret = of_property_read_u32(np, "nvidia,macsec-enable",
|
||||||
|
&macsec_pdata->is_macsec_enabled_in_dt);
|
||||||
|
if ((ret != 0) || (macsec_pdata->is_macsec_enabled_in_dt == 0U)) {
|
||||||
|
dev_info(dev,
|
||||||
|
"macsec param in DT is missing or disabled\n");
|
||||||
|
ret = 1;
|
||||||
|
goto init_err;
|
||||||
|
}
|
||||||
|
|
||||||
mutex_init(&pdata->macsec_pdata->lock);
|
mutex_init(&pdata->macsec_pdata->lock);
|
||||||
|
|
||||||
/* Read MAC instance id and used in TZ api's */
|
/* Read MAC instance id and used in TZ api's */
|
||||||
@@ -1613,15 +1610,31 @@ int macsec_probe(struct ether_priv_data *pdata)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Register macsec generic netlink ops */
|
/* Register macsec generic netlink ops */
|
||||||
if (is_nv_macsec_fam_registered == OSI_DISABLE) {
|
macsec_pdata->nv_macsec_fam.hdrsize = 0;
|
||||||
ret = genl_register_family(&nv_macsec_fam);
|
macsec_pdata->nv_macsec_fam.version = NV_MACSEC_GENL_VERSION;
|
||||||
|
macsec_pdata->nv_macsec_fam.maxattr = NV_MACSEC_ATTR_MAX;
|
||||||
|
macsec_pdata->nv_macsec_fam.module = THIS_MODULE;
|
||||||
|
macsec_pdata->nv_macsec_fam.ops = nv_macsec_genl_ops;
|
||||||
|
macsec_pdata->nv_macsec_fam.n_ops = ARRAY_SIZE(nv_macsec_genl_ops);
|
||||||
|
if (macsec_pdata->is_nv_macsec_fam_registered == OSI_DISABLE) {
|
||||||
|
if (strlen(netdev_name(pdata->ndev)) >= GENL_NAMSIZ) {
|
||||||
|
dev_err(dev, "Intf name %s of len %lu exceed nl_family name size\n",
|
||||||
|
netdev_name(pdata->ndev),
|
||||||
|
strlen(netdev_name(pdata->ndev)));
|
||||||
|
ret = -1;
|
||||||
|
goto genl_err;
|
||||||
|
} else {
|
||||||
|
strncpy(macsec_pdata->nv_macsec_fam.name,
|
||||||
|
netdev_name(pdata->ndev), GENL_NAMSIZ - 1);
|
||||||
|
}
|
||||||
|
ret = genl_register_family(&macsec_pdata->nv_macsec_fam);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "Failed to register GENL ops %d\n",
|
dev_err(dev, "Failed to register GENL ops %d\n",
|
||||||
ret);
|
ret);
|
||||||
goto genl_err;
|
goto genl_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
is_nv_macsec_fam_registered = OSI_ENABLE;
|
macsec_pdata->is_nv_macsec_fam_registered = OSI_ENABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINT_EXIT();
|
PRINT_EXIT();
|
||||||
@@ -1689,7 +1702,7 @@ static int macsec_tz_kt_config(struct ether_priv_data *pdata,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg_head = genlmsg_put_reply(msg, info, &nv_macsec_fam, 0, cmd);
|
msg_head = genlmsg_put_reply(msg, info, &macsec_pdata->nv_macsec_fam, 0, cmd);
|
||||||
if (msg_head == NULL) {
|
if (msg_head == NULL) {
|
||||||
dev_err(dev, "unable to get replyhead\n");
|
dev_err(dev, "unable to get replyhead\n");
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
@@ -1815,7 +1828,7 @@ static int macsec_get_tx_next_pn(struct sk_buff *skb, struct genl_info *info)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg_head = genlmsg_put_reply(msg, info, &nv_macsec_fam, 0, cmd);
|
msg_head = genlmsg_put_reply(msg, info, &macsec_pdata->nv_macsec_fam, 0, cmd);
|
||||||
if (!msg_head) {
|
if (!msg_head) {
|
||||||
dev_err(dev, "unable to get replyhead\n");
|
dev_err(dev, "unable to get replyhead\n");
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
* Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -44,8 +44,6 @@
|
|||||||
*/
|
*/
|
||||||
#define MACSEC_IRQ_NAME_SZ 32
|
#define MACSEC_IRQ_NAME_SZ 32
|
||||||
|
|
||||||
/* TODO - include name of driver interface as well */
|
|
||||||
#define NV_MACSEC_GENL_NAME "nv_macsec"
|
|
||||||
#define NV_MACSEC_GENL_VERSION 1
|
#define NV_MACSEC_GENL_VERSION 1
|
||||||
|
|
||||||
#ifdef MACSEC_KEY_PROGRAM
|
#ifdef MACSEC_KEY_PROGRAM
|
||||||
@@ -221,6 +219,12 @@ struct macsec_priv_data {
|
|||||||
struct mutex lock;
|
struct mutex lock;
|
||||||
/** macsec hw instance id */
|
/** macsec hw instance id */
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
|
/** Macsec enable flag in DT */
|
||||||
|
unsigned int is_macsec_enabled_in_dt;
|
||||||
|
/** Context family name */
|
||||||
|
struct genl_family nv_macsec_fam;
|
||||||
|
/** Flag to check if nv macsec nl registered */
|
||||||
|
unsigned int is_nv_macsec_fam_registered;
|
||||||
};
|
};
|
||||||
|
|
||||||
int macsec_probe(struct ether_priv_data *pdata);
|
int macsec_probe(struct ether_priv_data *pdata);
|
||||||
|
|||||||
Reference in New Issue
Block a user