Re: [dpdk-dev] [PATCH v3] net/ixgbe: Add access and locking APIs for MDIO

2018-04-13 Thread Shweta Choudaha
Hi Qi,

   I have addressed your comments and sent a v4 patchset.

Thanks,
Shweta

On Fri, Apr 13, 2018 at 3:37 AM, Zhang, Qi Z  wrote:

> Hi Choudaha:
>
> > -Original Message-
> > From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Shweta Choudaha
> > Sent: Wednesday, April 11, 2018 10:00 PM
> > To: dev@dpdk.org
> > Cc: Lu, Wenzhuo ; Ananyev, Konstantin
> > ; Zhang, Helin ;
> Yigit,
> > Ferruh ; shweta.choud...@att.com
> > Subject: [dpdk-dev] [PATCH v3] net/ixgbe: Add access and locking APIs for
> > MDIO
>
> Nitpick: title should not start with uppercase.
>
> > +
> > +EXPERIMENTAL {
> > + global:
> > +
> > + rte_pmd_ixgbe_lock_mdio;
> > + rte_pmd_ixgbe_unlock_mdio;
>
> Can we rename to rte_pmd_ixgbe_mdio_lock and rte_pmd_ixgbe_mdio_unlock, so
> all mdio functions can be list closely when follow the alphabet sequence?
>
>
> > + rte_pmd_ixgbe_mdio_read_unlocked;
> > + rte_pmd_ixgbe_mdio_write_unlocked;
>
> And this could be rte_pmd_ixgbe_mdio_unlocked_read/write to follow the
> same pattern that action after object
>
> Regards
> Qi
>
> > +} DPDK_18.05;
> > --
> > 2.11.0
>
>


Re: [dpdk-dev] [PATCH v3] net/ixgbe: Add access and locking APIs for MDIO

2018-04-12 Thread Zhang, Qi Z
Hi Choudaha:

> -Original Message-
> From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Shweta Choudaha
> Sent: Wednesday, April 11, 2018 10:00 PM
> To: dev@dpdk.org
> Cc: Lu, Wenzhuo ; Ananyev, Konstantin
> ; Zhang, Helin ; Yigit,
> Ferruh ; shweta.choud...@att.com
> Subject: [dpdk-dev] [PATCH v3] net/ixgbe: Add access and locking APIs for
> MDIO

Nitpick: title should not start with uppercase.

> +
> +EXPERIMENTAL {
> + global:
> +
> + rte_pmd_ixgbe_lock_mdio;
> + rte_pmd_ixgbe_unlock_mdio;

Can we rename to rte_pmd_ixgbe_mdio_lock and rte_pmd_ixgbe_mdio_unlock, so all 
mdio functions can be list closely when follow the alphabet sequence?


> + rte_pmd_ixgbe_mdio_read_unlocked;
> + rte_pmd_ixgbe_mdio_write_unlocked;

And this could be rte_pmd_ixgbe_mdio_unlocked_read/write to follow the same 
pattern that action after object

Regards
Qi

> +} DPDK_18.05;
> --
> 2.11.0



[dpdk-dev] [PATCH v3] net/ixgbe: Add access and locking APIs for MDIO

2018-04-11 Thread Shweta Choudaha
From: Shweta Choudaha 

Add ixgbe MDIO lock/unlock and access APIs to read and write registers
using specific device address. This provides MDIO access to any devices
that are not associated with the autoprobed PHY.Export these APIs via
the map file

Signed-off-by: Shweta Choudaha 
Reviewed-by: Chas Williams 
Reviewed-by: Luca Boccassi 
---
 drivers/net/ixgbe/rte_pmd_ixgbe.c   | 202 
 drivers/net/ixgbe/rte_pmd_ixgbe.h   |  71 ++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |   9 ++
 3 files changed, 282 insertions(+)

diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe.c 
b/drivers/net/ixgbe/rte_pmd_ixgbe.c
index d8ca8ca31..b028dd401 100644
--- a/drivers/net/ixgbe/rte_pmd_ixgbe.c
+++ b/drivers/net/ixgbe/rte_pmd_ixgbe.c
@@ -5,6 +5,7 @@
 #include 
 
 #include "base/ixgbe_api.h"
+#include "base/ixgbe_x550.h"
 #include "ixgbe_ethdev.h"
 #include "rte_pmd_ixgbe.h"
 
@@ -1012,3 +1013,204 @@ rte_pmd_ixgbe_bypass_wd_reset(uint16_t port_id)
return ixgbe_bypass_wd_reset(dev);
 }
 #endif
