[v2,1/2] net/nfp: add helper functions for read/write 16b values

Message ID 20230310062542.817107-2-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series write link speed to control BAR |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He March 10, 2023, 6:25 a.m. UTC
  From: James Hershaw <james.hershaw@corigine.com>

Expand the selection of read/write helper functions to include values of
16 bits.

Signed-off-by: James Hershaw <james.hershaw@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/nfp_common.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
  

Patch

diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h
index 4486ffa72c..3a8b023c75 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_common.h
@@ -283,6 +283,11 @@  static inline void nn_writel(uint32_t val, volatile void *addr)
 	rte_write32(val, addr);
 }
 
+static inline uint16_t nn_readw(volatile const void *addr)
+{
+	return rte_read16(addr);
+}
+
 static inline void nn_writew(uint16_t val, volatile void *addr)
 {
 	rte_write16(val, addr);
@@ -321,6 +326,18 @@  nn_cfg_writeb(struct nfp_net_hw *hw, int off, uint8_t val)
 	nn_writeb(val, hw->ctrl_bar + off);
 }
 
+static inline uint16_t
+nn_cfg_readw(struct nfp_net_hw *hw, int off)
+{
+	return rte_le_to_cpu_16(nn_readw(hw->ctrl_bar + off));
+}
+
+static inline void
+nn_cfg_writew(struct nfp_net_hw *hw, int off, uint16_t val)
+{
+	nn_writew(rte_cpu_to_le_16(val), hw->ctrl_bar + off);
+}
+
 static inline uint32_t
 nn_cfg_readl(struct nfp_net_hw *hw, int off)
 {