From patchwork Tue Jan 24 09:00:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiwei Bie X-Patchwork-Id: 19932 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B4D1E5589; Tue, 24 Jan 2017 10:06:18 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 324B52BE9 for ; Tue, 24 Jan 2017 10:06:13 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 24 Jan 2017 01:06:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,277,1477983600"; d="scan'208";a="216921430" Received: from dpdk19.sh.intel.com ([10.239.129.113]) by fmsmga004.fm.intel.com with ESMTP; 24 Jan 2017 01:06:11 -0800 From: Tiwei Bie To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 24 Jan 2017 17:00:49 +0800 Message-Id: <1485248449-50774-2-git-send-email-tiwei.bie@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485248449-50774-1-git-send-email-tiwei.bie@intel.com> References: <1485248449-50774-1-git-send-email-tiwei.bie@intel.com> Subject: [dpdk-dev] [PATCH v1] net/ixgbe: fix API parameter checking X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add checks to rte_pmd_ixgbe_macsec_* APIs to ensure that the port is an ixgbe port. Fixes: b35d309710fe ("net/ixgbe: add MACsec offload") Signed-off-by: Tiwei Bie --- drivers/net/ixgbe/ixgbe_ethdev.c | 30 ++++++++++++++++++++++++++++++ drivers/net/ixgbe/rte_pmd_ixgbe.h | 4 ++++ 2 files changed, 34 insertions(+) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index ad63e5a..58a4a2e 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -8222,10 +8222,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); @@ -8301,10 +8306,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); @@ -8361,10 +8371,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); @@ -8382,10 +8397,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); @@ -8405,10 +8425,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); @@ -8457,10 +8482,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 dade57a..d4efe07 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,