+
+/**
+ *  rte_pmd_ixgbe_acquire_swfw - Acquire SWFW semaphore
+ *  @hw: pointer to hardware structure
+ *  @mask: Mask to specify which semaphore to acquire
+ *
+ *  Acquires the SWFW semaphore and get the shared phy token as needed
+ */
+STATIC s32 rte_pmd_ixgbe_acquire_swfw(struct ixgbe_hw *hw, u32 mask)
+{
+   int retries = FW_PHY_TOKEN_RETRIES;
+   s32 status = IXGBE_SUCCESS;
+
+   while (--retries) {
+   status = ixgbe_acquire_swfw_semaphore(hw, mask);
+   if (status) {
+   PMD_DRV_LOG(ERR, "Get SWFW sem failed, Status = %d\n",
+   status);
+   return status;
+   }
+   status = ixgbe_get_phy_token(hw);
+   if (status == IXGBE_SUCCESS)
+   return IXGBE_SUCCESS;
+
+   if (status == IXGBE_ERR_TOKEN_RETRY)
+   PMD_DRV_LOG(ERR, "Get PHY token failed, Status = %d\n",
+   status);
+
+   ixgbe_release_swfw_semaphore(hw, mask);
+   if (status != IXGBE_ERR_TOKEN_RETRY) {
+   PMD_DRV_LOG(ERR,
+   "Retry get PHY token failed, Status=%d\n",
+   status);
+   return status;
+   }
+   }
+   PMD_DRV_LOG(ERR, "swfw acquisition retries failed!: PHY ID = 0x%08X\n",
+   hw->phy.id);
+   return status;
+}
+
+/**
+ *  rte_pmd_ixgbe_release_swfw_sync - Release SWFW semaphore
+ *  @hw: pointer to hardware structure
+ *  @mask: Mask to specify which semaphore to release
+ *
+ *  Releases the SWFW semaphore and puts the shared phy token as needed
+ */
+STATIC void rte_pmd_ixgbe_release_swfw(struct ixgbe_hw *hw, u32 mask)
+{
+   ixgbe_put_phy_token(hw);
+   ixgbe_release_swfw_semaphore(hw, mask);
+}
+
+int __rte_experimental
+rte_pmd_ixgbe_lock_mdio(uint16_t port)
+{
+   struct ixgbe_hw *hw;
+   struct rte_eth_dev *dev;
+   u32 swfw_mask;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+   dev = &rte_eth_devices[port];
+   if (!is_ixgbe_supported(dev))
+   return -ENOTSUP;
+
+   hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   if (!hw)
+   return -ENOTSUP;
+
+   if (hw->bus.lan_id)
+   swfw_mask = IXGBE_GSSR_PHY1_SM;
+   else
+   swfw_mask = IXGBE_GSSR_PHY0_SM;
+
+   if (rte_pmd_ixgbe_acquire_swfw(hw, swfw_mask))
+   return IXGBE_ERR_SWFW_SYNC;
+
+   return IXGBE_SUCCESS;
+}
+
+int __rte_experimental
+rte_pmd_ixgbe_unlock_mdio(uint16_t port)
+{
+   struct rte_eth_dev *dev;
+   struct ixgbe_hw *hw;
+   u32 swfw_mask;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+   dev = &rte_eth_devices[port];
+   if (!is_ixgbe_supported(dev))
+   return -ENOTSUP;
+
+   hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   if (!hw)
+   return -ENOTSUP;
+
+   if (hw->bus.lan_id)
+   swfw_mask = IXGBE_GSSR_PHY1_SM;
+   else
+   swfw_mask = IXGBE_GSSR_PHY0_SM;
+
+   rte_pmd_ixgbe_release_swfw(hw, swfw_mask);
+
+   return IXGBE_SUCCESS;
+}
+
+int __rte_experimental
+rte_pmd_ixgbe_mdio_read_unlocked(uint16_t port, uint32_t reg_addr,
+uint32_t dev_type, uint16_t *phy_data)
+{
+   struct ixgbe_hw *hw;
+   struct rte_eth_dev *dev;
+   u32 i, data, command;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+   dev = &rte_eth_devices[port];
+   if (!is_ixgbe_supported(dev))
+   return -ENOTSUP;
+
+   hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   if (!hw)
+   return -ENOTSUP;
+
+   /* Setup and write the read command */
+   command = (reg_addr << IXGBE_MSCA_DEV_TYPE_SHIFT) |
+ (