From: Tiwei Bie Date: Tue, 24 Jan 2017 09:00:49 +0000 (+0800) Subject: net/ixgbe: fix API parameter checking X-Git-Tag: spdx-start~4605 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=d2b46fd1357f5a33698711e26be0835b41add542;p=dpdk.git net/ixgbe: fix API parameter checking Add checks to rte_pmd_ixgbe_macsec_* APIs to ensure that the port is an ixgbe port. Fixes: b35d309710fe ("net/ixgbe: add MACsec offload") Cc: stable@dpdk.org Signed-off-by: Tiwei Bie --- diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 4f30ad6405..64ce55ab2d 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -8227,10 +8227,15 @@ rte_pmd_ixgbe_macsec_enable(uint8_t port, uint8_t en, uint8_t rp) { struct ixgbe_hw *hw; struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; uint32_t ctrl; RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); + rte_eth_dev_info_get(port, &dev_info); + if (is_ixgbe_pmd(dev_info.driver_name) != 0) + return -ENOTSUP; + dev = &rte_eth_devices[port]; hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -8306,10 +8311,15 @@ rte_pmd_ixgbe_macsec_disable(uint8_t port) { struct ixgbe_hw *hw; struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; uint32_t ctrl; RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); + rte_eth_dev_info_get(port, &dev_info); + if (is_ixgbe_pmd(dev_info.driver_name) != 0) + return -ENOTSUP; + dev = &rte_eth_devices[port]; hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -8366,10 +8376,15 @@ rte_pmd_ixgbe_macsec_config_txsc(uint8_t port, uint8_t *mac) { struct ixgbe_hw *hw; struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; uint32_t ctrl; RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); + rte_eth_dev_info_get(port, &dev_info); + if (is_ixgbe_pmd(dev_info.driver_name) != 0) + return -ENOTSUP; + dev = &rte_eth_devices[port]; hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -8387,10 +8402,15 @@ rte_pmd_ixgbe_macsec_config_rxsc(uint8_t port, uint8_t *mac, uint16_t pi) { struct ixgbe_hw *hw; struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; uint32_t ctrl; RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); + rte_eth_dev_info_get(port, &dev_info); + if (is_ixgbe_pmd(dev_info.driver_name) != 0) + return -ENOTSUP; + dev = &rte_eth_devices[port]; hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -8410,10 +8430,15 @@ rte_pmd_ixgbe_macsec_select_txsa(uint8_t port, uint8_t idx, uint8_t an, { struct ixgbe_hw *hw; struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; uint32_t ctrl, i; RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); + rte_eth_dev_info_get(port, &dev_info); + if (is_ixgbe_pmd(dev_info.driver_name) != 0) + return -ENOTSUP; + dev = &rte_eth_devices[port]; hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -8462,10 +8487,15 @@ rte_pmd_ixgbe_macsec_select_rxsa(uint8_t port, uint8_t idx, uint8_t an, { struct ixgbe_hw *hw; struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; uint32_t ctrl, i; RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); + rte_eth_dev_info_get(port, &dev_info); + if (is_ixgbe_pmd(dev_info.driver_name) != 0) + return -ENOTSUP; + dev = &rte_eth_devices[port]; hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe.h b/drivers/net/ixgbe/rte_pmd_ixgbe.h index dade57ae9f..d4efe07c78 100644 --- a/drivers/net/ixgbe/rte_pmd_ixgbe.h +++ b/drivers/net/ixgbe/rte_pmd_ixgbe.h @@ -222,6 +222,7 @@ int rte_pmd_ixgbe_macsec_disable(uint8_t port); * @return * - (0) if successful. * - (-ENODEV) if *port* invalid. + * - (-ENOTSUP) if hardware doesn't support this feature. */ int rte_pmd_ixgbe_macsec_config_txsc(uint8_t port, uint8_t *mac); @@ -237,6 +238,7 @@ int rte_pmd_ixgbe_macsec_config_txsc(uint8_t port, uint8_t *mac); * @return * - (0) if successful. * - (-ENODEV) if *port* invalid. + * - (-ENOTSUP) if hardware doesn't support this feature. */ int rte_pmd_ixgbe_macsec_config_rxsc(uint8_t port, uint8_t *mac, uint16_t pi); @@ -256,6 +258,7 @@ int rte_pmd_ixgbe_macsec_config_rxsc(uint8_t port, uint8_t *mac, uint16_t pi); * @return * - (0) if successful. * - (-ENODEV) if *port* invalid. + * - (-ENOTSUP) if hardware doesn't support this feature. * - (-EINVAL) if bad parameter. */ int rte_pmd_ixgbe_macsec_select_txsa(uint8_t port, uint8_t idx, uint8_t an, @@ -277,6 +280,7 @@ int rte_pmd_ixgbe_macsec_select_txsa(uint8_t port, uint8_t idx, uint8_t an, * @return * - (0) if successful. * - (-ENODEV) if *port* invalid. + * - (-ENOTSUP) if hardware doesn't support this feature. * - (-EINVAL) if bad parameter. */ int rte_pmd_ixgbe_macsec_select_rxsa(uint8_t port, uint8_t idx, uint8_t an,