mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-23 09:42:19 +03:00
nvethernet: address review comments
- Remove debug code under TEST macro - Remove macsec CLK/RST hard code WAR's - Update macsec OSI macro's as per latest OSI_ prefix Bug 3264523 Change-Id: I8674e953e0faf49125e2326bdeb4b5bdc323a26c Signed-off-by: Mahesh Patil <maheshp@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2548474 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
f972af3192
commit
b02ba38d38
@@ -5672,11 +5672,6 @@ static int ether_probe(struct platform_device *pdev)
|
|||||||
struct net_device *ndev;
|
struct net_device *ndev;
|
||||||
int ret = 0, i;
|
int ret = 0, i;
|
||||||
|
|
||||||
#ifdef TEST
|
|
||||||
macsec_genl_register();
|
|
||||||
return 0;
|
|
||||||
#endif /* TEST */
|
|
||||||
|
|
||||||
ether_get_num_dma_chan_mtl_q(pdev, &num_dma_chans,
|
ether_get_num_dma_chan_mtl_q(pdev, &num_dma_chans,
|
||||||
&mac, &num_mtl_queues);
|
&mac, &num_mtl_queues);
|
||||||
|
|
||||||
@@ -5827,9 +5822,11 @@ static int ether_probe(struct platform_device *pdev)
|
|||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&pdev->dev, "failed to setup macsec\n");
|
dev_err(&pdev->dev, "failed to setup macsec\n");
|
||||||
goto err_macsec;
|
goto err_macsec;
|
||||||
|
} else if (ret == 1) {
|
||||||
|
/* Nothing to do, macsec is not supported */
|
||||||
|
dev_info(&pdev->dev, "Macsec not supported\n");
|
||||||
} else {
|
} else {
|
||||||
; //Nothing to do, macsec is not supported
|
dev_info(&pdev->dev, "Macsec not enabled\n");
|
||||||
dev_info(&pdev->dev, "Macsec not enabled - ignore\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MACSEC
|
#ifdef DEBUG_MACSEC
|
||||||
@@ -5926,10 +5923,6 @@ static int ether_remove(struct platform_device *pdev)
|
|||||||
struct ether_priv_data *pdata = netdev_priv(ndev);
|
struct ether_priv_data *pdata = netdev_priv(ndev);
|
||||||
|
|
||||||
#ifdef MACSEC_SUPPORT
|
#ifdef MACSEC_SUPPORT
|
||||||
#ifdef TEST
|
|
||||||
macsec_genl_unregister();
|
|
||||||
return 0;
|
|
||||||
#endif /* TEST */
|
|
||||||
macsec_remove(pdata);
|
macsec_remove(pdata);
|
||||||
#endif /* MACSEC_SUPPORT */
|
#endif /* MACSEC_SUPPORT */
|
||||||
|
|
||||||
|
|||||||
@@ -49,12 +49,8 @@ static irqreturn_t macsec_ns_isr(int irq, void *data)
|
|||||||
static int macsec_disable_car(struct macsec_priv_data *macsec_pdata)
|
static int macsec_disable_car(struct macsec_priv_data *macsec_pdata)
|
||||||
{
|
{
|
||||||
struct ether_priv_data *pdata = macsec_pdata->ether_pdata;
|
struct ether_priv_data *pdata = macsec_pdata->ether_pdata;
|
||||||
struct device *dev = pdata->dev;
|
|
||||||
void __iomem *addr = NULL;
|
|
||||||
unsigned int val = 0;
|
|
||||||
|
|
||||||
PRINT_ENTRY();
|
PRINT_ENTRY();
|
||||||
if (!pdata->osi_core->pre_si) {
|
|
||||||
if (pdata->osi_core->mac == OSI_MAC_HW_MGBE) {
|
if (pdata->osi_core->mac == OSI_MAC_HW_MGBE) {
|
||||||
if (!IS_ERR_OR_NULL(macsec_pdata->mgbe_clk)) {
|
if (!IS_ERR_OR_NULL(macsec_pdata->mgbe_clk)) {
|
||||||
clk_disable_unprepare(macsec_pdata->mgbe_clk);
|
clk_disable_unprepare(macsec_pdata->mgbe_clk);
|
||||||
@@ -72,25 +68,6 @@ static int macsec_disable_car(struct macsec_priv_data *macsec_pdata)
|
|||||||
if (macsec_pdata->ns_rst) {
|
if (macsec_pdata->ns_rst) {
|
||||||
reset_control_assert(macsec_pdata->ns_rst);
|
reset_control_assert(macsec_pdata->ns_rst);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
/* For Pre-sil only, reset the MACsec controller directly.
|
|
||||||
* Assert the reset Bit 8 in CLK_RST_CONTROLLER_RST_DEV_MGBE_0.
|
|
||||||
*/
|
|
||||||
addr = devm_ioremap(dev, 0x21460018, 0x4);
|
|
||||||
if (addr) {
|
|
||||||
val = readl(addr);
|
|
||||||
val |= BIT(8);
|
|
||||||
writel(val, addr);
|
|
||||||
devm_iounmap(dev, addr);
|
|
||||||
}
|
|
||||||
addr = devm_ioremap(dev, 0x21460080, 0x4);
|
|
||||||
if (addr) {
|
|
||||||
val = readl(addr);
|
|
||||||
val &= ~BIT(2);
|
|
||||||
writel(val, addr);
|
|
||||||
devm_iounmap(dev, addr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PRINT_EXIT();
|
PRINT_EXIT();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -100,12 +77,9 @@ static int macsec_enable_car(struct macsec_priv_data *macsec_pdata)
|
|||||||
{
|
{
|
||||||
struct ether_priv_data *pdata = macsec_pdata->ether_pdata;
|
struct ether_priv_data *pdata = macsec_pdata->ether_pdata;
|
||||||
struct device *dev = pdata->dev;
|
struct device *dev = pdata->dev;
|
||||||
void __iomem *addr = NULL;
|
|
||||||
unsigned int val = 0;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
PRINT_ENTRY();
|
PRINT_ENTRY();
|
||||||
if (!pdata->osi_core->pre_si) {
|
|
||||||
if (pdata->osi_core->mac == OSI_MAC_HW_MGBE) {
|
if (pdata->osi_core->mac == OSI_MAC_HW_MGBE) {
|
||||||
if (!IS_ERR_OR_NULL(macsec_pdata->mgbe_clk)) {
|
if (!IS_ERR_OR_NULL(macsec_pdata->mgbe_clk)) {
|
||||||
ret = clk_prepare_enable(macsec_pdata->mgbe_clk);
|
ret = clk_prepare_enable(macsec_pdata->mgbe_clk);
|
||||||
@@ -131,9 +105,7 @@ static int macsec_enable_car(struct macsec_priv_data *macsec_pdata)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* TODO:
|
|
||||||
* 1. Any delay needed in silicon for clocks to stabilize ?
|
|
||||||
*/
|
|
||||||
if (macsec_pdata->ns_rst) {
|
if (macsec_pdata->ns_rst) {
|
||||||
ret = reset_control_reset(macsec_pdata->ns_rst);
|
ret = reset_control_reset(macsec_pdata->ns_rst);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -141,32 +113,6 @@ static int macsec_enable_car(struct macsec_priv_data *macsec_pdata)
|
|||||||
goto err_ns_rst;
|
goto err_ns_rst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (pdata->osi_core->use_virtualization != OSI_ENABLE) {
|
|
||||||
/* For Pre-sil only, reset the MACsec controller directly.
|
|
||||||
* clk ungate first, followed by disabling reset
|
|
||||||
* Bit 8 in CLK_RST_CONTROLLER_RST_DEV_MGBE_0 register.
|
|
||||||
*/
|
|
||||||
addr = devm_ioremap(dev, 0x21460080, 0x4);
|
|
||||||
if (addr) {
|
|
||||||
val = readl(addr);
|
|
||||||
val |= BIT(2);
|
|
||||||
writel(val, addr);
|
|
||||||
devm_iounmap(dev, addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Followed by disabling reset - Bit 8 in
|
|
||||||
* CLK_RST_CONTROLLER_RST_DEV_MGBE_0 register.
|
|
||||||
*/
|
|
||||||
addr = devm_ioremap(dev, 0x21460018, 0x4);
|
|
||||||
if (addr) {
|
|
||||||
val = readl(addr);
|
|
||||||
val &= ~BIT(8);
|
|
||||||
writel(val, addr);
|
|
||||||
devm_iounmap(dev, addr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
@@ -257,7 +203,7 @@ int macsec_open(struct macsec_priv_data *macsec_pdata,
|
|||||||
|
|
||||||
#ifndef MACSEC_KEY_PROGRAM
|
#ifndef MACSEC_KEY_PROGRAM
|
||||||
/* Clear KT entries */
|
/* Clear KT entries */
|
||||||
ret = macsec_tz_kt_config(pdata, MACSEC_CMD_TZ_KT_RESET, OSI_NULL,
|
ret = macsec_tz_kt_config(pdata, OSI_MACSEC_CMD_TZ_KT_RESET, OSI_NULL,
|
||||||
genl_info);
|
genl_info);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "TZ key config failed %d\n", ret);
|
dev_err(dev, "TZ key config failed %d\n", ret);
|
||||||
@@ -265,7 +211,7 @@ int macsec_open(struct macsec_priv_data *macsec_pdata,
|
|||||||
}
|
}
|
||||||
#endif /* !MACSEC_KEY_PROGRAM */
|
#endif /* !MACSEC_KEY_PROGRAM */
|
||||||
|
|
||||||
/* 4. Enable the macsec controller */
|
/* Enable the macsec controller */
|
||||||
ret = osi_macsec_en(pdata->osi_core,
|
ret = osi_macsec_en(pdata->osi_core,
|
||||||
(OSI_MACSEC_TX_EN | OSI_MACSEC_RX_EN));
|
(OSI_MACSEC_TX_EN | OSI_MACSEC_RX_EN));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -294,10 +240,8 @@ static int macsec_get_platform_res(struct macsec_priv_data *macsec_pdata)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
PRINT_ENTRY();
|
PRINT_ENTRY();
|
||||||
if (!pdata->osi_core->pre_si) {
|
|
||||||
/* 1. Get resets */
|
/* 1. Get resets */
|
||||||
macsec_pdata->ns_rst = devm_reset_control_get(dev,
|
macsec_pdata->ns_rst = devm_reset_control_get(dev, "macsec_ns_rst");
|
||||||
"macsec_ns_rst");
|
|
||||||
if (IS_ERR_OR_NULL(macsec_pdata->ns_rst)) {
|
if (IS_ERR_OR_NULL(macsec_pdata->ns_rst)) {
|
||||||
dev_err(dev, "Failed to get macsec_ns_rst\n");
|
dev_err(dev, "Failed to get macsec_ns_rst\n");
|
||||||
ret = PTR_ERR(macsec_pdata->ns_rst);
|
ret = PTR_ERR(macsec_pdata->ns_rst);
|
||||||
@@ -306,16 +250,14 @@ static int macsec_get_platform_res(struct macsec_priv_data *macsec_pdata)
|
|||||||
|
|
||||||
/* 2. Get clks */
|
/* 2. Get clks */
|
||||||
if (pdata->osi_core->mac == OSI_MAC_HW_MGBE) {
|
if (pdata->osi_core->mac == OSI_MAC_HW_MGBE) {
|
||||||
macsec_pdata->mgbe_clk = devm_clk_get(dev,
|
macsec_pdata->mgbe_clk = devm_clk_get(dev, "mgbe_macsec");
|
||||||
"mgbe_macsec");
|
|
||||||
if (IS_ERR(macsec_pdata->mgbe_clk)) {
|
if (IS_ERR(macsec_pdata->mgbe_clk)) {
|
||||||
dev_err(dev, "failed to get macsec clk\n");
|
dev_err(dev, "failed to get macsec clk\n");
|
||||||
ret = PTR_ERR(macsec_pdata->mgbe_clk);
|
ret = PTR_ERR(macsec_pdata->mgbe_clk);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
macsec_pdata->eqos_tx_clk = devm_clk_get(dev,
|
macsec_pdata->eqos_tx_clk = devm_clk_get(dev, "eqos_macsec_tx");
|
||||||
"eqos_macsec_tx");
|
|
||||||
if (IS_ERR(macsec_pdata->eqos_tx_clk)) {
|
if (IS_ERR(macsec_pdata->eqos_tx_clk)) {
|
||||||
dev_err(dev, "failed to get eqos_tx clk\n");
|
dev_err(dev, "failed to get eqos_tx clk\n");
|
||||||
ret = PTR_ERR(macsec_pdata->eqos_tx_clk);
|
ret = PTR_ERR(macsec_pdata->eqos_tx_clk);
|
||||||
@@ -329,7 +271,6 @@ static int macsec_get_platform_res(struct macsec_priv_data *macsec_pdata)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* 3. Get irqs */
|
/* 3. Get irqs */
|
||||||
macsec_pdata->ns_irq = platform_get_irq_byname(pdev, "macsec-ns-irq");
|
macsec_pdata->ns_irq = platform_get_irq_byname(pdev, "macsec-ns-irq");
|
||||||
@@ -346,7 +287,6 @@ static int macsec_get_platform_res(struct macsec_priv_data *macsec_pdata)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sucess */
|
|
||||||
exit:
|
exit:
|
||||||
PRINT_EXIT();
|
PRINT_EXIT();
|
||||||
return ret;
|
return ret;
|
||||||
@@ -358,7 +298,6 @@ static void macsec_release_platform_res(struct macsec_priv_data *macsec_pdata)
|
|||||||
struct device *dev = pdata->dev;
|
struct device *dev = pdata->dev;
|
||||||
|
|
||||||
PRINT_ENTRY();
|
PRINT_ENTRY();
|
||||||
if (!pdata->osi_core->pre_si) {
|
|
||||||
if (pdata->osi_core->mac == OSI_MAC_HW_MGBE) {
|
if (pdata->osi_core->mac == OSI_MAC_HW_MGBE) {
|
||||||
if (!IS_ERR_OR_NULL(macsec_pdata->mgbe_clk)) {
|
if (!IS_ERR_OR_NULL(macsec_pdata->mgbe_clk)) {
|
||||||
devm_clk_put(dev, macsec_pdata->mgbe_clk);
|
devm_clk_put(dev, macsec_pdata->mgbe_clk);
|
||||||
@@ -372,7 +311,7 @@ static void macsec_release_platform_res(struct macsec_priv_data *macsec_pdata)
|
|||||||
devm_clk_put(dev, macsec_pdata->eqos_rx_clk);
|
devm_clk_put(dev, macsec_pdata->eqos_rx_clk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
PRINT_EXIT();
|
PRINT_EXIT();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,7 +349,7 @@ static struct macsec_supplicant_data *macsec_get_supplicant(
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* check for already exist instance */
|
/* check for already exist instance */
|
||||||
for (i = 0; i < MAX_NUM_SC; i++) {
|
for (i = 0; i < OSI_MAX_NUM_SC; i++) {
|
||||||
if (supplicant[i].snd_portid == portid &&
|
if (supplicant[i].snd_portid == portid &&
|
||||||
supplicant[i].in_use == OSI_ENABLE) {
|
supplicant[i].in_use == OSI_ENABLE) {
|
||||||
return &supplicant[i];
|
return &supplicant[i];
|
||||||
@@ -426,7 +365,7 @@ static int update_prot_frame(
|
|||||||
int enable = OSI_NONE;
|
int enable = OSI_NONE;
|
||||||
|
|
||||||
/* check any supplicant instance set */
|
/* check any supplicant instance set */
|
||||||
for (i = 0; i < MAX_NUM_SC; i++) {
|
for (i = 0; i < OSI_MAX_NUM_SC; i++) {
|
||||||
if (supplicant[i].protect_frames == OSI_ENABLE) {
|
if (supplicant[i].protect_frames == OSI_ENABLE) {
|
||||||
enable = OSI_ENABLE;
|
enable = OSI_ENABLE;
|
||||||
break;
|
break;
|
||||||
@@ -442,7 +381,7 @@ static int update_set_controlled_port(
|
|||||||
int enable = OSI_NONE;
|
int enable = OSI_NONE;
|
||||||
|
|
||||||
/* check any supplicant instance set */
|
/* check any supplicant instance set */
|
||||||
for (i = 0; i < MAX_NUM_SC; i++) {
|
for (i = 0; i < OSI_MAX_NUM_SC; i++) {
|
||||||
if (supplicant[i].enabled == OSI_ENABLE) {
|
if (supplicant[i].enabled == OSI_ENABLE) {
|
||||||
enable = OSI_ENABLE;
|
enable = OSI_ENABLE;
|
||||||
break;
|
break;
|
||||||
@@ -469,7 +408,7 @@ static int macsec_set_prot_frames(struct sk_buff *skb, struct genl_info *info)
|
|||||||
|
|
||||||
macsec_pdata = genl_to_macsec_pdata(info);
|
macsec_pdata = genl_to_macsec_pdata(info);
|
||||||
if (!macsec_pdata) {
|
if (!macsec_pdata) {
|
||||||
ret = -EOPNOTSUPP;
|
ret = -EPROTO;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
pdata = macsec_pdata->ether_pdata;
|
pdata = macsec_pdata->ether_pdata;
|
||||||
@@ -483,7 +422,7 @@ static int macsec_set_prot_frames(struct sk_buff *skb, struct genl_info *info)
|
|||||||
mutex_lock(&macsec_pdata->lock);
|
mutex_lock(&macsec_pdata->lock);
|
||||||
supplicant = macsec_get_supplicant(macsec_pdata, info->snd_portid);
|
supplicant = macsec_get_supplicant(macsec_pdata, info->snd_portid);
|
||||||
if (!supplicant) {
|
if (!supplicant) {
|
||||||
ret = -EOPNOTSUPP;
|
ret = -EPROTO;
|
||||||
dev_err(pdata->dev, "%s: failed to get supplicant data",
|
dev_err(pdata->dev, "%s: failed to get supplicant data",
|
||||||
__func__);
|
__func__);
|
||||||
goto err_unlock;
|
goto err_unlock;
|
||||||
@@ -502,7 +441,62 @@ exit:
|
|||||||
|
|
||||||
static int macsec_set_cipher(struct sk_buff *skb, struct genl_info *info)
|
static int macsec_set_cipher(struct sk_buff *skb, struct genl_info *info)
|
||||||
{
|
{
|
||||||
return -1;
|
struct nlattr **attrs = info->attrs;
|
||||||
|
struct macsec_priv_data *macsec_pdata;
|
||||||
|
struct macsec_supplicant_data *supplicant;
|
||||||
|
struct ether_priv_data *pdata = NULL;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
PRINT_ENTRY();
|
||||||
|
if (!attrs[NV_MACSEC_ATTR_IFNAME] ||
|
||||||
|
!attrs[NV_MACSEC_ATTR_CIPHER_SUITE]) {
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
macsec_pdata = genl_to_macsec_pdata(info);
|
||||||
|
if (!macsec_pdata) {
|
||||||
|
ret = -EPROTO;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
pdata = macsec_pdata->ether_pdata;
|
||||||
|
|
||||||
|
if (!netif_running(pdata->ndev)) {
|
||||||
|
ret = -ENETDOWN;
|
||||||
|
dev_err(pdata->dev, "%s: MAC interface down!!\n", __func__);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
mutex_lock(&macsec_pdata->lock);
|
||||||
|
supplicant = macsec_get_supplicant(macsec_pdata, info->snd_portid);
|
||||||
|
if (!supplicant) {
|
||||||
|
ret = -EPROTO;
|
||||||
|
dev_err(pdata->dev, "%s: failed to get supplicant data\n",
|
||||||
|
__func__);
|
||||||
|
goto err_unlock;
|
||||||
|
}
|
||||||
|
supplicant->cipher = nla_get_u32(attrs[NV_MACSEC_ATTR_CIPHER_SUITE]);
|
||||||
|
|
||||||
|
if (supplicant->cipher != OSI_MACSEC_CIPHER_AES128 &&
|
||||||
|
supplicant->cipher != OSI_MACSEC_CIPHER_AES256) {
|
||||||
|
ret = -EPROTO;
|
||||||
|
dev_err(pdata->dev, "%s: Invalid cipher suit %d\n",
|
||||||
|
__func__, supplicant->cipher);
|
||||||
|
goto err_unlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (macsec_pdata->cipher != supplicant->cipher) {
|
||||||
|
ret = osi_macsec_cipher_config(pdata->osi_core,
|
||||||
|
supplicant->cipher);
|
||||||
|
if (ret < 0) {
|
||||||
|
dev_err(pdata->dev, "Failed to set macsec cipher\n");
|
||||||
|
}
|
||||||
|
macsec_pdata->cipher = supplicant->cipher;
|
||||||
|
}
|
||||||
|
err_unlock:
|
||||||
|
mutex_unlock(&macsec_pdata->lock);
|
||||||
|
exit:
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int macsec_set_controlled_port(struct sk_buff *skb,
|
static int macsec_set_controlled_port(struct sk_buff *skb,
|
||||||
@@ -525,7 +519,7 @@ static int macsec_set_controlled_port(struct sk_buff *skb,
|
|||||||
|
|
||||||
macsec_pdata = genl_to_macsec_pdata(info);
|
macsec_pdata = genl_to_macsec_pdata(info);
|
||||||
if (!macsec_pdata) {
|
if (!macsec_pdata) {
|
||||||
ret = -EOPNOTSUPP;
|
ret = -EPROTO;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
pdata = macsec_pdata->ether_pdata;
|
pdata = macsec_pdata->ether_pdata;
|
||||||
@@ -539,7 +533,7 @@ static int macsec_set_controlled_port(struct sk_buff *skb,
|
|||||||
mutex_lock(&macsec_pdata->lock);
|
mutex_lock(&macsec_pdata->lock);
|
||||||
supplicant = macsec_get_supplicant(macsec_pdata, info->snd_portid);
|
supplicant = macsec_get_supplicant(macsec_pdata, info->snd_portid);
|
||||||
if (!supplicant) {
|
if (!supplicant) {
|
||||||
ret = -EOPNOTSUPP;
|
ret = -EPROTO;
|
||||||
dev_err(pdata->dev, "%s: failed to get supplicant data",
|
dev_err(pdata->dev, "%s: failed to get supplicant data",
|
||||||
__func__);
|
__func__);
|
||||||
goto err_unlock;
|
goto err_unlock;
|
||||||
@@ -557,7 +551,7 @@ static int macsec_set_controlled_port(struct sk_buff *skb,
|
|||||||
ret = osi_macsec_en(macsec_pdata->ether_pdata->osi_core,
|
ret = osi_macsec_en(macsec_pdata->ether_pdata->osi_core,
|
||||||
macsec_en);
|
macsec_en);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ret = -EOPNOTSUPP;
|
ret = -EPROTO;
|
||||||
goto err_unlock;
|
goto err_unlock;
|
||||||
}
|
}
|
||||||
macsec_pdata->enabled = macsec_en;
|
macsec_pdata->enabled = macsec_en;
|
||||||
@@ -611,7 +605,7 @@ static int macsec_dis_rx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
struct device *dev = NULL;
|
struct device *dev = NULL;
|
||||||
#ifndef MACSEC_KEY_PROGRAM
|
#ifndef MACSEC_KEY_PROGRAM
|
||||||
struct osi_macsec_kt_config kt_config = {0};
|
struct osi_macsec_kt_config kt_config = {0};
|
||||||
struct macsec_table_config *table_config;
|
struct osi_macsec_table_config *table_config;
|
||||||
#endif /* !MACSEC_KEY_PROGRAM */
|
#endif /* !MACSEC_KEY_PROGRAM */
|
||||||
|
|
||||||
PRINT_ENTRY();
|
PRINT_ENTRY();
|
||||||
@@ -620,10 +614,8 @@ static int macsec_dis_rx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
if (macsec_pdata) {
|
if (macsec_pdata) {
|
||||||
pdata = macsec_pdata->ether_pdata;
|
pdata = macsec_pdata->ether_pdata;
|
||||||
} else {
|
} else {
|
||||||
#ifndef TEST
|
ret = -EPROTO;
|
||||||
ret = -EOPNOTSUPP;
|
|
||||||
goto exit;
|
goto exit;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
dev = pdata->dev;
|
dev = pdata->dev;
|
||||||
|
|
||||||
@@ -654,10 +646,9 @@ static int macsec_dis_rx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
}
|
}
|
||||||
pr_err("");
|
pr_err("");
|
||||||
|
|
||||||
#ifndef TEST
|
|
||||||
mutex_lock(&macsec_pdata->lock);
|
mutex_lock(&macsec_pdata->lock);
|
||||||
ret = osi_macsec_config(pdata->osi_core, &rx_sa, OSI_DISABLE,
|
ret = osi_macsec_config(pdata->osi_core, &rx_sa, OSI_DISABLE,
|
||||||
CTLR_SEL_RX, &kt_idx);
|
OSI_CTLR_SEL_RX, &kt_idx);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "%s: failed to disable Rx SA", __func__);
|
dev_err(dev, "%s: failed to disable Rx SA", __func__);
|
||||||
mutex_unlock(&macsec_pdata->lock);
|
mutex_unlock(&macsec_pdata->lock);
|
||||||
@@ -666,11 +657,11 @@ static int macsec_dis_rx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
mutex_unlock(&macsec_pdata->lock);
|
mutex_unlock(&macsec_pdata->lock);
|
||||||
#ifndef MACSEC_KEY_PROGRAM
|
#ifndef MACSEC_KEY_PROGRAM
|
||||||
table_config = &kt_config.table_config;
|
table_config = &kt_config.table_config;
|
||||||
table_config->ctlr_sel = CTLR_SEL_RX;
|
table_config->ctlr_sel = OSI_CTLR_SEL_RX;
|
||||||
table_config->rw = LUT_WRITE;
|
table_config->rw = OSI_LUT_WRITE;
|
||||||
table_config->index = kt_idx;
|
table_config->index = kt_idx;
|
||||||
|
|
||||||
ret = macsec_tz_kt_config(pdata, MACSEC_CMD_TZ_CONFIG, &kt_config,
|
ret = macsec_tz_kt_config(pdata, OSI_MACSEC_CMD_TZ_CONFIG, &kt_config,
|
||||||
info);
|
info);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "%s: failed to program SAK through TZ %d",
|
dev_err(dev, "%s: failed to program SAK through TZ %d",
|
||||||
@@ -678,7 +669,6 @@ static int macsec_dis_rx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
#endif /* !MACSEC_KEY_PROGRAM */
|
#endif /* !MACSEC_KEY_PROGRAM */
|
||||||
#endif
|
|
||||||
exit:
|
exit:
|
||||||
PRINT_EXIT();
|
PRINT_EXIT();
|
||||||
return ret;
|
return ret;
|
||||||
@@ -696,7 +686,7 @@ static int macsec_en_rx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
struct device *dev = NULL;
|
struct device *dev = NULL;
|
||||||
#ifndef MACSEC_KEY_PROGRAM
|
#ifndef MACSEC_KEY_PROGRAM
|
||||||
struct osi_macsec_kt_config kt_config = {0};
|
struct osi_macsec_kt_config kt_config = {0};
|
||||||
struct macsec_table_config *table_config;
|
struct osi_macsec_table_config *table_config;
|
||||||
#endif /* !MACSEC_KEY_PROGRAM */
|
#endif /* !MACSEC_KEY_PROGRAM */
|
||||||
|
|
||||||
PRINT_ENTRY();
|
PRINT_ENTRY();
|
||||||
@@ -704,10 +694,8 @@ static int macsec_en_rx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
if (macsec_pdata) {
|
if (macsec_pdata) {
|
||||||
pdata = macsec_pdata->ether_pdata;
|
pdata = macsec_pdata->ether_pdata;
|
||||||
} else {
|
} else {
|
||||||
#ifndef TEST
|
ret = -EPROTO;
|
||||||
ret = -EOPNOTSUPP;
|
|
||||||
goto exit;
|
goto exit;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
dev = pdata->dev;
|
dev = pdata->dev;
|
||||||
|
|
||||||
@@ -724,24 +712,25 @@ static int macsec_en_rx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rx_sa.pn_window = macsec_pdata->pn_window;
|
||||||
pr_err("%s:\n"
|
pr_err("%s:\n"
|
||||||
"\tsci: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n"
|
"\tsci: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n"
|
||||||
"\tan: %u\n"
|
"\tan: %u\n"
|
||||||
"\tpn: %u",
|
"\tpn: %u\n"
|
||||||
|
"\twindow: %u",
|
||||||
__func__,
|
__func__,
|
||||||
rx_sa.sci[0], rx_sa.sci[1], rx_sa.sci[2], rx_sa.sci[3],
|
rx_sa.sci[0], rx_sa.sci[1], rx_sa.sci[2], rx_sa.sci[3],
|
||||||
rx_sa.sci[4], rx_sa.sci[5], rx_sa.sci[6], rx_sa.sci[7],
|
rx_sa.sci[4], rx_sa.sci[5], rx_sa.sci[6], rx_sa.sci[7],
|
||||||
rx_sa.curr_an, rx_sa.next_pn);
|
rx_sa.curr_an, rx_sa.next_pn, rx_sa.pn_window);
|
||||||
pr_err("\tkey: ");
|
pr_err("\tkey: ");
|
||||||
for (i = 0; i < 16; i++) {
|
for (i = 0; i < 16; i++) {
|
||||||
pr_cont(" %02x", rx_sa.sak[i]);
|
pr_cont(" %02x", rx_sa.sak[i]);
|
||||||
}
|
}
|
||||||
pr_err("");
|
pr_err("");
|
||||||
|
|
||||||
#ifndef TEST
|
|
||||||
mutex_lock(&macsec_pdata->lock);
|
mutex_lock(&macsec_pdata->lock);
|
||||||
ret = osi_macsec_config(pdata->osi_core, &rx_sa, OSI_ENABLE,
|
ret = osi_macsec_config(pdata->osi_core, &rx_sa, OSI_ENABLE,
|
||||||
CTLR_SEL_RX, &kt_idx);
|
OSI_CTLR_SEL_RX, &kt_idx);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "%s: failed to enable Rx SA", __func__);
|
dev_err(dev, "%s: failed to enable Rx SA", __func__);
|
||||||
mutex_unlock(&macsec_pdata->lock);
|
mutex_unlock(&macsec_pdata->lock);
|
||||||
@@ -751,16 +740,16 @@ static int macsec_en_rx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
|
|
||||||
#ifndef MACSEC_KEY_PROGRAM
|
#ifndef MACSEC_KEY_PROGRAM
|
||||||
table_config = &kt_config.table_config;
|
table_config = &kt_config.table_config;
|
||||||
table_config->ctlr_sel = CTLR_SEL_RX;
|
table_config->ctlr_sel = OSI_CTLR_SEL_RX;
|
||||||
table_config->rw = LUT_WRITE;
|
table_config->rw = OSI_LUT_WRITE;
|
||||||
table_config->index = kt_idx;
|
table_config->index = kt_idx;
|
||||||
kt_config.flags |= LUT_FLAGS_ENTRY_VALID;
|
kt_config.flags |= OSI_LUT_FLAGS_ENTRY_VALID;
|
||||||
|
|
||||||
for (i = 0; i < KEY_LEN_128; i++) {
|
for (i = 0; i < OSI_KEY_LEN_128; i++) {
|
||||||
kt_config.entry.sak[i] = rx_sa.sak[i];
|
kt_config.entry.sak[i] = rx_sa.sak[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = macsec_tz_kt_config(pdata, MACSEC_CMD_TZ_CONFIG, &kt_config,
|
ret = macsec_tz_kt_config(pdata, OSI_MACSEC_CMD_TZ_CONFIG, &kt_config,
|
||||||
info);
|
info);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "%s: failed to program SAK through TZ %d",
|
dev_err(dev, "%s: failed to program SAK through TZ %d",
|
||||||
@@ -768,7 +757,6 @@ static int macsec_en_rx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
#endif /* !MACSEC_KEY_PROGRAM */
|
#endif /* !MACSEC_KEY_PROGRAM */
|
||||||
#endif
|
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
PRINT_EXIT();
|
PRINT_EXIT();
|
||||||
@@ -787,7 +775,7 @@ static int macsec_dis_tx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
struct device *dev = NULL;
|
struct device *dev = NULL;
|
||||||
#ifndef MACSEC_KEY_PROGRAM
|
#ifndef MACSEC_KEY_PROGRAM
|
||||||
struct osi_macsec_kt_config kt_config = {0};
|
struct osi_macsec_kt_config kt_config = {0};
|
||||||
struct macsec_table_config *table_config;
|
struct osi_macsec_table_config *table_config;
|
||||||
#endif /* !MACSEC_KEY_PROGRAM */
|
#endif /* !MACSEC_KEY_PROGRAM */
|
||||||
|
|
||||||
PRINT_ENTRY();
|
PRINT_ENTRY();
|
||||||
@@ -795,10 +783,8 @@ static int macsec_dis_tx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
if (macsec_pdata) {
|
if (macsec_pdata) {
|
||||||
pdata = macsec_pdata->ether_pdata;
|
pdata = macsec_pdata->ether_pdata;
|
||||||
} else {
|
} else {
|
||||||
#ifndef TEST
|
ret = -EPROTO;
|
||||||
ret = -EOPNOTSUPP;
|
|
||||||
goto exit;
|
goto exit;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
dev = pdata->dev;
|
dev = pdata->dev;
|
||||||
|
|
||||||
@@ -829,10 +815,9 @@ static int macsec_dis_tx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
}
|
}
|
||||||
pr_err("");
|
pr_err("");
|
||||||
|
|
||||||
#ifndef TEST
|
|
||||||
mutex_lock(&macsec_pdata->lock);
|
mutex_lock(&macsec_pdata->lock);
|
||||||
ret = osi_macsec_config(pdata->osi_core, &tx_sa, OSI_DISABLE,
|
ret = osi_macsec_config(pdata->osi_core, &tx_sa, OSI_DISABLE,
|
||||||
CTLR_SEL_TX, &kt_idx);
|
OSI_CTLR_SEL_TX, &kt_idx);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "%s: failed to disable Tx SA", __func__);
|
dev_err(dev, "%s: failed to disable Tx SA", __func__);
|
||||||
mutex_unlock(&macsec_pdata->lock);
|
mutex_unlock(&macsec_pdata->lock);
|
||||||
@@ -842,11 +827,11 @@ static int macsec_dis_tx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
|
|
||||||
#ifndef MACSEC_KEY_PROGRAM
|
#ifndef MACSEC_KEY_PROGRAM
|
||||||
table_config = &kt_config.table_config;
|
table_config = &kt_config.table_config;
|
||||||
table_config->ctlr_sel = CTLR_SEL_TX;
|
table_config->ctlr_sel = OSI_CTLR_SEL_TX;
|
||||||
table_config->rw = LUT_WRITE;
|
table_config->rw = OSI_LUT_WRITE;
|
||||||
table_config->index = kt_idx;
|
table_config->index = kt_idx;
|
||||||
|
|
||||||
ret = macsec_tz_kt_config(pdata, MACSEC_CMD_TZ_CONFIG, &kt_config,
|
ret = macsec_tz_kt_config(pdata, OSI_MACSEC_CMD_TZ_CONFIG, &kt_config,
|
||||||
info);
|
info);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "%s: failed to program SAK through TZ %d",
|
dev_err(dev, "%s: failed to program SAK through TZ %d",
|
||||||
@@ -854,7 +839,6 @@ static int macsec_dis_tx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
#endif /* !MACSEC_KEY_PROGRAM */
|
#endif /* !MACSEC_KEY_PROGRAM */
|
||||||
#endif
|
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
PRINT_EXIT();
|
PRINT_EXIT();
|
||||||
@@ -873,7 +857,7 @@ static int macsec_en_tx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
struct device *dev = NULL;
|
struct device *dev = NULL;
|
||||||
#ifndef MACSEC_KEY_PROGRAM
|
#ifndef MACSEC_KEY_PROGRAM
|
||||||
struct osi_macsec_kt_config kt_config = {0};
|
struct osi_macsec_kt_config kt_config = {0};
|
||||||
struct macsec_table_config *table_config;
|
struct osi_macsec_table_config *table_config;
|
||||||
#endif /* !MACSEC_KEY_PROGRAM */
|
#endif /* !MACSEC_KEY_PROGRAM */
|
||||||
|
|
||||||
PRINT_ENTRY();
|
PRINT_ENTRY();
|
||||||
@@ -881,10 +865,8 @@ static int macsec_en_tx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
if (macsec_pdata) {
|
if (macsec_pdata) {
|
||||||
pdata = macsec_pdata->ether_pdata;
|
pdata = macsec_pdata->ether_pdata;
|
||||||
} else {
|
} else {
|
||||||
#ifndef TEST
|
ret = -EPROTO;
|
||||||
ret = -EOPNOTSUPP;
|
|
||||||
goto exit;
|
goto exit;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
dev = pdata->dev;
|
dev = pdata->dev;
|
||||||
|
|
||||||
@@ -901,6 +883,7 @@ static int macsec_en_tx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tx_sa.pn_window = macsec_pdata->pn_window;
|
||||||
pr_err("%s:\n"
|
pr_err("%s:\n"
|
||||||
"\tsci: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n"
|
"\tsci: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n"
|
||||||
"\tan: %u\n"
|
"\tan: %u\n"
|
||||||
@@ -915,10 +898,9 @@ static int macsec_en_tx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
}
|
}
|
||||||
pr_err("");
|
pr_err("");
|
||||||
|
|
||||||
#ifndef TEST
|
|
||||||
mutex_lock(&macsec_pdata->lock);
|
mutex_lock(&macsec_pdata->lock);
|
||||||
ret = osi_macsec_config(pdata->osi_core, &tx_sa, OSI_ENABLE,
|
ret = osi_macsec_config(pdata->osi_core, &tx_sa, OSI_ENABLE,
|
||||||
CTLR_SEL_TX, &kt_idx);
|
OSI_CTLR_SEL_TX, &kt_idx);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "%s: failed to enable Tx SA", __func__);
|
dev_err(dev, "%s: failed to enable Tx SA", __func__);
|
||||||
mutex_unlock(&macsec_pdata->lock);
|
mutex_unlock(&macsec_pdata->lock);
|
||||||
@@ -928,16 +910,16 @@ static int macsec_en_tx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
mutex_unlock(&macsec_pdata->lock);
|
mutex_unlock(&macsec_pdata->lock);
|
||||||
#ifndef MACSEC_KEY_PROGRAM
|
#ifndef MACSEC_KEY_PROGRAM
|
||||||
table_config = &kt_config.table_config;
|
table_config = &kt_config.table_config;
|
||||||
table_config->ctlr_sel = CTLR_SEL_TX;
|
table_config->ctlr_sel = OSI_CTLR_SEL_TX;
|
||||||
table_config->rw = LUT_WRITE;
|
table_config->rw = OSI_LUT_WRITE;
|
||||||
table_config->index = kt_idx;
|
table_config->index = kt_idx;
|
||||||
kt_config.flags |= LUT_FLAGS_ENTRY_VALID;
|
kt_config.flags |= OSI_LUT_FLAGS_ENTRY_VALID;
|
||||||
|
|
||||||
for (i = 0; i < KEY_LEN_128; i++) {
|
for (i = 0; i < OSI_KEY_LEN_128; i++) {
|
||||||
kt_config.entry.sak[i] = tx_sa.sak[i];
|
kt_config.entry.sak[i] = tx_sa.sak[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = macsec_tz_kt_config(pdata, MACSEC_CMD_TZ_CONFIG, &kt_config,
|
ret = macsec_tz_kt_config(pdata, OSI_MACSEC_CMD_TZ_CONFIG, &kt_config,
|
||||||
info);
|
info);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "%s: failed to program SAK through TZ %d",
|
dev_err(dev, "%s: failed to program SAK through TZ %d",
|
||||||
@@ -945,7 +927,6 @@ static int macsec_en_tx_sa(struct sk_buff *skb, struct genl_info *info)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
#endif /* !MACSEC_KEY_PROGRAM */
|
#endif /* !MACSEC_KEY_PROGRAM */
|
||||||
#endif
|
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
PRINT_EXIT();
|
PRINT_EXIT();
|
||||||
@@ -970,7 +951,7 @@ static int macsec_deinit(struct sk_buff *skb, struct genl_info *info)
|
|||||||
macsec_pdata = genl_to_macsec_pdata(info);
|
macsec_pdata = genl_to_macsec_pdata(info);
|
||||||
if (!macsec_pdata) {
|
if (!macsec_pdata) {
|
||||||
pr_err("%s: failed to get macsec_pdata", __func__);
|
pr_err("%s: failed to get macsec_pdata", __func__);
|
||||||
ret = -EOPNOTSUPP;
|
ret = -EPROTO;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
pdata = macsec_pdata->ether_pdata;
|
pdata = macsec_pdata->ether_pdata;
|
||||||
@@ -979,7 +960,7 @@ static int macsec_deinit(struct sk_buff *skb, struct genl_info *info)
|
|||||||
supplicant = macsec_get_supplicant(macsec_pdata, info->snd_portid);
|
supplicant = macsec_get_supplicant(macsec_pdata, info->snd_portid);
|
||||||
|
|
||||||
if (!supplicant) {
|
if (!supplicant) {
|
||||||
ret = -EOPNOTSUPP;
|
ret = -EPROTO;
|
||||||
mutex_unlock(&macsec_pdata->lock);
|
mutex_unlock(&macsec_pdata->lock);
|
||||||
dev_err(pdata->dev, "%s: failed to get supplicant data",
|
dev_err(pdata->dev, "%s: failed to get supplicant data",
|
||||||
__func__);
|
__func__);
|
||||||
@@ -1006,9 +987,8 @@ static int macsec_deinit(struct sk_buff *skb, struct genl_info *info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = macsec_close(macsec_pdata);
|
ret = macsec_close(macsec_pdata);
|
||||||
//TODO - check why needs -EOPNOTSUPP, why not pass ret val
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ret = -EOPNOTSUPP;
|
ret = -EPROTO;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
@@ -1040,7 +1020,7 @@ static int macsec_init(struct sk_buff *skb, struct genl_info *info)
|
|||||||
|
|
||||||
macsec_pdata = genl_to_macsec_pdata(info);
|
macsec_pdata = genl_to_macsec_pdata(info);
|
||||||
if (!macsec_pdata) {
|
if (!macsec_pdata) {
|
||||||
ret = -EOPNOTSUPP;
|
ret = -EPROTO;
|
||||||
pr_err("%s: failed to get macsec_pdata", __func__);
|
pr_err("%s: failed to get macsec_pdata", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@@ -1055,8 +1035,8 @@ static int macsec_init(struct sk_buff *skb, struct genl_info *info)
|
|||||||
}
|
}
|
||||||
mutex_lock(&macsec_pdata->lock);
|
mutex_lock(&macsec_pdata->lock);
|
||||||
|
|
||||||
if (macsec_pdata->next_supp_idx >= MAX_NUM_SC) {
|
if (macsec_pdata->next_supp_idx >= OSI_MAX_NUM_SC) {
|
||||||
ret = -EOPNOTSUPP;
|
ret = -EPROTO;
|
||||||
mutex_unlock(&macsec_pdata->lock);
|
mutex_unlock(&macsec_pdata->lock);
|
||||||
dev_err(dev, "%s: Reached max supported supplicants", __func__);
|
dev_err(dev, "%s: Reached max supported supplicants", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
@@ -1080,9 +1060,8 @@ static int macsec_init(struct sk_buff *skb, struct genl_info *info)
|
|||||||
|
|
||||||
mutex_unlock(&macsec_pdata->lock);
|
mutex_unlock(&macsec_pdata->lock);
|
||||||
ret = macsec_open(macsec_pdata, info);
|
ret = macsec_open(macsec_pdata, info);
|
||||||
//TODO - check why needs -EOPNOTSUPP, why not pass ret val
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ret = -EOPNOTSUPP;
|
ret = -EPROTO;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
@@ -1098,23 +1077,48 @@ static int macsec_set_replay_prot(struct sk_buff *skb, struct genl_info *info)
|
|||||||
{
|
{
|
||||||
struct nlattr **attrs = info->attrs;
|
struct nlattr **attrs = info->attrs;
|
||||||
unsigned int replay_prot, window;
|
unsigned int replay_prot, window;
|
||||||
|
struct macsec_priv_data *macsec_pdata = NULL;
|
||||||
|
struct ether_priv_data *pdata = NULL;
|
||||||
|
struct device *dev = NULL;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
PRINT_ENTRY();
|
||||||
|
|
||||||
if (!attrs[NV_MACSEC_ATTR_IFNAME] ||
|
if (!attrs[NV_MACSEC_ATTR_IFNAME] ||
|
||||||
!attrs[NV_MACSEC_ATTR_REPLAY_PROT_EN] ||
|
!attrs[NV_MACSEC_ATTR_REPLAY_PROT_EN] ||
|
||||||
!attrs[NV_MACSEC_ATTR_REPLAY_WINDOW]) {
|
!attrs[NV_MACSEC_ATTR_REPLAY_WINDOW]) {
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
replay_prot = nla_get_u32(attrs[NV_MACSEC_ATTR_REPLAY_PROT_EN]);
|
replay_prot = nla_get_u32(attrs[NV_MACSEC_ATTR_REPLAY_PROT_EN]);
|
||||||
window = nla_get_u32(attrs[NV_MACSEC_ATTR_REPLAY_WINDOW]);
|
window = nla_get_u32(attrs[NV_MACSEC_ATTR_REPLAY_WINDOW]);
|
||||||
pr_err("replay_prot(window): %u(%u)\n",
|
macsec_pdata = genl_to_macsec_pdata(info);
|
||||||
replay_prot, window);
|
|
||||||
|
|
||||||
|
if (!macsec_pdata) {
|
||||||
|
ret = -EPROTO;
|
||||||
|
pr_err("%s: failed to get macsec_pdata", __func__);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO - set replay window for all active SA's.
|
pdata = macsec_pdata->ether_pdata;
|
||||||
* Store window in macsec_pdata so that future SA's can be updated
|
dev = pdata->dev;
|
||||||
*/
|
|
||||||
return 0;
|
if (!netif_running(pdata->ndev)) {
|
||||||
|
ret = -ENETDOWN;
|
||||||
|
dev_err(pdata->dev, "%s: MAC interface down!!\n", __func__);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window != 0) {
|
||||||
|
macsec_pdata->pn_window = window;
|
||||||
|
} else {
|
||||||
|
macsec_pdata->pn_window = OSI_PN_MAX_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
PRINT_EXIT();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct genl_ops nv_macsec_genl_ops[] = {
|
static const struct genl_ops nv_macsec_genl_ops[] = {
|
||||||
@@ -1192,7 +1196,7 @@ void macsec_remove(struct ether_priv_data *pdata)
|
|||||||
mutex_lock(&macsec_pdata->lock);
|
mutex_lock(&macsec_pdata->lock);
|
||||||
/* Delete if any supplicant active heartbeat timer */
|
/* Delete if any supplicant active heartbeat timer */
|
||||||
supplicant = macsec_pdata->supplicant;
|
supplicant = macsec_pdata->supplicant;
|
||||||
for (i = 0; i < MAX_NUM_SC; i++) {
|
for (i = 0; i < OSI_MAX_NUM_SC; i++) {
|
||||||
if (supplicant[i].in_use == OSI_ENABLE) {
|
if (supplicant[i].in_use == OSI_ENABLE) {
|
||||||
supplicant->snd_portid = OSI_NONE;
|
supplicant->snd_portid = OSI_NONE;
|
||||||
supplicant->in_use = OSI_NONE;
|
supplicant->in_use = OSI_NONE;
|
||||||
@@ -1220,23 +1224,6 @@ void macsec_remove(struct ether_priv_data *pdata)
|
|||||||
PRINT_EXIT();
|
PRINT_EXIT();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST
|
|
||||||
int macsec_genl_register(void)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
ret = genl_register_family(&nv_macsec_fam);
|
|
||||||
if (ret < 0) {
|
|
||||||
pr_err("failed to register genl\n");
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void macsec_genl_unregister(void)
|
|
||||||
{
|
|
||||||
genl_unregister_family(&nv_macsec_fam);
|
|
||||||
}
|
|
||||||
#endif /* TEST */
|
|
||||||
|
|
||||||
int macsec_probe(struct ether_priv_data *pdata)
|
int macsec_probe(struct ether_priv_data *pdata)
|
||||||
{
|
{
|
||||||
struct device *dev = pdata->dev;
|
struct device *dev = pdata->dev;
|
||||||
@@ -1248,7 +1235,7 @@ int macsec_probe(struct ether_priv_data *pdata)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
PRINT_ENTRY();
|
PRINT_ENTRY();
|
||||||
/* 1. Check if MACsec is enabled in DT, if so map the I/O base addr */
|
/* Check if MACsec is enabled in DT, if so map the I/O base addr */
|
||||||
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "macsec-base");
|
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "macsec-base");
|
||||||
if (res) {
|
if (res) {
|
||||||
osi_core->macsec_base = devm_ioremap_resource(dev, res);
|
osi_core->macsec_base = devm_ioremap_resource(dev, res);
|
||||||
@@ -1276,7 +1263,7 @@ int macsec_probe(struct ether_priv_data *pdata)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* 2. Alloc macsec priv data structure */
|
/* Alloc macsec priv data structure */
|
||||||
macsec_pdata = devm_kzalloc(dev, sizeof(struct macsec_priv_data),
|
macsec_pdata = devm_kzalloc(dev, sizeof(struct macsec_priv_data),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (macsec_pdata == NULL) {
|
if (macsec_pdata == NULL) {
|
||||||
@@ -1296,14 +1283,14 @@ int macsec_probe(struct ether_priv_data *pdata)
|
|||||||
macsec_pdata->id = 0;
|
macsec_pdata->id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 3. Get OSI MACsec ops */
|
/* Get OSI MACsec ops */
|
||||||
if (osi_init_macsec_ops(osi_core) != 0) {
|
if (osi_init_macsec_ops(osi_core) != 0) {
|
||||||
dev_err(dev, "osi_init_macsec_ops failed\n");
|
dev_err(dev, "osi_init_macsec_ops failed\n");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto init_err;
|
goto init_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 4. Get platform resources - clks, resets, irqs.
|
/* Get platform resources - clks, resets, irqs.
|
||||||
* CAR is not enabled and irqs not requested until macsec_init()
|
* CAR is not enabled and irqs not requested until macsec_init()
|
||||||
*/
|
*/
|
||||||
ret = macsec_get_platform_res(macsec_pdata);
|
ret = macsec_get_platform_res(macsec_pdata);
|
||||||
@@ -1312,15 +1299,14 @@ int macsec_probe(struct ether_priv_data *pdata)
|
|||||||
goto init_err;
|
goto init_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 2. Enable CAR */
|
/* Enable CAR */
|
||||||
ret = macsec_enable_car(macsec_pdata);
|
ret = macsec_enable_car(macsec_pdata);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "Unable to enable macsec clks & reset\n");
|
dev_err(dev, "Unable to enable macsec clks & reset\n");
|
||||||
goto car_err;
|
goto car_err;
|
||||||
}
|
}
|
||||||
/* 5. Register macsec sysfs node - done from sysfs.c */
|
|
||||||
|
|
||||||
/* 6. Register macsec generic netlink ops */
|
/* Register macsec generic netlink ops */
|
||||||
if (is_nv_macsec_fam_registered == OSI_DISABLE) {
|
if (is_nv_macsec_fam_registered == OSI_DISABLE) {
|
||||||
ret = genl_register_family(&nv_macsec_fam);
|
ret = genl_register_family(&nv_macsec_fam);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@@ -1374,13 +1360,14 @@ static int macsec_tz_kt_config(struct ether_priv_data *pdata,
|
|||||||
/* return success, as info can be NULL if called from
|
/* return success, as info can be NULL if called from
|
||||||
* sysfs calls
|
* sysfs calls
|
||||||
*/
|
*/
|
||||||
return ret;
|
ret = 0;
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remap osi tz cmd to netlink cmd */
|
/* remap osi tz cmd to netlink cmd */
|
||||||
if (cmd == MACSEC_CMD_TZ_CONFIG) {
|
if (cmd == OSI_MACSEC_CMD_TZ_CONFIG) {
|
||||||
cmd = NV_MACSEC_CMD_TZ_CONFIG;
|
cmd = NV_MACSEC_CMD_TZ_CONFIG;
|
||||||
} else if (cmd == MACSEC_CMD_TZ_KT_RESET) {
|
} else if (cmd == OSI_MACSEC_CMD_TZ_KT_RESET) {
|
||||||
cmd = NV_MACSEC_CMD_TZ_KT_RESET;
|
cmd = NV_MACSEC_CMD_TZ_KT_RESET;
|
||||||
} else {
|
} else {
|
||||||
dev_err(dev, "%s: Wrong TZ cmd %d\n", __func__, cmd);
|
dev_err(dev, "%s: Wrong TZ cmd %d\n", __func__, cmd);
|
||||||
@@ -1423,7 +1410,7 @@ static int macsec_tz_kt_config(struct ether_priv_data *pdata,
|
|||||||
kt_config->table_config.rw);
|
kt_config->table_config.rw);
|
||||||
nla_put_u8(msg, NV_MACSEC_TZ_ATTR_INDEX,
|
nla_put_u8(msg, NV_MACSEC_TZ_ATTR_INDEX,
|
||||||
kt_config->table_config.index);
|
kt_config->table_config.index);
|
||||||
nla_put(msg, NV_MACSEC_TZ_ATTR_KEY, KEY_LEN_256,
|
nla_put(msg, NV_MACSEC_TZ_ATTR_KEY, OSI_KEY_LEN_256,
|
||||||
kt_config->entry.sak);
|
kt_config->entry.sak);
|
||||||
nla_put_u32(msg, NV_MACSEC_TZ_ATTR_FLAG, kt_config->flags);
|
nla_put_u32(msg, NV_MACSEC_TZ_ATTR_FLAG, kt_config->flags);
|
||||||
nla_nest_end(msg, nest);
|
nla_nest_end(msg, nest);
|
||||||
|
|||||||
@@ -28,8 +28,6 @@
|
|||||||
#include <net/genetlink.h>
|
#include <net/genetlink.h>
|
||||||
#include <linux/crypto.h>
|
#include <linux/crypto.h>
|
||||||
|
|
||||||
//#define TEST 1
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Size of Macsec IRQ name.
|
* @brief Size of Macsec IRQ name.
|
||||||
*/
|
*/
|
||||||
@@ -86,7 +84,7 @@ static const struct nla_policy nv_macsec_sa_genl_policy[NUM_NV_MACSEC_SA_ATTR] =
|
|||||||
[NV_MACSEC_SA_ATTR_AN] = { .type = NLA_U8 },
|
[NV_MACSEC_SA_ATTR_AN] = { .type = NLA_U8 },
|
||||||
[NV_MACSEC_SA_ATTR_PN] = { .type = NLA_U32 },
|
[NV_MACSEC_SA_ATTR_PN] = { .type = NLA_U32 },
|
||||||
[NV_MACSEC_SA_ATTR_KEY] = { .type = NLA_BINARY,
|
[NV_MACSEC_SA_ATTR_KEY] = { .type = NLA_BINARY,
|
||||||
.len = KEY_LEN_128,},
|
.len = OSI_KEY_LEN_128,},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct nla_policy nv_macsec_tz_genl_policy[NUM_NV_MACSEC_TZ_ATTR] = {
|
static const struct nla_policy nv_macsec_tz_genl_policy[NUM_NV_MACSEC_TZ_ATTR] = {
|
||||||
@@ -95,7 +93,7 @@ static const struct nla_policy nv_macsec_tz_genl_policy[NUM_NV_MACSEC_TZ_ATTR] =
|
|||||||
[NV_MACSEC_TZ_ATTR_RW] = { .type = NLA_U8 },
|
[NV_MACSEC_TZ_ATTR_RW] = { .type = NLA_U8 },
|
||||||
[NV_MACSEC_TZ_ATTR_INDEX] = { .type = NLA_U8 },
|
[NV_MACSEC_TZ_ATTR_INDEX] = { .type = NLA_U8 },
|
||||||
[NV_MACSEC_TZ_ATTR_KEY] = { .type = NLA_BINARY,
|
[NV_MACSEC_TZ_ATTR_KEY] = { .type = NLA_BINARY,
|
||||||
.len = KEY_LEN_256 },
|
.len = OSI_KEY_LEN_256 },
|
||||||
[NV_MACSEC_TZ_ATTR_FLAG] = { .type = NLA_U32 },
|
[NV_MACSEC_TZ_ATTR_FLAG] = { .type = NLA_U32 },
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -136,6 +134,8 @@ struct macsec_supplicant_data {
|
|||||||
unsigned int protect_frames;
|
unsigned int protect_frames;
|
||||||
/** MACsec enabled flags for Tx/Rx controller status */
|
/** MACsec enabled flags for Tx/Rx controller status */
|
||||||
unsigned int enabled;
|
unsigned int enabled;
|
||||||
|
/** MACsec cipher suite */
|
||||||
|
unsigned int cipher;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,10 +166,12 @@ struct macsec_priv_data {
|
|||||||
unsigned int protect_frames;
|
unsigned int protect_frames;
|
||||||
/** MACsec enabled flags for Tx/Rx controller status */
|
/** MACsec enabled flags for Tx/Rx controller status */
|
||||||
unsigned int enabled;
|
unsigned int enabled;
|
||||||
|
/** MACsec Rx PN Window */
|
||||||
|
unsigned int pn_window;
|
||||||
/** MACsec controller init reference count */
|
/** MACsec controller init reference count */
|
||||||
atomic_t ref_count;
|
atomic_t ref_count;
|
||||||
/** supplicant instance specific data */
|
/** supplicant instance specific data */
|
||||||
struct macsec_supplicant_data supplicant[MAX_NUM_SC];
|
struct macsec_supplicant_data supplicant[OSI_MAX_NUM_SC];
|
||||||
/** next supplicant instance index */
|
/** next supplicant instance index */
|
||||||
unsigned short next_supp_idx;
|
unsigned short next_supp_idx;
|
||||||
/** macsec mutex lock */
|
/** macsec mutex lock */
|
||||||
@@ -184,11 +186,6 @@ int macsec_open(struct macsec_priv_data *macsec_pdata,
|
|||||||
void *const genl_info);
|
void *const genl_info);
|
||||||
int macsec_close(struct macsec_priv_data *macsec_pdata);
|
int macsec_close(struct macsec_priv_data *macsec_pdata);
|
||||||
|
|
||||||
#ifdef TEST
|
|
||||||
int macsec_genl_register(void);
|
|
||||||
void macsec_genl_unregister(void);
|
|
||||||
#endif /* TEST */
|
|
||||||
|
|
||||||
#ifdef MACSEC_DEBUG
|
#ifdef MACSEC_DEBUG
|
||||||
#define PRINT_ENTRY() (pr_info("-->%s()\n", __func__))
|
#define PRINT_ENTRY() (pr_info("-->%s()\n", __func__))
|
||||||
#define PRINT_EXIT() (pr_info("<--%s()\n", __func__))
|
#define PRINT_EXIT() (pr_info("<--%s()\n", __func__))
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ static ssize_t macsec_cipher_show(struct device *dev,
|
|||||||
struct macsec_priv_data *macsec_pdata = pdata->macsec_pdata;
|
struct macsec_priv_data *macsec_pdata = pdata->macsec_pdata;
|
||||||
|
|
||||||
return scnprintf(buf, PAGE_SIZE, "%s\n",
|
return scnprintf(buf, PAGE_SIZE, "%s\n",
|
||||||
(macsec_pdata->cipher == MACSEC_CIPHER_AES128) ?
|
(macsec_pdata->cipher == OSI_MACSEC_CIPHER_AES128) ?
|
||||||
"aes128" : "aes256");
|
"aes128" : "aes256");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,20 +328,20 @@ static ssize_t macsec_cipher_store(struct device *dev,
|
|||||||
|
|
||||||
if (strncmp(buf, "aes128", 6) == OSI_NONE) {
|
if (strncmp(buf, "aes128", 6) == OSI_NONE) {
|
||||||
ret = osi_macsec_cipher_config(pdata->osi_core,
|
ret = osi_macsec_cipher_config(pdata->osi_core,
|
||||||
MACSEC_CIPHER_AES128);
|
OSI_MACSEC_CIPHER_AES128);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(pdata->dev, "Failed to set macsec cipher\n");
|
dev_err(pdata->dev, "Failed to set macsec cipher\n");
|
||||||
} else {
|
} else {
|
||||||
macsec_pdata->cipher = MACSEC_CIPHER_AES128;
|
macsec_pdata->cipher = OSI_MACSEC_CIPHER_AES128;
|
||||||
dev_info(pdata->dev, "macsec cipher aes128 enabled\n");
|
dev_info(pdata->dev, "macsec cipher aes128 enabled\n");
|
||||||
}
|
}
|
||||||
} else if (strncmp(buf, "aes256", 6) == OSI_NONE) {
|
} else if (strncmp(buf, "aes256", 6) == OSI_NONE) {
|
||||||
ret = osi_macsec_cipher_config(pdata->osi_core,
|
ret = osi_macsec_cipher_config(pdata->osi_core,
|
||||||
MACSEC_CIPHER_AES256);
|
OSI_MACSEC_CIPHER_AES256);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(pdata->dev, "Failed to set macsec cipher\n");
|
dev_err(pdata->dev, "Failed to set macsec cipher\n");
|
||||||
} else {
|
} else {
|
||||||
macsec_pdata->cipher = MACSEC_CIPHER_AES256;
|
macsec_pdata->cipher = OSI_MACSEC_CIPHER_AES256;
|
||||||
dev_info(pdata->dev, "macsec cipher aes256 enabled\n");
|
dev_info(pdata->dev, "macsec cipher aes256 enabled\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -454,9 +454,9 @@ static void format_output(char **buf_p,
|
|||||||
{
|
{
|
||||||
char *buf = *buf_p;
|
char *buf = *buf_p;
|
||||||
unsigned int flags = lut_config->flags;
|
unsigned int flags = lut_config->flags;
|
||||||
struct lut_inputs entry = lut_config->lut_in;
|
struct osi_lut_inputs entry = lut_config->lut_in;
|
||||||
|
|
||||||
if ((flags & LUT_FLAGS_DA_VALID) == LUT_FLAGS_DA_VALID) {
|
if ((flags & OSI_LUT_FLAGS_DA_VALID) == OSI_LUT_FLAGS_DA_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "DA: " MAC_ADDR_FMT " ",
|
buf += scnprintf(buf, PAGE_SIZE, "DA: " MAC_ADDR_FMT " ",
|
||||||
entry.da[5], entry.da[4], entry.da[3],
|
entry.da[5], entry.da[4], entry.da[3],
|
||||||
entry.da[2], entry.da[1], entry.da[0]);
|
entry.da[2], entry.da[1], entry.da[0]);
|
||||||
@@ -464,7 +464,7 @@ static void format_output(char **buf_p,
|
|||||||
buf += scnprintf(buf, PAGE_SIZE, "DA: X ");
|
buf += scnprintf(buf, PAGE_SIZE, "DA: X ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & LUT_FLAGS_SA_VALID) == LUT_FLAGS_SA_VALID) {
|
if ((flags & OSI_LUT_FLAGS_SA_VALID) == OSI_LUT_FLAGS_SA_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "SA: " MAC_ADDR_FMT " ",
|
buf += scnprintf(buf, PAGE_SIZE, "SA: " MAC_ADDR_FMT " ",
|
||||||
entry.sa[5], entry.sa[4], entry.sa[3],
|
entry.sa[5], entry.sa[4], entry.sa[3],
|
||||||
entry.sa[2], entry.sa[1], entry.sa[0]);
|
entry.sa[2], entry.sa[1], entry.sa[0]);
|
||||||
@@ -472,24 +472,25 @@ static void format_output(char **buf_p,
|
|||||||
buf += scnprintf(buf, PAGE_SIZE, "SA: X ");
|
buf += scnprintf(buf, PAGE_SIZE, "SA: X ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & LUT_FLAGS_ETHTYPE_VALID) == LUT_FLAGS_ETHTYPE_VALID) {
|
if ((flags & OSI_LUT_FLAGS_ETHTYPE_VALID) ==
|
||||||
|
OSI_LUT_FLAGS_ETHTYPE_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "ethtype: " ETHTYPE_FMT " ",
|
buf += scnprintf(buf, PAGE_SIZE, "ethtype: " ETHTYPE_FMT " ",
|
||||||
entry.ethtype[1], entry.ethtype[0]);
|
entry.ethtype[1], entry.ethtype[0]);
|
||||||
} else {
|
} else {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "ethtype: X ");
|
buf += scnprintf(buf, PAGE_SIZE, "ethtype: X ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & LUT_FLAGS_VLAN_VALID) == LUT_FLAGS_VLAN_VALID) {
|
if ((flags & OSI_LUT_FLAGS_VLAN_VALID) == OSI_LUT_FLAGS_VLAN_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "vlan: ");
|
buf += scnprintf(buf, PAGE_SIZE, "vlan: ");
|
||||||
if ((flags & LUT_FLAGS_VLAN_PCP_VALID) ==
|
if ((flags & OSI_LUT_FLAGS_VLAN_PCP_VALID) ==
|
||||||
LUT_FLAGS_VLAN_PCP_VALID) {
|
OSI_LUT_FLAGS_VLAN_PCP_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "prio: %u ",
|
buf += scnprintf(buf, PAGE_SIZE, "prio: %u ",
|
||||||
entry.vlan_pcp);
|
entry.vlan_pcp);
|
||||||
} else {
|
} else {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "prio: X ");
|
buf += scnprintf(buf, PAGE_SIZE, "prio: X ");
|
||||||
}
|
}
|
||||||
if ((flags & LUT_FLAGS_VLAN_ID_VALID) ==
|
if ((flags & OSI_LUT_FLAGS_VLAN_ID_VALID) ==
|
||||||
LUT_FLAGS_VLAN_ID_VALID) {
|
OSI_LUT_FLAGS_VLAN_ID_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "id: %u ",
|
buf += scnprintf(buf, PAGE_SIZE, "id: %u ",
|
||||||
entry.vlan_id);
|
entry.vlan_id);
|
||||||
} else {
|
} else {
|
||||||
@@ -499,10 +500,10 @@ static void format_output(char **buf_p,
|
|||||||
buf += scnprintf(buf, PAGE_SIZE, "vlan: X ");
|
buf += scnprintf(buf, PAGE_SIZE, "vlan: X ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & LUT_FLAGS_DVLAN_PKT) == LUT_FLAGS_DVLAN_PKT) {
|
if ((flags & OSI_LUT_FLAGS_DVLAN_PKT) == OSI_LUT_FLAGS_DVLAN_PKT) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "dvlan: 1 ");
|
buf += scnprintf(buf, PAGE_SIZE, "dvlan: 1 ");
|
||||||
if ((flags & LUT_FLAGS_DVLAN_OUTER_INNER_TAG_SEL) ==
|
if ((flags & OSI_LUT_FLAGS_DVLAN_OUTER_INNER_TAG_SEL) ==
|
||||||
LUT_FLAGS_DVLAN_OUTER_INNER_TAG_SEL) {
|
OSI_LUT_FLAGS_DVLAN_OUTER_INNER_TAG_SEL) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "dvlan_outer_tag: 1 ");
|
buf += scnprintf(buf, PAGE_SIZE, "dvlan_outer_tag: 1 ");
|
||||||
} else {
|
} else {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "dvlan_outer_tag: 0 ");
|
buf += scnprintf(buf, PAGE_SIZE, "dvlan_outer_tag: 0 ");
|
||||||
@@ -511,8 +512,8 @@ static void format_output(char **buf_p,
|
|||||||
buf += scnprintf(buf, PAGE_SIZE, "dvlan: X ");
|
buf += scnprintf(buf, PAGE_SIZE, "dvlan: X ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & LUT_FLAGS_BYTE0_PATTERN_VALID) ==
|
if ((flags & OSI_LUT_FLAGS_BYTE0_PATTERN_VALID) ==
|
||||||
LUT_FLAGS_BYTE0_PATTERN_VALID) {
|
OSI_LUT_FLAGS_BYTE0_PATTERN_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Byte0: Pattern: %x "
|
buf += scnprintf(buf, PAGE_SIZE, "Byte0: Pattern: %x "
|
||||||
"offset: %u ",
|
"offset: %u ",
|
||||||
entry.byte_pattern[0],
|
entry.byte_pattern[0],
|
||||||
@@ -521,8 +522,8 @@ static void format_output(char **buf_p,
|
|||||||
buf += scnprintf(buf, PAGE_SIZE, "Byte0: X ");
|
buf += scnprintf(buf, PAGE_SIZE, "Byte0: X ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & LUT_FLAGS_BYTE1_PATTERN_VALID) ==
|
if ((flags & OSI_LUT_FLAGS_BYTE1_PATTERN_VALID) ==
|
||||||
LUT_FLAGS_BYTE1_PATTERN_VALID) {
|
OSI_LUT_FLAGS_BYTE1_PATTERN_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Byte1: Pattern: %x "
|
buf += scnprintf(buf, PAGE_SIZE, "Byte1: Pattern: %x "
|
||||||
"offset: %u ",
|
"offset: %u ",
|
||||||
entry.byte_pattern[1],
|
entry.byte_pattern[1],
|
||||||
@@ -531,8 +532,8 @@ static void format_output(char **buf_p,
|
|||||||
buf += scnprintf(buf, PAGE_SIZE, "Byte1: X ");
|
buf += scnprintf(buf, PAGE_SIZE, "Byte1: X ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & LUT_FLAGS_BYTE2_PATTERN_VALID) ==
|
if ((flags & OSI_LUT_FLAGS_BYTE2_PATTERN_VALID) ==
|
||||||
LUT_FLAGS_BYTE2_PATTERN_VALID) {
|
OSI_LUT_FLAGS_BYTE2_PATTERN_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Byte2: Pattern: %x "
|
buf += scnprintf(buf, PAGE_SIZE, "Byte2: Pattern: %x "
|
||||||
"offset: %u ",
|
"offset: %u ",
|
||||||
entry.byte_pattern[2],
|
entry.byte_pattern[2],
|
||||||
@@ -541,8 +542,8 @@ static void format_output(char **buf_p,
|
|||||||
buf += scnprintf(buf, PAGE_SIZE, "Byte2: X ");
|
buf += scnprintf(buf, PAGE_SIZE, "Byte2: X ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & LUT_FLAGS_BYTE3_PATTERN_VALID) ==
|
if ((flags & OSI_LUT_FLAGS_BYTE3_PATTERN_VALID) ==
|
||||||
LUT_FLAGS_BYTE3_PATTERN_VALID) {
|
OSI_LUT_FLAGS_BYTE3_PATTERN_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Byte3: Pattern: %x "
|
buf += scnprintf(buf, PAGE_SIZE, "Byte3: Pattern: %x "
|
||||||
"offset: %u ",
|
"offset: %u ",
|
||||||
entry.byte_pattern[3],
|
entry.byte_pattern[3],
|
||||||
@@ -551,8 +552,9 @@ static void format_output(char **buf_p,
|
|||||||
buf += scnprintf(buf, PAGE_SIZE, "Byte3: X ");
|
buf += scnprintf(buf, PAGE_SIZE, "Byte3: X ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & LUT_FLAGS_PREEMPT_VALID) == LUT_FLAGS_PREEMPT_VALID) {
|
if ((flags & OSI_LUT_FLAGS_PREEMPT_VALID) ==
|
||||||
if ((flags & LUT_FLAGS_PREEMPT) == LUT_FLAGS_PREEMPT) {
|
OSI_LUT_FLAGS_PREEMPT_VALID) {
|
||||||
|
if ((flags & OSI_LUT_FLAGS_PREEMPT) == OSI_LUT_FLAGS_PREEMPT) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "prempt: 1 ");
|
buf += scnprintf(buf, PAGE_SIZE, "prempt: 1 ");
|
||||||
} else {
|
} else {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "prempt: 0 ");
|
buf += scnprintf(buf, PAGE_SIZE, "prempt: 0 ");
|
||||||
@@ -571,21 +573,21 @@ static void format_output(char **buf_p,
|
|||||||
static int parse_inputs(const char *buf,
|
static int parse_inputs(const char *buf,
|
||||||
struct osi_macsec_lut_config *lut_config, int *bufp)
|
struct osi_macsec_lut_config *lut_config, int *bufp)
|
||||||
{
|
{
|
||||||
struct lut_inputs *lut_in;
|
struct osi_lut_inputs *lut_in;
|
||||||
int temp[OSI_ETH_ALEN] = {0};
|
int temp[OSI_ETH_ALEN] = {0};
|
||||||
int temp2[OSI_ETH_ALEN] = {0};
|
int temp2[OSI_ETH_ALEN] = {0};
|
||||||
int temp3[LUT_BYTE_PATTERN_MAX] = {0};
|
int temp3[OSI_LUT_BYTE_PATTERN_MAX] = {0};
|
||||||
int temp4[ETHTYPE_LEN] = {0};
|
int temp4[OSI_ETHTYPE_LEN] = {0};
|
||||||
unsigned char byte[LUT_BYTE_PATTERN_MAX] = {0};
|
unsigned char byte[OSI_LUT_BYTE_PATTERN_MAX] = {0};
|
||||||
unsigned char mac_da[OSI_ETH_ALEN] = {0};
|
unsigned char mac_da[OSI_ETH_ALEN] = {0};
|
||||||
unsigned char mac_sa[OSI_ETH_ALEN] = {0};
|
unsigned char mac_sa[OSI_ETH_ALEN] = {0};
|
||||||
unsigned char ethtype[ETHTYPE_LEN] = {0};
|
unsigned char ethtype[OSI_ETHTYPE_LEN] = {0};
|
||||||
unsigned int byte_offset[LUT_BYTE_PATTERN_MAX] = {0};
|
unsigned int byte_offset[OSI_LUT_BYTE_PATTERN_MAX] = {0};
|
||||||
unsigned int vlan_pcp = 0, vlan_id = 0, flags = 0;
|
unsigned int vlan_pcp = 0, vlan_id = 0, flags = 0;
|
||||||
unsigned short controller;
|
unsigned short controller;
|
||||||
int mac_da_valid, mac_sa_valid, ethtype_valid, vlan_valid;
|
int mac_da_valid, mac_sa_valid, ethtype_valid, vlan_valid;
|
||||||
int dvlan, dvlan_outer_tag;
|
int dvlan, dvlan_outer_tag;
|
||||||
int byte_valid[LUT_BYTE_PATTERN_MAX];
|
int byte_valid[OSI_LUT_BYTE_PATTERN_MAX];
|
||||||
int i, valid, index;;
|
int i, valid, index;;
|
||||||
|
|
||||||
|
|
||||||
@@ -620,11 +622,11 @@ static int parse_inputs(const char *buf,
|
|||||||
mac_sa[i] = (unsigned char)temp2[i];
|
mac_sa[i] = (unsigned char)temp2[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ETHTYPE_LEN; i++) {
|
for (i = 0; i < OSI_ETHTYPE_LEN; i++) {
|
||||||
ethtype[i] = (unsigned char)temp4[i];
|
ethtype[i] = (unsigned char)temp4[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < LUT_BYTE_PATTERN_MAX; i++) {
|
for (i = 0; i < OSI_LUT_BYTE_PATTERN_MAX; i++) {
|
||||||
byte[i] = (unsigned char)temp3[i];
|
byte[i] = (unsigned char)temp3[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -648,7 +650,7 @@ static int parse_inputs(const char *buf,
|
|||||||
for (i = 0; i < OSI_ETH_ALEN; i++) {
|
for (i = 0; i < OSI_ETH_ALEN; i++) {
|
||||||
lut_in->da[i] = mac_da[OSI_ETH_ALEN - 1 - i];
|
lut_in->da[i] = mac_da[OSI_ETH_ALEN - 1 - i];
|
||||||
}
|
}
|
||||||
flags |= LUT_FLAGS_DA_VALID;
|
flags |= OSI_LUT_FLAGS_DA_VALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mac_sa_valid) {
|
if (mac_sa_valid) {
|
||||||
@@ -656,32 +658,31 @@ static int parse_inputs(const char *buf,
|
|||||||
for (i = 0; i < OSI_ETH_ALEN; i++) {
|
for (i = 0; i < OSI_ETH_ALEN; i++) {
|
||||||
lut_in->sa[i] = mac_sa[OSI_ETH_ALEN - 1 - i];
|
lut_in->sa[i] = mac_sa[OSI_ETH_ALEN - 1 - i];
|
||||||
}
|
}
|
||||||
flags |= LUT_FLAGS_SA_VALID;
|
flags |= OSI_LUT_FLAGS_SA_VALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ethtype_valid) {
|
if (ethtype_valid) {
|
||||||
/* Reverse endianess for HW */
|
/* Reverse endianess for HW */
|
||||||
for (i = 0; i < ETHTYPE_LEN; i++) {
|
for (i = 0; i < OSI_ETHTYPE_LEN; i++) {
|
||||||
lut_in->ethtype[i] = ethtype[ETHTYPE_LEN - 1 - i];
|
lut_in->ethtype[i] = ethtype[OSI_ETHTYPE_LEN - 1 - i];
|
||||||
}
|
}
|
||||||
flags |= LUT_FLAGS_ETHTYPE_VALID;
|
flags |= OSI_LUT_FLAGS_ETHTYPE_VALID;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < LUT_BYTE_PATTERN_MAX; i++) {
|
for (i = 0; i < OSI_LUT_BYTE_PATTERN_MAX; i++) {
|
||||||
if (byte_valid[i]) {
|
if (byte_valid[i]) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
flags |= LUT_FLAGS_BYTE0_PATTERN_VALID;
|
flags |= OSI_LUT_FLAGS_BYTE0_PATTERN_VALID;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
flags |= LUT_FLAGS_BYTE1_PATTERN_VALID;
|
flags |= OSI_LUT_FLAGS_BYTE1_PATTERN_VALID;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
flags |= LUT_FLAGS_BYTE2_PATTERN_VALID;
|
flags |= OSI_LUT_FLAGS_BYTE2_PATTERN_VALID;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
flags |= LUT_FLAGS_BYTE3_PATTERN_VALID;
|
flags |= OSI_LUT_FLAGS_BYTE3_PATTERN_VALID;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -694,19 +695,20 @@ static int parse_inputs(const char *buf,
|
|||||||
if (vlan_valid) {
|
if (vlan_valid) {
|
||||||
lut_in->vlan_pcp = vlan_pcp;
|
lut_in->vlan_pcp = vlan_pcp;
|
||||||
lut_in->vlan_id = vlan_id;
|
lut_in->vlan_id = vlan_id;
|
||||||
flags |= (LUT_FLAGS_VLAN_ID_VALID | LUT_FLAGS_VLAN_PCP_VALID |
|
flags |= (OSI_LUT_FLAGS_VLAN_ID_VALID |
|
||||||
LUT_FLAGS_VLAN_VALID);
|
OSI_LUT_FLAGS_VLAN_PCP_VALID |
|
||||||
|
OSI_LUT_FLAGS_VLAN_VALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dvlan) {
|
if (dvlan) {
|
||||||
flags |= LUT_FLAGS_DVLAN_PKT;
|
flags |= OSI_LUT_FLAGS_DVLAN_PKT;
|
||||||
if (dvlan_outer_tag) {
|
if (dvlan_outer_tag) {
|
||||||
flags |= LUT_FLAGS_DVLAN_OUTER_INNER_TAG_SEL;
|
flags |= OSI_LUT_FLAGS_DVLAN_OUTER_INNER_TAG_SEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
flags |= LUT_FLAGS_ENTRY_VALID;
|
flags |= OSI_LUT_FLAGS_ENTRY_VALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
lut_config->flags = flags;
|
lut_config->flags = flags;
|
||||||
@@ -724,11 +726,11 @@ static void dump_byp_lut(char **buf_p, unsigned short ctlr_sel,
|
|||||||
char *buf = *buf_p;
|
char *buf = *buf_p;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i <= BYP_LUT_MAX_INDEX; i++) {
|
for (i = 0; i <= OSI_BYP_LUT_MAX_INDEX; i++) {
|
||||||
memset(&lut_config, OSI_NONE, sizeof(lut_config));
|
memset(&lut_config, OSI_NONE, sizeof(lut_config));
|
||||||
lut_config.table_config.ctlr_sel = ctlr_sel;
|
lut_config.table_config.ctlr_sel = ctlr_sel;
|
||||||
lut_config.lut_sel = LUT_SEL_BYPASS;
|
lut_config.lut_sel = OSI_LUT_SEL_BYPASS;
|
||||||
lut_config.table_config.rw = LUT_READ;
|
lut_config.table_config.rw = OSI_LUT_READ;
|
||||||
lut_config.table_config.index = i;
|
lut_config.table_config.index = i;
|
||||||
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
||||||
pr_err("%s: Failed to read BYP LUT\n", __func__);
|
pr_err("%s: Failed to read BYP LUT\n", __func__);
|
||||||
@@ -736,8 +738,8 @@ static void dump_byp_lut(char **buf_p, unsigned short ctlr_sel,
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "%d.\t", i);
|
buf += scnprintf(buf, PAGE_SIZE, "%d.\t", i);
|
||||||
if ((lut_config.flags & LUT_FLAGS_ENTRY_VALID) !=
|
if ((lut_config.flags & OSI_LUT_FLAGS_ENTRY_VALID) !=
|
||||||
LUT_FLAGS_ENTRY_VALID) {
|
OSI_LUT_FLAGS_ENTRY_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Invalid\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Invalid\n");
|
||||||
memset(&lut_config, 0, sizeof(lut_config));
|
memset(&lut_config, 0, sizeof(lut_config));
|
||||||
continue;
|
continue;
|
||||||
@@ -745,8 +747,8 @@ static void dump_byp_lut(char **buf_p, unsigned short ctlr_sel,
|
|||||||
|
|
||||||
format_output(&buf, &lut_config);
|
format_output(&buf, &lut_config);
|
||||||
/* BYP LUT output field */
|
/* BYP LUT output field */
|
||||||
if ((lut_config.flags & LUT_FLAGS_CONTROLLED_PORT) ==
|
if ((lut_config.flags & OSI_LUT_FLAGS_CONTROLLED_PORT) ==
|
||||||
LUT_FLAGS_CONTROLLED_PORT) {
|
OSI_LUT_FLAGS_CONTROLLED_PORT) {
|
||||||
buf += scnprintf(buf,
|
buf += scnprintf(buf,
|
||||||
PAGE_SIZE, "ctrl port: 1\n");
|
PAGE_SIZE, "ctrl port: 1\n");
|
||||||
} else {
|
} else {
|
||||||
@@ -780,10 +782,10 @@ static ssize_t macsec_byp_lut_show(struct device *dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Tx:\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Tx:\n");
|
||||||
dump_byp_lut(&buf, CTLR_SEL_TX, osi_core);
|
dump_byp_lut(&buf, OSI_CTLR_SEL_TX, osi_core);
|
||||||
|
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Rx:\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Rx:\n");
|
||||||
dump_byp_lut(&buf, CTLR_SEL_RX, osi_core);
|
dump_byp_lut(&buf, OSI_CTLR_SEL_RX, osi_core);
|
||||||
|
|
||||||
return (buf - start);
|
return (buf - start);
|
||||||
}
|
}
|
||||||
@@ -819,13 +821,12 @@ static ssize_t macsec_byp_lut_store(struct device *dev,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO - need to lock. Since lut_status is updated.
|
lut_config.lut_sel = OSI_LUT_SEL_BYPASS;
|
||||||
lut_config.lut_sel = LUT_SEL_BYPASS;
|
lut_config.table_config.rw = OSI_LUT_WRITE;
|
||||||
lut_config.table_config.rw = LUT_WRITE;
|
|
||||||
/* Rest of LUT attributes are filled by parse_inputs() */
|
/* Rest of LUT attributes are filled by parse_inputs() */
|
||||||
if (lut_config.table_config.index > BYP_LUT_MAX_INDEX) {
|
if (lut_config.table_config.index > OSI_BYP_LUT_MAX_INDEX) {
|
||||||
dev_err(dev, "%s: Index can't be > %d\n", __func__,
|
dev_err(dev, "%s: Index can't be > %d\n", __func__,
|
||||||
BYP_LUT_MAX_INDEX);
|
OSI_BYP_LUT_MAX_INDEX);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -870,8 +871,8 @@ static ssize_t macsec_mmc_counters_show(struct device *dev,
|
|||||||
dev_err(pdata->dev, "Not Allowed. Ether interface is not up\n");
|
dev_err(pdata->dev, "Not Allowed. Ether interface is not up\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
osi_macsec_read_mmc(osi_core);
|
|
||||||
|
|
||||||
|
osi_macsec_read_mmc(osi_core);
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "tx_pkts_untaged:\t%llu\n",
|
buf += scnprintf(buf, PAGE_SIZE, "tx_pkts_untaged:\t%llu\n",
|
||||||
mmc->tx_pkts_untaged);
|
mmc->tx_pkts_untaged);
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "tx_pkts_too_long:\t%llu\n",
|
buf += scnprintf(buf, PAGE_SIZE, "tx_pkts_too_long:\t%llu\n",
|
||||||
@@ -910,6 +911,7 @@ static ssize_t macsec_mmc_counters_show(struct device *dev,
|
|||||||
buf += scnprintf(buf, PAGE_SIZE, "rx_pkts_ok sc%d: \t%llu\n",
|
buf += scnprintf(buf, PAGE_SIZE, "rx_pkts_ok sc%d: \t%llu\n",
|
||||||
i, mmc->rx_pkts_ok[i]);
|
i, mmc->rx_pkts_ok[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (buf - start);
|
return (buf - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -930,14 +932,14 @@ static void dump_dbg_buffers(char **buf_p, unsigned short ctlr_sel,
|
|||||||
int i;
|
int i;
|
||||||
unsigned int idx_max;
|
unsigned int idx_max;
|
||||||
|
|
||||||
if (ctlr_sel == CTLR_SEL_TX) {
|
if (ctlr_sel == OSI_CTLR_SEL_TX) {
|
||||||
idx_max = TX_DBG_BUF_IDX_MAX;
|
idx_max = OSI_TX_DBG_BUF_IDX_MAX;
|
||||||
} else {
|
} else {
|
||||||
idx_max = RX_DBG_BUF_IDX_MAX;
|
idx_max = OSI_RX_DBG_BUF_IDX_MAX;
|
||||||
}
|
}
|
||||||
for (i = 0; i < idx_max; i++) {
|
for (i = 0; i < idx_max; i++) {
|
||||||
memset(&dbg_buf_config, OSI_NONE, sizeof(dbg_buf_config));
|
memset(&dbg_buf_config, OSI_NONE, sizeof(dbg_buf_config));
|
||||||
dbg_buf_config.rw = DBG_TBL_READ;
|
dbg_buf_config.rw = OSI_DBG_TBL_READ;
|
||||||
dbg_buf_config.ctlr_sel = ctlr_sel;
|
dbg_buf_config.ctlr_sel = ctlr_sel;
|
||||||
dbg_buf_config.index = i;
|
dbg_buf_config.index = i;
|
||||||
if (osi_macsec_dbg_buf_config(osi_core, &dbg_buf_config) < 0) {
|
if (osi_macsec_dbg_buf_config(osi_core, &dbg_buf_config) < 0) {
|
||||||
@@ -956,7 +958,7 @@ static void dump_dbg_buffers(char **buf_p, unsigned short ctlr_sel,
|
|||||||
/* reset debug buffer after buf read */
|
/* reset debug buffer after buf read */
|
||||||
for (i = 0; i < idx_max; i++) {
|
for (i = 0; i < idx_max; i++) {
|
||||||
memset(&dbg_buf_config, OSI_NONE, sizeof(dbg_buf_config));
|
memset(&dbg_buf_config, OSI_NONE, sizeof(dbg_buf_config));
|
||||||
dbg_buf_config.rw = DBG_TBL_WRITE;
|
dbg_buf_config.rw = OSI_DBG_TBL_WRITE;
|
||||||
dbg_buf_config.ctlr_sel = ctlr_sel;
|
dbg_buf_config.ctlr_sel = ctlr_sel;
|
||||||
dbg_buf_config.index = i;
|
dbg_buf_config.index = i;
|
||||||
if (osi_macsec_dbg_buf_config(osi_core, &dbg_buf_config) < 0) {
|
if (osi_macsec_dbg_buf_config(osi_core, &dbg_buf_config) < 0) {
|
||||||
@@ -986,10 +988,10 @@ static ssize_t macsec_dbg_buffer_show(struct device *dev,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Tx Dbg Buffers:\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Tx Dbg Buffers:\n");
|
||||||
dump_dbg_buffers(&buf, CTLR_SEL_TX, osi_core);
|
dump_dbg_buffers(&buf, OSI_CTLR_SEL_TX, osi_core);
|
||||||
|
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Rx Dbg Buffers:\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Rx Dbg Buffers:\n");
|
||||||
dump_dbg_buffers(&buf, CTLR_SEL_RX, osi_core);
|
dump_dbg_buffers(&buf, OSI_CTLR_SEL_RX, osi_core);
|
||||||
|
|
||||||
return (buf - start);
|
return (buf - start);
|
||||||
}
|
}
|
||||||
@@ -1050,7 +1052,7 @@ static ssize_t macsec_dbg_events_store(struct device *dev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dbg_buf_config.ctlr_sel = controller;
|
dbg_buf_config.ctlr_sel = controller;
|
||||||
dbg_buf_config.rw = DBG_TBL_WRITE;
|
dbg_buf_config.rw = OSI_DBG_TBL_WRITE;
|
||||||
|
|
||||||
if (osi_macsec_dbg_events_config(osi_core, &dbg_buf_config) < 0) {
|
if (osi_macsec_dbg_events_config(osi_core, &dbg_buf_config) < 0) {
|
||||||
dev_err(dev, "%s: Failed to config dbg trigger events\n", __func__);
|
dev_err(dev, "%s: Failed to config dbg trigger events\n", __func__);
|
||||||
@@ -1098,19 +1100,19 @@ static ssize_t macsec_sci_lut_show(struct device *dev,
|
|||||||
|
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Tx:\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Tx:\n");
|
||||||
|
|
||||||
for (i = 0; i <= SC_LUT_MAX_INDEX; i++) {
|
for (i = 0; i <= OSI_SC_LUT_MAX_INDEX; i++) {
|
||||||
memset(&lut_config, OSI_NONE, sizeof(lut_config));
|
memset(&lut_config, OSI_NONE, sizeof(lut_config));
|
||||||
lut_config.table_config.ctlr_sel = CTLR_SEL_TX;
|
lut_config.table_config.ctlr_sel = OSI_CTLR_SEL_TX;
|
||||||
lut_config.lut_sel = LUT_SEL_SCI;
|
lut_config.lut_sel = OSI_LUT_SEL_SCI;
|
||||||
lut_config.table_config.rw = LUT_READ;
|
lut_config.table_config.rw = OSI_LUT_READ;
|
||||||
lut_config.table_config.index = i;
|
lut_config.table_config.index = i;
|
||||||
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
||||||
dev_err(dev, "%s: Failed to read BYP LUT\n", __func__);
|
dev_err(dev, "%s: Failed to read SCI LUT\n", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
} else {
|
} else {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "%d.\t", i);
|
buf += scnprintf(buf, PAGE_SIZE, "%d.\t", i);
|
||||||
if ((lut_config.flags & LUT_FLAGS_ENTRY_VALID) !=
|
if ((lut_config.flags & OSI_LUT_FLAGS_ENTRY_VALID) !=
|
||||||
LUT_FLAGS_ENTRY_VALID) {
|
OSI_LUT_FLAGS_ENTRY_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Invalid\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Invalid\n");
|
||||||
memset(&lut_config, 0, sizeof(lut_config));
|
memset(&lut_config, 0, sizeof(lut_config));
|
||||||
continue;
|
continue;
|
||||||
@@ -1120,10 +1122,10 @@ static ssize_t macsec_sci_lut_show(struct device *dev,
|
|||||||
an_valid = lut_config.sci_lut_out.an_valid;
|
an_valid = lut_config.sci_lut_out.an_valid;
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "AN3: %d AN2: %d "
|
buf += scnprintf(buf, PAGE_SIZE, "AN3: %d AN2: %d "
|
||||||
"AN1: %d AN0: %d ",
|
"AN1: %d AN0: %d ",
|
||||||
an_valid & AN3_VALID ? 1 : 0,
|
an_valid & OSI_AN3_VALID ? 1 : 0,
|
||||||
an_valid & AN2_VALID ? 1 : 0,
|
an_valid & OSI_AN2_VALID ? 1 : 0,
|
||||||
an_valid & AN1_VALID ? 1 : 0,
|
an_valid & OSI_AN1_VALID ? 1 : 0,
|
||||||
an_valid & AN0_VALID ? 1 : 0);
|
an_valid & OSI_AN0_VALID ? 1 : 0);
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "sc_index: %d\n",
|
buf += scnprintf(buf, PAGE_SIZE, "sc_index: %d\n",
|
||||||
lut_config.sci_lut_out.sc_index);
|
lut_config.sci_lut_out.sc_index);
|
||||||
memset(&lut_config, 0, sizeof(lut_config));
|
memset(&lut_config, 0, sizeof(lut_config));
|
||||||
@@ -1132,19 +1134,19 @@ static ssize_t macsec_sci_lut_show(struct device *dev,
|
|||||||
|
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Rx:\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Rx:\n");
|
||||||
|
|
||||||
for (i = 0; i <= SC_LUT_MAX_INDEX; i++) {
|
for (i = 0; i <= OSI_SC_LUT_MAX_INDEX; i++) {
|
||||||
memset(&lut_config, OSI_NONE, sizeof(lut_config));
|
memset(&lut_config, OSI_NONE, sizeof(lut_config));
|
||||||
lut_config.table_config.ctlr_sel = CTLR_SEL_RX;
|
lut_config.table_config.ctlr_sel = OSI_CTLR_SEL_RX;
|
||||||
lut_config.lut_sel = LUT_SEL_SCI;
|
lut_config.lut_sel = OSI_LUT_SEL_SCI;
|
||||||
lut_config.table_config.rw = LUT_READ;
|
lut_config.table_config.rw = OSI_LUT_READ;
|
||||||
lut_config.table_config.index = i;
|
lut_config.table_config.index = i;
|
||||||
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
||||||
dev_err(dev, "%s: Failed to read BYP LUT\n", __func__);
|
dev_err(dev, "%s: Failed to read BYP LUT\n", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
} else {
|
} else {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "%d.\t", i);
|
buf += scnprintf(buf, PAGE_SIZE, "%d.\t", i);
|
||||||
if ((lut_config.flags & LUT_FLAGS_ENTRY_VALID) !=
|
if ((lut_config.flags & OSI_LUT_FLAGS_ENTRY_VALID) !=
|
||||||
LUT_FLAGS_ENTRY_VALID) {
|
OSI_LUT_FLAGS_ENTRY_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Invalid\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Invalid\n");
|
||||||
memset(&lut_config, 0, sizeof(lut_config));
|
memset(&lut_config, 0, sizeof(lut_config));
|
||||||
continue;
|
continue;
|
||||||
@@ -1190,9 +1192,9 @@ static ssize_t macsec_sci_lut_store(struct device *dev,
|
|||||||
struct ether_priv_data *pdata = netdev_priv(ndev);
|
struct ether_priv_data *pdata = netdev_priv(ndev);
|
||||||
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
||||||
struct osi_macsec_lut_config lut_config;
|
struct osi_macsec_lut_config lut_config;
|
||||||
int an_valid[MAX_NUM_SA] = {0};
|
int an_valid[OSI_MAX_NUM_SA] = {0};
|
||||||
int ret, bufp;
|
int ret, bufp;
|
||||||
int temp[SCI_LEN];
|
int temp[OSI_SCI_LEN];
|
||||||
int i;
|
int i;
|
||||||
int sc_index;
|
int sc_index;
|
||||||
|
|
||||||
@@ -1217,25 +1219,25 @@ static ssize_t macsec_sci_lut_store(struct device *dev,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
lut_config.lut_sel = LUT_SEL_SCI;
|
lut_config.lut_sel = OSI_LUT_SEL_SCI;
|
||||||
lut_config.table_config.rw = LUT_WRITE;
|
lut_config.table_config.rw = OSI_LUT_WRITE;
|
||||||
/* Rest of LUT attributes are filled by parse_inputs() */
|
/* Rest of LUT attributes are filled by parse_inputs() */
|
||||||
if (lut_config.table_config.index > SC_LUT_MAX_INDEX) {
|
if (lut_config.table_config.index > OSI_SC_LUT_MAX_INDEX) {
|
||||||
dev_err(dev, "%s: Index can't be > %d\n", __func__,
|
dev_err(dev, "%s: Index can't be > %d\n", __func__,
|
||||||
SC_LUT_MAX_INDEX);
|
OSI_SC_LUT_MAX_INDEX);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if (sc_index > SC_LUT_MAX_INDEX) {
|
if (sc_index > OSI_SC_LUT_MAX_INDEX) {
|
||||||
dev_err(dev, "%s: SC Index can't be > %d\n", __func__,
|
dev_err(dev, "%s: SC Index can't be > %d\n", __func__,
|
||||||
SC_LUT_MAX_INDEX);
|
OSI_SC_LUT_MAX_INDEX);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configure the outputs */
|
/* Configure the outputs */
|
||||||
for (i = 0; i < SCI_LEN; i++) {
|
for (i = 0; i < OSI_SCI_LEN; i++) {
|
||||||
lut_config.sci_lut_out.sci[i] = (unsigned char)temp[i];
|
lut_config.sci_lut_out.sci[i] = (unsigned char)temp[i];
|
||||||
}
|
}
|
||||||
for (i = 0; i < MAX_NUM_SA; i++) {
|
for (i = 0; i < OSI_MAX_NUM_SA; i++) {
|
||||||
if (an_valid[i] > OSI_ENABLE) {
|
if (an_valid[i] > OSI_ENABLE) {
|
||||||
dev_err(dev, "%s: an_valid bitmap error\n", __func__);
|
dev_err(dev, "%s: an_valid bitmap error\n", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
@@ -1246,7 +1248,7 @@ static ssize_t macsec_sci_lut_store(struct device *dev,
|
|||||||
lut_config.sci_lut_out.sc_index = sc_index;
|
lut_config.sci_lut_out.sc_index = sc_index;
|
||||||
|
|
||||||
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
||||||
dev_err(dev, "%s: Failed to config BYP LUT\n", __func__);
|
dev_err(dev, "%s: Failed to config SCI LUT\n", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
} else {
|
} else {
|
||||||
dev_err(dev, "%s: Added SCI LUT idx: %d", __func__,
|
dev_err(dev, "%s: Added SCI LUT idx: %d", __func__,
|
||||||
@@ -1273,10 +1275,10 @@ static void dump_kt(char **buf_p, unsigned short ctlr_sel,
|
|||||||
char *buf = *buf_p;
|
char *buf = *buf_p;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
for (i = 0; i <= TABLE_INDEX_MAX; i++) {
|
for (i = 0; i <= OSI_TABLE_INDEX_MAX; i++) {
|
||||||
memset(&kt_config, OSI_NONE, sizeof(kt_config));
|
memset(&kt_config, OSI_NONE, sizeof(kt_config));
|
||||||
kt_config.table_config.ctlr_sel = ctlr_sel;
|
kt_config.table_config.ctlr_sel = ctlr_sel;
|
||||||
kt_config.table_config.rw = LUT_READ;
|
kt_config.table_config.rw = OSI_LUT_READ;
|
||||||
kt_config.table_config.index = i;
|
kt_config.table_config.index = i;
|
||||||
if (osi_macsec_kt_config(osi_core, &kt_config, OSI_NULL) < 0) {
|
if (osi_macsec_kt_config(osi_core, &kt_config, OSI_NULL) < 0) {
|
||||||
pr_err("%s: Failed to read KT\n", __func__);
|
pr_err("%s: Failed to read KT\n", __func__);
|
||||||
@@ -1284,22 +1286,22 @@ static void dump_kt(char **buf_p, unsigned short ctlr_sel,
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "%d.\t", i);
|
buf += scnprintf(buf, PAGE_SIZE, "%d.\t", i);
|
||||||
if ((kt_config.flags & LUT_FLAGS_ENTRY_VALID) !=
|
if ((kt_config.flags & OSI_LUT_FLAGS_ENTRY_VALID) !=
|
||||||
LUT_FLAGS_ENTRY_VALID) {
|
OSI_LUT_FLAGS_ENTRY_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Invalid\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Invalid\n");
|
||||||
memset(&kt_config, 0, sizeof(kt_config));
|
memset(&kt_config, 0, sizeof(kt_config));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "SAK: 0x");
|
buf += scnprintf(buf, PAGE_SIZE, "SAK: 0x");
|
||||||
for (j = 0; j < KEY_LEN_256; j++) {
|
for (j = 0; j < OSI_KEY_LEN_256; j++) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "%02x",
|
buf += scnprintf(buf, PAGE_SIZE, "%02x",
|
||||||
kt_config.entry.sak[KEY_LEN_256 - 1 - j]);
|
kt_config.entry.sak[OSI_KEY_LEN_256 - 1 - j]);
|
||||||
}
|
}
|
||||||
buf += scnprintf(buf, PAGE_SIZE, " H: 0x");
|
buf += scnprintf(buf, PAGE_SIZE, " H: 0x");
|
||||||
for (j = 0; j < KEY_LEN_128; j++) {
|
for (j = 0; j < OSI_KEY_LEN_128; j++) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "%02x",
|
buf += scnprintf(buf, PAGE_SIZE, "%02x",
|
||||||
kt_config.entry.h[KEY_LEN_128 - 1 - j]);
|
kt_config.entry.h[OSI_KEY_LEN_128 - 1 - j]);
|
||||||
}
|
}
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "\n");
|
buf += scnprintf(buf, PAGE_SIZE, "\n");
|
||||||
}
|
}
|
||||||
@@ -1329,7 +1331,7 @@ static ssize_t macsec_tx_kt_show(struct device *dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Tx:\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Tx:\n");
|
||||||
dump_kt(&buf, CTLR_SEL_TX, osi_core);
|
dump_kt(&buf, OSI_CTLR_SEL_TX, osi_core);
|
||||||
|
|
||||||
return (buf - start);
|
return (buf - start);
|
||||||
}
|
}
|
||||||
@@ -1355,7 +1357,7 @@ static ssize_t macsec_rx_kt_show(struct device *dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Rx:\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Rx:\n");
|
||||||
dump_kt(&buf, CTLR_SEL_RX, osi_core);
|
dump_kt(&buf, OSI_CTLR_SEL_RX, osi_core);
|
||||||
|
|
||||||
return (buf - start);
|
return (buf - start);
|
||||||
}
|
}
|
||||||
@@ -1380,11 +1382,11 @@ static ssize_t macsec_kt_store(struct device *dev,
|
|||||||
struct ether_priv_data *pdata = netdev_priv(ndev);
|
struct ether_priv_data *pdata = netdev_priv(ndev);
|
||||||
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
||||||
struct crypto_cipher *tfm;
|
struct crypto_cipher *tfm;
|
||||||
unsigned char hkey[KEY_LEN_128];
|
unsigned char hkey[OSI_KEY_LEN_128];
|
||||||
unsigned char zeros[KEY_LEN_128] = {0};
|
unsigned char zeros[OSI_KEY_LEN_128] = {0};
|
||||||
struct osi_macsec_kt_config kt_config = {0};
|
struct osi_macsec_kt_config kt_config = {0};
|
||||||
int temp[KEY_LEN_256] = {0};
|
int temp[OSI_KEY_LEN_256] = {0};
|
||||||
unsigned char sak[KEY_LEN_256] = {0};
|
unsigned char sak[OSI_KEY_LEN_256] = {0};
|
||||||
|
|
||||||
int valid, index, ctlr, key256bit;
|
int valid, index, ctlr, key256bit;
|
||||||
int i, ret, bufp = 0;
|
int i, ret, bufp = 0;
|
||||||
@@ -1418,20 +1420,20 @@ static ssize_t macsec_kt_store(struct device *dev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((index > TABLE_INDEX_MAX) ||
|
if ((index > OSI_TABLE_INDEX_MAX) ||
|
||||||
(valid != OSI_ENABLE && valid != OSI_DISABLE) ||
|
(valid != OSI_ENABLE && valid != OSI_DISABLE) ||
|
||||||
(ctlr != CTLR_SEL_TX && ctlr != CTLR_SEL_RX)) {
|
(ctlr != OSI_CTLR_SEL_TX && ctlr != OSI_CTLR_SEL_RX)) {
|
||||||
dev_err(pdata->dev, "%s: Invalid inputs\n", __func__);
|
dev_err(pdata->dev, "%s: Invalid inputs\n", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
kt_config.table_config.ctlr_sel = ctlr;
|
kt_config.table_config.ctlr_sel = ctlr;
|
||||||
kt_config.table_config.rw = LUT_WRITE;
|
kt_config.table_config.rw = OSI_LUT_WRITE;
|
||||||
kt_config.table_config.index = index;
|
kt_config.table_config.index = index;
|
||||||
|
|
||||||
/* HKEY GENERATION */
|
/* HKEY GENERATION */
|
||||||
tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
|
tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
|
||||||
if (crypto_cipher_setkey(tfm, sak, KEY_LEN_128)) {
|
if (crypto_cipher_setkey(tfm, sak, OSI_KEY_LEN_128)) {
|
||||||
pr_err("%s: Failed to set cipher key for H generation",
|
pr_err("%s: Failed to set cipher key for H generation",
|
||||||
__func__);
|
__func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
@@ -1439,31 +1441,31 @@ static ssize_t macsec_kt_store(struct device *dev,
|
|||||||
crypto_cipher_encrypt_one(tfm, hkey, zeros);
|
crypto_cipher_encrypt_one(tfm, hkey, zeros);
|
||||||
crypto_free_cipher(tfm);
|
crypto_free_cipher(tfm);
|
||||||
|
|
||||||
for (i = 0; i < KEY_LEN_128; i++) {
|
for (i = 0; i < OSI_KEY_LEN_128; i++) {
|
||||||
sak[i] = (unsigned char)temp[i];
|
sak[i] = (unsigned char)temp[i];
|
||||||
}
|
}
|
||||||
if (key256bit == 1) {
|
if (key256bit == 1) {
|
||||||
for (i = KEY_LEN_128; i < KEY_LEN_256; i++) {
|
for (i = OSI_KEY_LEN_128; i < OSI_KEY_LEN_256; i++) {
|
||||||
sak[i] = (unsigned char)temp[i];
|
sak[i] = (unsigned char)temp[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < KEY_LEN_128; i++) {
|
for (i = 0; i < OSI_KEY_LEN_128; i++) {
|
||||||
kt_config.entry.h[i] = hkey[KEY_LEN_128 - 1 - i];
|
kt_config.entry.h[i] = hkey[OSI_KEY_LEN_128 - 1 - i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key256bit == 1) {
|
if (key256bit == 1) {
|
||||||
for (i = 0; i < KEY_LEN_256; i++) {
|
for (i = 0; i < OSI_KEY_LEN_256; i++) {
|
||||||
kt_config.entry.sak[i] = sak[KEY_LEN_256 - 1 - i];
|
kt_config.entry.sak[i] = sak[OSI_KEY_LEN_256 - 1 - i];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < KEY_LEN_128; i++) {
|
for (i = 0; i < OSI_KEY_LEN_128; i++) {
|
||||||
kt_config.entry.sak[i] = sak[KEY_LEN_128 - 1 - i];
|
kt_config.entry.sak[i] = sak[OSI_KEY_LEN_128 - 1 - i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
kt_config.flags |= LUT_FLAGS_ENTRY_VALID;
|
kt_config.flags |= OSI_LUT_FLAGS_ENTRY_VALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = osi_macsec_kt_config(osi_core, &kt_config, OSI_NULL);
|
ret = osi_macsec_kt_config(osi_core, &kt_config, OSI_NULL);
|
||||||
@@ -1508,12 +1510,12 @@ static void dump_sc_state_lut(char **buf_p, unsigned short ctlr_sel,
|
|||||||
char *buf = *buf_p;
|
char *buf = *buf_p;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i <= SC_LUT_MAX_INDEX; i++) {
|
for (i = 0; i <= OSI_SC_LUT_MAX_INDEX; i++) {
|
||||||
memset(&lut_config, OSI_NONE, sizeof(lut_config));
|
memset(&lut_config, OSI_NONE, sizeof(lut_config));
|
||||||
lut_config.table_config.ctlr_sel = ctlr_sel;
|
lut_config.table_config.ctlr_sel = ctlr_sel;
|
||||||
lut_config.table_config.rw = LUT_READ;
|
lut_config.table_config.rw = OSI_LUT_READ;
|
||||||
lut_config.table_config.index = i;
|
lut_config.table_config.index = i;
|
||||||
lut_config.lut_sel = LUT_SEL_SC_STATE;
|
lut_config.lut_sel = OSI_LUT_SEL_SC_STATE;
|
||||||
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
||||||
pr_err("%s: Failed to read BYP LUT\n", __func__);
|
pr_err("%s: Failed to read BYP LUT\n", __func__);
|
||||||
*buf_p = buf;
|
*buf_p = buf;
|
||||||
@@ -1549,10 +1551,10 @@ static ssize_t macsec_sc_state_lut_show(struct device *dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Tx:\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Tx:\n");
|
||||||
dump_sc_state_lut(&buf, CTLR_SEL_TX, osi_core);
|
dump_sc_state_lut(&buf, OSI_CTLR_SEL_TX, osi_core);
|
||||||
|
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Rx:\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Rx:\n");
|
||||||
dump_sc_state_lut(&buf, CTLR_SEL_RX, osi_core);
|
dump_sc_state_lut(&buf, OSI_CTLR_SEL_RX, osi_core);
|
||||||
|
|
||||||
return (buf - start);
|
return (buf - start);
|
||||||
}
|
}
|
||||||
@@ -1589,18 +1591,17 @@ static ssize_t macsec_sc_state_lut_store(struct device *dev,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((index > SC_LUT_MAX_INDEX) ||
|
if ((index > OSI_SC_LUT_MAX_INDEX) ||
|
||||||
(ctlr != CTLR_SEL_TX && ctlr != CTLR_SEL_RX) ||
|
(ctlr != OSI_CTLR_SEL_TX && ctlr != OSI_CTLR_SEL_RX) ||
|
||||||
(curr_an > CURR_AN_MAX)) {
|
(curr_an > OSI_CURR_AN_MAX)) {
|
||||||
dev_err(pdata->dev, "%s:Invalid inputs", __func__);
|
dev_err(pdata->dev, "%s:Invalid inputs", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO - need to lock. Since lut_status is updated.
|
|
||||||
lut_config.table_config.ctlr_sel = ctlr;
|
lut_config.table_config.ctlr_sel = ctlr;
|
||||||
lut_config.table_config.rw = LUT_WRITE;
|
lut_config.table_config.rw = OSI_LUT_WRITE;
|
||||||
lut_config.table_config.index = index;
|
lut_config.table_config.index = index;
|
||||||
lut_config.lut_sel = LUT_SEL_SC_STATE;
|
lut_config.lut_sel = OSI_LUT_SEL_SC_STATE;
|
||||||
lut_config.sc_state_out.curr_an = curr_an;
|
lut_config.sc_state_out.curr_an = curr_an;
|
||||||
|
|
||||||
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
||||||
@@ -1630,21 +1631,21 @@ static void dump_sa_state_lut(char **buf_p, unsigned short ctlr_sel,
|
|||||||
char *buf = *buf_p;
|
char *buf = *buf_p;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i <= SA_LUT_MAX_INDEX; i++) {
|
for (i = 0; i <= OSI_SA_LUT_MAX_INDEX; i++) {
|
||||||
memset(&lut_config, OSI_NONE, sizeof(lut_config));
|
memset(&lut_config, OSI_NONE, sizeof(lut_config));
|
||||||
lut_config.table_config.ctlr_sel = ctlr_sel;
|
lut_config.table_config.ctlr_sel = ctlr_sel;
|
||||||
lut_config.table_config.rw = LUT_READ;
|
lut_config.table_config.rw = OSI_LUT_READ;
|
||||||
lut_config.table_config.index = i;
|
lut_config.table_config.index = i;
|
||||||
lut_config.lut_sel = LUT_SEL_SA_STATE;
|
lut_config.lut_sel = OSI_LUT_SEL_SA_STATE;
|
||||||
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
||||||
pr_err("%s: Failed to read BYP LUT\n", __func__);
|
pr_err("%s: Failed to read BYP LUT\n", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ctlr_sel) {
|
switch (ctlr_sel) {
|
||||||
case CTLR_SEL_TX:
|
case OSI_CTLR_SEL_TX:
|
||||||
if ((lut_config.flags & LUT_FLAGS_ENTRY_VALID) ==
|
if ((lut_config.flags & OSI_LUT_FLAGS_ENTRY_VALID) ==
|
||||||
LUT_FLAGS_ENTRY_VALID) {
|
OSI_LUT_FLAGS_ENTRY_VALID) {
|
||||||
buf += scnprintf(buf, PAGE_SIZE,
|
buf += scnprintf(buf, PAGE_SIZE,
|
||||||
"%d.\tnext_pn: %d\n", i,
|
"%d.\tnext_pn: %d\n", i,
|
||||||
lut_config.sa_state_out.next_pn);
|
lut_config.sa_state_out.next_pn);
|
||||||
@@ -1653,7 +1654,7 @@ static void dump_sa_state_lut(char **buf_p, unsigned short ctlr_sel,
|
|||||||
"%d.\tInvalid\n", i);
|
"%d.\tInvalid\n", i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CTLR_SEL_RX:
|
case OSI_CTLR_SEL_RX:
|
||||||
buf += scnprintf(buf, PAGE_SIZE,
|
buf += scnprintf(buf, PAGE_SIZE,
|
||||||
"%d.\tnext_pn: %d lowest_pn: %d\n", i,
|
"%d.\tnext_pn: %d lowest_pn: %d\n", i,
|
||||||
lut_config.sa_state_out.next_pn,
|
lut_config.sa_state_out.next_pn,
|
||||||
@@ -1690,10 +1691,10 @@ static ssize_t macsec_sa_state_lut_show(struct device *dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Tx:\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Tx:\n");
|
||||||
dump_sa_state_lut(&buf, CTLR_SEL_TX, osi_core);
|
dump_sa_state_lut(&buf, OSI_CTLR_SEL_TX, osi_core);
|
||||||
|
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Rx:\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Rx:\n");
|
||||||
dump_sa_state_lut(&buf, CTLR_SEL_RX, osi_core);
|
dump_sa_state_lut(&buf, OSI_CTLR_SEL_RX, osi_core);
|
||||||
|
|
||||||
return (buf - start);
|
return (buf - start);
|
||||||
}
|
}
|
||||||
@@ -1731,20 +1732,19 @@ static ssize_t macsec_sa_state_lut_store(struct device *dev,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((index > SA_LUT_MAX_INDEX) ||
|
if ((index > OSI_SA_LUT_MAX_INDEX) ||
|
||||||
(ctlr != CTLR_SEL_TX && ctlr != CTLR_SEL_RX)) {
|
(ctlr != OSI_CTLR_SEL_TX && ctlr != OSI_CTLR_SEL_RX)) {
|
||||||
dev_err(pdata->dev, "%s:Invalid inputs", __func__);
|
dev_err(pdata->dev, "%s:Invalid inputs", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO - need to lock. Since lut_status is updated.
|
lut_config.flags = OSI_LUT_FLAGS_ENTRY_VALID;
|
||||||
lut_config.flags = LUT_FLAGS_ENTRY_VALID;
|
|
||||||
lut_config.table_config.ctlr_sel = ctlr;
|
lut_config.table_config.ctlr_sel = ctlr;
|
||||||
lut_config.table_config.rw = LUT_WRITE;
|
lut_config.table_config.rw = OSI_LUT_WRITE;
|
||||||
lut_config.table_config.index = index;
|
lut_config.table_config.index = index;
|
||||||
lut_config.sa_state_out.next_pn = next_pn;
|
lut_config.sa_state_out.next_pn = next_pn;
|
||||||
lut_config.sa_state_out.lowest_pn = lowest_pn;
|
lut_config.sa_state_out.lowest_pn = lowest_pn;
|
||||||
lut_config.lut_sel = LUT_SEL_SA_STATE;
|
lut_config.lut_sel = OSI_LUT_SEL_SA_STATE;
|
||||||
|
|
||||||
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
||||||
dev_err(dev, "%s: Failed to config SA STATE LUT\n", __func__);
|
dev_err(dev, "%s: Failed to config SA STATE LUT\n", __func__);
|
||||||
@@ -1774,19 +1774,19 @@ static void dump_sc_param_lut(char **buf_p, unsigned short ctlr_sel,
|
|||||||
char *buf = *buf_p;
|
char *buf = *buf_p;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i <= SC_LUT_MAX_INDEX; i++) {
|
for (i = 0; i <= OSI_SC_LUT_MAX_INDEX; i++) {
|
||||||
memset(&lut_config, OSI_NONE, sizeof(lut_config));
|
memset(&lut_config, OSI_NONE, sizeof(lut_config));
|
||||||
lut_config.table_config.ctlr_sel = ctlr_sel;
|
lut_config.table_config.ctlr_sel = ctlr_sel;
|
||||||
lut_config.table_config.rw = LUT_READ;
|
lut_config.table_config.rw = OSI_LUT_READ;
|
||||||
lut_config.table_config.index = i;
|
lut_config.table_config.index = i;
|
||||||
lut_config.lut_sel = LUT_SEL_SC_PARAM;
|
lut_config.lut_sel = OSI_LUT_SEL_SC_PARAM;
|
||||||
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
if (osi_macsec_lut_config(osi_core, &lut_config) < 0) {
|
||||||
pr_err("%s: Failed to read BYP LUT\n", __func__);
|
pr_err("%s: Failed to read BYP LUT\n", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ctlr_sel) {
|
switch (ctlr_sel) {
|
||||||
case CTLR_SEL_TX:
|
case OSI_CTLR_SEL_TX:
|
||||||
buf += scnprintf(buf, PAGE_SIZE,
|
buf += scnprintf(buf, PAGE_SIZE,
|
||||||
"%d.\tkey_idx_start: %d pn_max: %u "
|
"%d.\tkey_idx_start: %d pn_max: %u "
|
||||||
"pn_threshold: %u tci %01x vlan_clear %01x sci: " SCI_FMT,
|
"pn_threshold: %u tci %01x vlan_clear %01x sci: " SCI_FMT,
|
||||||
@@ -1805,7 +1805,7 @@ static void dump_sc_param_lut(char **buf_p, unsigned short ctlr_sel,
|
|||||||
lut_config.sc_param_out.sci[0]);
|
lut_config.sc_param_out.sci[0]);
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "\n");
|
buf += scnprintf(buf, PAGE_SIZE, "\n");
|
||||||
break;
|
break;
|
||||||
case CTLR_SEL_RX:
|
case OSI_CTLR_SEL_RX:
|
||||||
buf += scnprintf(buf, PAGE_SIZE,
|
buf += scnprintf(buf, PAGE_SIZE,
|
||||||
"%d.\tkey_idx_start: %d pn_max: %u pn_window: %u\n", i,
|
"%d.\tkey_idx_start: %d pn_max: %u pn_window: %u\n", i,
|
||||||
lut_config.sc_param_out.key_index_start,
|
lut_config.sc_param_out.key_index_start,
|
||||||
@@ -1843,10 +1843,10 @@ static ssize_t macsec_sc_param_lut_show(struct device *dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Tx:\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Tx:\n");
|
||||||
dump_sc_param_lut(&buf, CTLR_SEL_TX, osi_core);
|
dump_sc_param_lut(&buf, OSI_CTLR_SEL_TX, osi_core);
|
||||||
|
|
||||||
buf += scnprintf(buf, PAGE_SIZE, "Rx:\n");
|
buf += scnprintf(buf, PAGE_SIZE, "Rx:\n");
|
||||||
dump_sc_param_lut(&buf, CTLR_SEL_RX, osi_core);
|
dump_sc_param_lut(&buf, OSI_CTLR_SEL_RX, osi_core);
|
||||||
|
|
||||||
return (buf - start);
|
return (buf - start);
|
||||||
}
|
}
|
||||||
@@ -1873,7 +1873,7 @@ static ssize_t macsec_sc_param_lut_store(struct device *dev,
|
|||||||
struct osi_macsec_lut_config lut_config = {0};
|
struct osi_macsec_lut_config lut_config = {0};
|
||||||
int index, ctlr;
|
int index, ctlr;
|
||||||
int ret, i, tci, vlan_clear;
|
int ret, i, tci, vlan_clear;
|
||||||
int sci[SCI_LEN] = {0};
|
int sci[OSI_SCI_LEN] = {0};
|
||||||
unsigned int pn_max, pn_threshold, key_index_start, pn_window;
|
unsigned int pn_max, pn_threshold, key_index_start, pn_window;
|
||||||
|
|
||||||
if (!netif_running(ndev)) {
|
if (!netif_running(ndev)) {
|
||||||
@@ -1892,26 +1892,25 @@ static ssize_t macsec_sc_param_lut_store(struct device *dev,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((index > SC_LUT_MAX_INDEX) ||
|
if ((index > OSI_SC_LUT_MAX_INDEX) ||
|
||||||
(ctlr != CTLR_SEL_TX && ctlr != CTLR_SEL_RX) ||
|
(ctlr != OSI_CTLR_SEL_TX && ctlr != OSI_CTLR_SEL_RX) ||
|
||||||
(key_index_start > KEY_INDEX_MAX) ||
|
(key_index_start > OSI_KEY_INDEX_MAX) ||
|
||||||
(pn_threshold > pn_max)) {
|
(pn_threshold > pn_max)) {
|
||||||
dev_err(pdata->dev, "%s:Invalid inputs", __func__);
|
dev_err(pdata->dev, "%s:Invalid inputs", __func__);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO - need to lock. Since lut_status is updated.
|
|
||||||
lut_config.table_config.ctlr_sel = ctlr;
|
lut_config.table_config.ctlr_sel = ctlr;
|
||||||
lut_config.table_config.rw = LUT_WRITE;
|
lut_config.table_config.rw = OSI_LUT_WRITE;
|
||||||
lut_config.table_config.index = index;
|
lut_config.table_config.index = index;
|
||||||
lut_config.lut_sel = LUT_SEL_SC_PARAM;
|
lut_config.lut_sel = OSI_LUT_SEL_SC_PARAM;
|
||||||
lut_config.sc_param_out.key_index_start = key_index_start;
|
lut_config.sc_param_out.key_index_start = key_index_start;
|
||||||
lut_config.sc_param_out.pn_max = pn_max;
|
lut_config.sc_param_out.pn_max = pn_max;
|
||||||
lut_config.sc_param_out.pn_threshold = pn_threshold;
|
lut_config.sc_param_out.pn_threshold = pn_threshold;
|
||||||
lut_config.sc_param_out.pn_window = pn_window;
|
lut_config.sc_param_out.pn_window = pn_window;
|
||||||
lut_config.sc_param_out.tci = (unsigned char)tci;
|
lut_config.sc_param_out.tci = (unsigned char)tci;
|
||||||
lut_config.sc_param_out.vlan_in_clear = (unsigned char)vlan_clear;
|
lut_config.sc_param_out.vlan_in_clear = (unsigned char)vlan_clear;
|
||||||
for (i = 0; i < SCI_LEN; i++) {
|
for (i = 0; i < OSI_SCI_LEN; i++) {
|
||||||
lut_config.sc_param_out.sci[i] = (unsigned char)sci[i];
|
lut_config.sc_param_out.sci[i] = (unsigned char)sci[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user