net/ixgbe: fix MAC security private API
Checks
Commit Message
The driver type need to be checked in private API.
The patch fixes the issue.
Fixes: 50556c88104c ("net/ixgbe: fix MACsec setting")
Cc: stable@dpdk.org
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
---
drivers/net/ixgbe/ixgbe_ethdev.c | 14 ++++++++++++--
drivers/net/ixgbe/ixgbe_ethdev.h | 4 ++--
drivers/net/ixgbe/rte_pmd_ixgbe.c | 10 ++++++----
3 files changed, 20 insertions(+), 8 deletions(-)
Comments
Hi,
Do you copy the commit log of the other patch? I think this patch don't touch any private API.
Qiming
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Guinan Sun
> Sent: Friday, May 22, 2020 12:40
> To: dev@dpdk.org
> Cc: Zhao1, Wei <wei.zhao1@intel.com>; Sun, GuinanX
> <guinanx.sun@intel.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] net/ixgbe: fix MAC security private API
>
> The driver type need to be checked in private API.
> The patch fixes the issue.
>
> Fixes: 50556c88104c ("net/ixgbe: fix MACsec setting")
> Cc: stable@dpdk.org
>
> Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
> ---
> drivers/net/ixgbe/ixgbe_ethdev.c | 14 ++++++++++++--
> drivers/net/ixgbe/ixgbe_ethdev.h | 4 ++--
> drivers/net/ixgbe/rte_pmd_ixgbe.c | 10 ++++++----
> 3 files changed, 20 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c
> b/drivers/net/ixgbe/ixgbe_ethdev.c
> index f8a84c565..3e9c0f895 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -8988,7 +8988,7 @@ ixgbe_dev_macsec_setting_reset(struct
> rte_eth_dev *dev)
> macsec->replayprotect_en = 0;
> }
>
> -void
> +int
> ixgbe_dev_macsec_register_enable(struct rte_eth_dev *dev,
> struct ixgbe_macsec_setting
> *macsec_setting) { @@ -8997,6 +8997,9 @@
> ixgbe_dev_macsec_register_enable(struct rte_eth_dev *dev,
> uint8_t en = macsec_setting->encrypt_en;
> uint8_t rp = macsec_setting->replayprotect_en;
>
> + if (!is_ixgbe_supported(dev))
> + return -ENOTSUP;
> +
> /**
> * Workaround:
> * As no ixgbe_disable_sec_rx_path equivalent is @@ -9057,14
> +9060,19 @@ ixgbe_dev_macsec_register_enable(struct rte_eth_dev *dev,
> * just call the hand-written one directly for now.
> */
> ixgbe_enable_sec_tx_path_generic(hw);
> +
> + return 0;
> }
>
> -void
> +int
> ixgbe_dev_macsec_register_disable(struct rte_eth_dev *dev) {
> struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data-
> >dev_private);
> uint32_t ctrl;
>
> + if (!is_ixgbe_supported(dev))
> + return -ENOTSUP;
> +
> /**
> * Workaround:
> * As no ixgbe_disable_sec_rx_path equivalent is @@ -9106,6
> +9114,8 @@ ixgbe_dev_macsec_register_disable(struct rte_eth_dev *dev)
> * just call the hand-written one directly for now.
> */
> ixgbe_enable_sec_tx_path_generic(hw);
> +
> + return 0;
> }
>
> RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd); diff --git
> a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
> index 3d78b2ee2..c14cadab4 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.h
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.h
> @@ -755,10 +755,10 @@ int ixgbe_action_rss_same(const struct
> rte_flow_action_rss *comp, int ixgbe_config_rss_filter(struct rte_eth_dev
> *dev,
> struct ixgbe_rte_flow_rss_conf *conf, bool add);
>
> -void ixgbe_dev_macsec_register_enable(struct rte_eth_dev *dev,
> +int ixgbe_dev_macsec_register_enable(struct rte_eth_dev *dev,
> struct ixgbe_macsec_setting *macsec_setting);
>
> -void ixgbe_dev_macsec_register_disable(struct rte_eth_dev *dev);
> +int ixgbe_dev_macsec_register_disable(struct rte_eth_dev *dev);
>
> void ixgbe_dev_macsec_setting_save(struct rte_eth_dev *dev,
> struct ixgbe_macsec_setting *macsec_setting); diff --git
> a/drivers/net/ixgbe/rte_pmd_ixgbe.c b/drivers/net/ixgbe/rte_pmd_ixgbe.c
> index 8bcaded6e..40cc7058f 100644
> --- a/drivers/net/ixgbe/rte_pmd_ixgbe.c
> +++ b/drivers/net/ixgbe/rte_pmd_ixgbe.c
> @@ -517,6 +517,7 @@ rte_pmd_ixgbe_macsec_enable(uint16_t port,
> uint8_t en, uint8_t rp) {
> struct rte_eth_dev *dev;
> struct ixgbe_macsec_setting macsec_setting;
> + int ret = 0;
>
> RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
>
> @@ -528,15 +529,16 @@ rte_pmd_ixgbe_macsec_enable(uint16_t port,
> uint8_t en, uint8_t rp)
>
> ixgbe_dev_macsec_setting_save(dev, &macsec_setting);
>
> - ixgbe_dev_macsec_register_enable(dev, &macsec_setting);
> + ret = ixgbe_dev_macsec_register_enable(dev, &macsec_setting);
>
> - return 0;
> + return ret;
> }
>
> int
> rte_pmd_ixgbe_macsec_disable(uint16_t port) {
> struct rte_eth_dev *dev;
> + int ret = 0;
>
> RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
>
> @@ -544,9 +546,9 @@ rte_pmd_ixgbe_macsec_disable(uint16_t port)
>
> ixgbe_dev_macsec_setting_reset(dev);
>
> - ixgbe_dev_macsec_register_disable(dev);
> + ret = ixgbe_dev_macsec_register_disable(dev);
>
> - return 0;
> + return ret;
> }
>
> int
> --
> 2.17.1
@@ -8988,7 +8988,7 @@ ixgbe_dev_macsec_setting_reset(struct rte_eth_dev *dev)
macsec->replayprotect_en = 0;
}
-void
+int
ixgbe_dev_macsec_register_enable(struct rte_eth_dev *dev,
struct ixgbe_macsec_setting *macsec_setting)
{
@@ -8997,6 +8997,9 @@ ixgbe_dev_macsec_register_enable(struct rte_eth_dev *dev,
uint8_t en = macsec_setting->encrypt_en;
uint8_t rp = macsec_setting->replayprotect_en;
+ if (!is_ixgbe_supported(dev))
+ return -ENOTSUP;
+
/**
* Workaround:
* As no ixgbe_disable_sec_rx_path equivalent is
@@ -9057,14 +9060,19 @@ ixgbe_dev_macsec_register_enable(struct rte_eth_dev *dev,
* just call the hand-written one directly for now.
*/
ixgbe_enable_sec_tx_path_generic(hw);
+
+ return 0;
}
-void
+int
ixgbe_dev_macsec_register_disable(struct rte_eth_dev *dev)
{
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
uint32_t ctrl;
+ if (!is_ixgbe_supported(dev))
+ return -ENOTSUP;
+
/**
* Workaround:
* As no ixgbe_disable_sec_rx_path equivalent is
@@ -9106,6 +9114,8 @@ ixgbe_dev_macsec_register_disable(struct rte_eth_dev *dev)
* just call the hand-written one directly for now.
*/
ixgbe_enable_sec_tx_path_generic(hw);
+
+ return 0;
}
RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd);
@@ -755,10 +755,10 @@ int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp,
int ixgbe_config_rss_filter(struct rte_eth_dev *dev,
struct ixgbe_rte_flow_rss_conf *conf, bool add);
-void ixgbe_dev_macsec_register_enable(struct rte_eth_dev *dev,
+int ixgbe_dev_macsec_register_enable(struct rte_eth_dev *dev,
struct ixgbe_macsec_setting *macsec_setting);
-void ixgbe_dev_macsec_register_disable(struct rte_eth_dev *dev);
+int ixgbe_dev_macsec_register_disable(struct rte_eth_dev *dev);
void ixgbe_dev_macsec_setting_save(struct rte_eth_dev *dev,
struct ixgbe_macsec_setting *macsec_setting);
@@ -517,6 +517,7 @@ rte_pmd_ixgbe_macsec_enable(uint16_t port, uint8_t en, uint8_t rp)
{
struct rte_eth_dev *dev;
struct ixgbe_macsec_setting macsec_setting;
+ int ret = 0;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
@@ -528,15 +529,16 @@ rte_pmd_ixgbe_macsec_enable(uint16_t port, uint8_t en, uint8_t rp)
ixgbe_dev_macsec_setting_save(dev, &macsec_setting);
- ixgbe_dev_macsec_register_enable(dev, &macsec_setting);
+ ret = ixgbe_dev_macsec_register_enable(dev, &macsec_setting);
- return 0;
+ return ret;
}
int
rte_pmd_ixgbe_macsec_disable(uint16_t port)
{
struct rte_eth_dev *dev;
+ int ret = 0;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
@@ -544,9 +546,9 @@ rte_pmd_ixgbe_macsec_disable(uint16_t port)
ixgbe_dev_macsec_setting_reset(dev);
- ixgbe_dev_macsec_register_disable(dev);
+ ret = ixgbe_dev_macsec_register_disable(dev);
- return 0;
+ return ret;
}
int