Skip to contentSkip to conversation

rdma: prepare for const netdev->dev_addr

PATCH Applied Jakub Kicinski 4 participants 12 messages Oct 19, 2021 – Oct 25, 2021

Subsystems (8)
lore
Share & tools
lore
author maintainer
#1 lore raw

PATCH 1/3 ipoib: use dev_addr_mod()

In reply to Jakub Kicinski

Commit 406f42fa0d3c ("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintain netdev->dev_addr in this tree we need to make all the writes to it got through appropriate helpers.

---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 drivers/infiniband/ulp/ipoib/ipoib_cm.c   |  4 +++-
 drivers/infiniband/ulp/ipoib/ipoib_ib.c   |  9 ++++-----
 drivers/infiniband/ulp/ipoib/ipoib_main.c | 17 +++++++++--------
 3 files changed, 16 insertions(+), 14 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib_cm.c +3 -1
index 684c2ddb16f5..fd9d7f2c4d64 100644
@@ -1583,6 +1583,7 @@ int ipoib_cm_dev_init(struct net_device *dev)
 {
 	struct ipoib_dev_priv *priv = ipoib_priv(dev);
 	int max_srq_sge, i;
+	u8 addr;
 
 	INIT_LIST_HEAD(&priv->cm.passive_ids);
 	INIT_LIST_HEAD(&priv->cm.reap_list);
@@ -1636,7 +1637,8 @@ int ipoib_cm_dev_init(struct net_device *dev)
 		}
 	}
 
-	priv->dev->dev_addr[0] = IPOIB_FLAGS_RC;
+	addr = IPOIB_FLAGS_RC;
+	dev_addr_mod(dev, 0, &addr, 1);
 	return 0;
 }
 
drivers/infiniband/ulp/ipoib/ipoib_ib.c +4 -5
index ceabfb0b0a83..2c3dca41d3bd 100644
@@ -1057,13 +1057,11 @@ static bool ipoib_dev_addr_changed_valid(struct ipoib_dev_priv *priv)
 {
 	union ib_gid search_gid;
 	union ib_gid gid0;
-	union ib_gid *netdev_gid;
 	int err;
 	u16 index;
 	u32 port;
 	bool ret = false;
 
-	netdev_gid = (union ib_gid *)(priv->dev->dev_addr + 4);
 	if (rdma_query_gid(priv->ca, priv->port, 0, &gid0))
 		return false;
 
@@ -1073,7 +1071,8 @@ static bool ipoib_dev_addr_changed_valid(struct ipoib_dev_priv *priv)
 	 * to do it later
 	 */
 	priv->local_gid.global.subnet_prefix = gid0.global.subnet_prefix;
-	netdev_gid->global.subnet_prefix = gid0.global.subnet_prefix;
+	dev_addr_mod(priv->dev, 4, (u8 *)&gid0.global.subnet_prefix,
+		     sizeof(gid0.global.subnet_prefix));
 	search_gid.global.subnet_prefix = gid0.global.subnet_prefix;
 
 	search_gid.global.interface_id = priv->local_gid.global.interface_id;
@@ -1135,8 +1134,8 @@ static bool ipoib_dev_addr_changed_valid(struct ipoib_dev_priv *priv)
 			if (!test_bit(IPOIB_FLAG_DEV_ADDR_CTRL, &priv->flags)) {
 				memcpy(&priv->local_gid, &gid0,
 				       sizeof(priv->local_gid));
-				memcpy(priv->dev->dev_addr + 4, &gid0,
-				       sizeof(priv->local_gid));
+				dev_addr_mod(priv->dev, 4, (u8 *)&gid0,
+					     sizeof(priv->local_gid));
 				ret = true;
 			}
 		}
drivers/infiniband/ulp/ipoib/ipoib_main.c +9 -8
index 9c9da5aa592a..9934b8bd7f56 100644
@@ -1696,6 +1696,7 @@ static void ipoib_dev_uninit_default(struct net_device *dev)
 static int ipoib_dev_init_default(struct net_device *dev)
 {
 	struct ipoib_dev_priv *priv = ipoib_priv(dev);
+	u8 addr_mod[3];
 
 	ipoib_napi_add(dev);
 
@@ -1723,9 +1724,10 @@ static int ipoib_dev_init_default(struct net_device *dev)
 	}
 
 	/* after qp created set dev address */
-	priv->dev->dev_addr[1] = (priv->qp->qp_num >> 16) & 0xff;
-	priv->dev->dev_addr[2] = (priv->qp->qp_num >>  8) & 0xff;
-	priv->dev->dev_addr[3] = (priv->qp->qp_num) & 0xff;
+	addr_mod[0] = (priv->qp->qp_num >> 16) & 0xff;
+	addr_mod[1] = (priv->qp->qp_num >>  8) & 0xff;
+	addr_mod[2] = (priv->qp->qp_num) & 0xff;
+	dev_addr_mod(priv->dev, 1, addr_mod, sizeof(addr_mod));
 
 	return 0;
 
@@ -1886,8 +1888,7 @@ static int ipoib_parent_init(struct net_device *ndev)
 			priv->ca->name, priv->port, result);
 		return result;
 	}
-	memcpy(priv->dev->dev_addr + 4, priv->local_gid.raw,
-	       sizeof(union ib_gid));
+	dev_addr_mod(priv->dev, 4, priv->local_gid.raw, sizeof(union ib_gid));
 
 	SET_NETDEV_DEV(priv->dev, priv->ca->dev.parent);
 	priv->dev->dev_port = priv->port - 1;
@@ -1908,8 +1909,8 @@ static void ipoib_child_init(struct net_device *ndev)
 		memcpy(&priv->local_gid, priv->dev->dev_addr + 4,
 		       sizeof(priv->local_gid));
 	else {
-		memcpy(priv->dev->dev_addr, ppriv->dev->dev_addr,
-		       INFINIBAND_ALEN);
+		__dev_addr_set(priv->dev, ppriv->dev->dev_addr,
+			       INFINIBAND_ALEN);
 		memcpy(&priv->local_gid, &ppriv->local_gid,
 		       sizeof(priv->local_gid));
 	}
@@ -2326,7 +2327,7 @@ static void set_base_guid(struct ipoib_dev_priv *priv, union ib_gid *gid)
 	memcpy(&priv->local_gid.global.interface_id,
 	       &gid->global.interface_id,
 	       sizeof(gid->global.interface_id));
-	memcpy(netdev->dev_addr + 4, &priv->local_gid, sizeof(priv->local_gid));
+	dev_addr_mod(netdev, 4, (u8 *)&priv->local_gid, sizeof(priv->local_gid));
 	clear_bit(IPOIB_FLAG_DEV_ADDR_SET, &priv->flags);
 
 	netif_addr_unlock_bh(netdev);
Signature · 1 line
2.31.1

Jakub Kicinski

author maintainer
#0 lore raw

cover rdma: prepare for const netdev->dev_addr

Hi!

These are RDMA changes needed to make netdev->dev_addr const. These can go via rdma-next.

Jakub Kicinski (3):
ipoib: use dev_addr_mod()
mlx5: use dev_addr_mod()
RDMA: constify netdev->dev_addr accesses

 drivers/infiniband/hw/bnxt_re/qplib_res.c       |  2 +-
 drivers/infiniband/hw/bnxt_re/qplib_res.h       |  2 +-
 drivers/infiniband/hw/bnxt_re/qplib_sp.c        |  6 +++---
 drivers/infiniband/hw/bnxt_re/qplib_sp.h        |  5 +++--
 drivers/infiniband/hw/hfi1/ipoib_main.c         |  2 +-
 drivers/infiniband/hw/hns/hns_roce_device.h     |  3 ++-
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c      | 10 +++++-----
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c      |  6 +++---
 drivers/infiniband/hw/hns/hns_roce_main.c       |  3 ++-
 drivers/infiniband/hw/irdma/cm.h                |  4 ++--
 drivers/infiniband/hw/irdma/hw.c                |  7 ++++---
 drivers/infiniband/hw/irdma/main.h              |  5 +++--
 drivers/infiniband/hw/irdma/trace_cm.h          |  8 +++++---
 drivers/infiniband/hw/irdma/utils.c             |  4 ++--
 drivers/infiniband/hw/irdma/verbs.c             |  2 +-
 drivers/infiniband/hw/usnic/usnic_fwd.c         |  2 +-
 drivers/infiniband/hw/usnic/usnic_fwd.h         |  2 +-
 drivers/infiniband/ulp/ipoib/ipoib_cm.c         |  4 +++-
 drivers/infiniband/ulp/ipoib/ipoib_ib.c         |  9 ++++-----
 drivers/infiniband/ulp/ipoib/ipoib_main.c       | 17 +++++++++--------
 .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c   |  8 +++++---
 21 files changed, 61 insertions(+), 50 deletions(-)
Signature · 1 line
2.31.1
author maintainer
#8 lore raw

PATCH 3/3 RDMA: constify netdev->dev_addr accesses

netdev->dev_addr will become const soon, make sure drivers propagate the qualifier.

---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 drivers/infiniband/hw/bnxt_re/qplib_res.c   |  2 +-
 drivers/infiniband/hw/bnxt_re/qplib_res.h   |  2 +-
 drivers/infiniband/hw/bnxt_re/qplib_sp.c    |  6 +++---
 drivers/infiniband/hw/bnxt_re/qplib_sp.h    |  5 +++--
 drivers/infiniband/hw/hfi1/ipoib_main.c     |  2 +-
 drivers/infiniband/hw/hns/hns_roce_device.h |  3 ++-
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c  | 10 +++++-----
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  |  6 +++---
 drivers/infiniband/hw/hns/hns_roce_main.c   |  3 ++-
 drivers/infiniband/hw/irdma/cm.h            |  4 ++--
 drivers/infiniband/hw/irdma/hw.c            |  7 ++++---
 drivers/infiniband/hw/irdma/main.h          |  5 +++--
 drivers/infiniband/hw/irdma/trace_cm.h      |  8 +++++---
 drivers/infiniband/hw/irdma/utils.c         |  4 ++--
 drivers/infiniband/hw/irdma/verbs.c         |  2 +-
 drivers/infiniband/hw/usnic/usnic_fwd.c     |  2 +-
 drivers/infiniband/hw/usnic/usnic_fwd.h     |  2 +-
 17 files changed, 40 insertions(+), 33 deletions(-)
drivers/infiniband/hw/bnxt_re/qplib_res.c +1 -1
index bf49363f590e..a1d8a87dc678 100644
@@ -573,7 +573,7 @@ int bnxt_qplib_alloc_ctx(struct bnxt_qplib_res *res,
 }
 
 /* GUID */
-void bnxt_qplib_get_guid(u8 *dev_addr, u8 *guid)
+void bnxt_qplib_get_guid(const u8 *dev_addr, u8 *guid)
 {
 	u8 mac[ETH_ALEN];
 
drivers/infiniband/hw/bnxt_re/qplib_res.h +1 -1
index c39b20236f16..d2951a713cc8 100644
@@ -346,7 +346,7 @@ void bnxt_qplib_free_hwq(struct bnxt_qplib_res *res,
 			 struct bnxt_qplib_hwq *hwq);
 int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq,
 			      struct bnxt_qplib_hwq_attr *hwq_attr);
-void bnxt_qplib_get_guid(u8 *dev_addr, u8 *guid);
+void bnxt_qplib_get_guid(const u8 *dev_addr, u8 *guid);
 int bnxt_qplib_alloc_pd(struct bnxt_qplib_pd_tbl *pd_tbl,
 			struct bnxt_qplib_pd *pd);
 int bnxt_qplib_dealloc_pd(struct bnxt_qplib_res *res,
drivers/infiniband/hw/bnxt_re/qplib_sp.c +3 -3
index cbe83e9bce5c..379e715ebd30 100644
@@ -287,8 +287,8 @@ int bnxt_qplib_del_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
 }
 
 int bnxt_qplib_add_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
-			struct bnxt_qplib_gid *gid, u8 *smac, u16 vlan_id,
-			bool update, u32 *index)
+			struct bnxt_qplib_gid *gid, const u8 *smac,
+			u16 vlan_id, bool update, u32 *index)
 {
 	struct bnxt_qplib_res *res = to_bnxt_qplib(sgid_tbl,
 						   struct bnxt_qplib_res,
@@ -379,7 +379,7 @@ int bnxt_qplib_add_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
 
 int bnxt_qplib_update_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
 			   struct bnxt_qplib_gid *gid, u16 gid_idx,
-			   u8 *smac)
+			   const u8 *smac)
 {
 	struct bnxt_qplib_res *res = to_bnxt_qplib(sgid_tbl,
 						   struct bnxt_qplib_res,
drivers/infiniband/hw/bnxt_re/qplib_sp.h +3 -2
index 3d5c41841668..a18f568cb23e 100644
@@ -250,10 +250,11 @@ int bnxt_qplib_get_sgid(struct bnxt_qplib_res *res,
 int bnxt_qplib_del_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
 			struct bnxt_qplib_gid *gid, u16 vlan_id, bool update);
 int bnxt_qplib_add_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
-			struct bnxt_qplib_gid *gid, u8 *mac, u16 vlan_id,
+			struct bnxt_qplib_gid *gid, const u8 *mac, u16 vlan_id,
 			bool update, u32 *index);
 int bnxt_qplib_update_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
-			   struct bnxt_qplib_gid *gid, u16 gid_idx, u8 *smac);
+			   struct bnxt_qplib_gid *gid, u16 gid_idx,
+			   const u8 *smac);
 int bnxt_qplib_get_pkey(struct bnxt_qplib_res *res,
 			struct bnxt_qplib_pkey_tbl *pkey_tbl, u16 index,
 			u16 *pkey);
drivers/infiniband/hw/hfi1/ipoib_main.c +1 -1
index e594a961f513..e1a2b02bbd91 100644
@@ -11,7 +11,7 @@
 #include "ipoib.h"
 #include "hfi.h"
 
-static u32 qpn_from_mac(u8 *mac_arr)
+static u32 qpn_from_mac(const u8 *mac_arr)
 {
 	return (u32)mac_arr[1] << 16 | mac_arr[2] << 8 | mac_arr[3];
 }
drivers/infiniband/hw/hns/hns_roce_device.h +2 -1
index 9467c39e3d28..e5dadcd118ac 100644
@@ -898,7 +898,8 @@ struct hns_roce_hw {
 	bool (*chk_mbox_avail)(struct hns_roce_dev *hr_dev, bool *is_busy);
 	int (*set_gid)(struct hns_roce_dev *hr_dev, u32 port, int gid_index,
 		       const union ib_gid *gid, const struct ib_gid_attr *attr);
-	int (*set_mac)(struct hns_roce_dev *hr_dev, u8 phy_port, u8 *addr);
+	int (*set_mac)(struct hns_roce_dev *hr_dev, u8 phy_port,
+		       const u8 *addr);
 	void (*set_mtu)(struct hns_roce_dev *hr_dev, u8 phy_port,
 			enum ib_mtu mtu);
 	int (*write_mtpt)(struct hns_roce_dev *hr_dev, void *mb_buf,
drivers/infiniband/hw/hns/hns_roce_hw_v1.c +5 -5
index e0f59b8d7d5d..f4af3992ba95 100644
@@ -90,11 +90,11 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp,
 	unsigned long flags = 0;
 	void *wqe = NULL;
 	__le32 doorbell[2];
+	const u8 *smac;
 	int ret = 0;
 	int loopback;
 	u32 wqe_idx;
 	int nreq;
-	u8 *smac;
 
 	if (unlikely(ibqp->qp_type != IB_QPT_GSI &&
 		ibqp->qp_type != IB_QPT_RC)) {
@@ -154,7 +154,7 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp,
 				       UD_SEND_WQE_U32_8_DMAC_5_S,
 				       ah->av.mac[5]);
 
-			smac = (u8 *)hr_dev->dev_addr[qp->port];
+			smac = (const u8 *)hr_dev->dev_addr[qp->port];
 			loopback = ether_addr_equal_unaligned(ah->av.mac,
 							      smac) ? 1 : 0;
 			roce_set_bit(ud_sq_wqe->u32_8,
@@ -1782,7 +1782,7 @@ static int hns_roce_v1_set_gid(struct hns_roce_dev *hr_dev, u32 port,
 }
 
 static int hns_roce_v1_set_mac(struct hns_roce_dev *hr_dev, u8 phy_port,
-			       u8 *addr)
+			       const u8 *addr)
 {
 	u32 reg_smac_l;
 	u16 reg_smac_h;
@@ -2743,12 +2743,12 @@ static int hns_roce_v1_m_qp(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
 	__le32 doorbell[2] = {0};
 	u64 *mtts_2 = NULL;
 	int ret = -EINVAL;
+	const u8 *smac;
 	u64 sq_ba = 0;
 	u64 rq_ba = 0;
 	u32 port;
 	u32 port_num;
 	u8 *dmac;
-	u8 *smac;
 
 	if (!check_qp_state(cur_state, new_state)) {
 		ibdev_err(ibqp->device,
@@ -2947,7 +2947,7 @@ static int hns_roce_v1_m_qp(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
 
 		port = (attr_mask & IB_QP_PORT) ? (attr->port_num - 1) :
 			hr_qp->port;
-		smac = (u8 *)hr_dev->dev_addr[port];
+		smac = (const u8 *)hr_dev->dev_addr[port];
 		/* when dmac equals smac or loop_idc is 1, it should loopback */
 		if (ether_addr_equal_unaligned(dmac, smac) ||
 		    hr_dev->loop_idc == 0x1)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +3 -3
index 91990fad7185..c2916b170a41 100644
@@ -2982,7 +2982,7 @@ static int hns_roce_v2_set_gid(struct hns_roce_dev *hr_dev, u32 port,
 }
 
 static int hns_roce_v2_set_mac(struct hns_roce_dev *hr_dev, u8 phy_port,
-			       u8 *addr)
+			       const u8 *addr)
 {
 	struct hns_roce_cmq_desc desc;
 	struct hns_roce_cfg_smac_tb *smac_tb =
@@ -4308,10 +4308,10 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
 	dma_addr_t trrl_ba;
 	dma_addr_t irrl_ba;
 	enum ib_mtu ib_mtu;
+	const u8 *smac;
 	u8 lp_pktn_ini;
 	u64 *mtts;
 	u8 *dmac;
-	u8 *smac;
 	u32 port;
 	int mtu;
 	int ret;
@@ -4364,7 +4364,7 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
 
 	port = (attr_mask & IB_QP_PORT) ? (attr->port_num - 1) : hr_qp->port;
 
-	smac = (u8 *)hr_dev->dev_addr[port];
+	smac = (const u8 *)hr_dev->dev_addr[port];
 	dmac = (u8 *)attr->ah_attr.roce.dmac;
 	/* when dmac equals smac or loop_idc is 1, it should loopback */
 	if (ether_addr_equal_unaligned(dmac, smac) ||
drivers/infiniband/hw/hns/hns_roce_main.c +2 -1
index 5d39bd08582a..b3595b6079b5 100644
@@ -42,7 +42,8 @@
 #include "hns_roce_device.h"
 #include "hns_roce_hem.h"
 
-static int hns_roce_set_mac(struct hns_roce_dev *hr_dev, u32 port, u8 *addr)
+static int hns_roce_set_mac(struct hns_roce_dev *hr_dev, u32 port,
+			    const u8 *addr)
 {
 	u8 phy_port;
 	u32 i;
drivers/infiniband/hw/irdma/cm.h +2 -2
index 1fbe72e18625..3bf42728e9b7 100644
@@ -389,7 +389,7 @@ int irdma_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len);
 int irdma_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);
 int irdma_create_listen(struct iw_cm_id *cm_id, int backlog);
 int irdma_destroy_listen(struct iw_cm_id *cm_id);
-int irdma_add_arp(struct irdma_pci_f *rf, u32 *ip, bool ipv4, u8 *mac);
+int irdma_add_arp(struct irdma_pci_f *rf, u32 *ip, bool ipv4, const u8 *mac);
 void irdma_cm_teardown_connections(struct irdma_device *iwdev, u32 *ipaddr,
 				   struct irdma_cm_info *nfo,
 				   bool disconnect_all);
@@ -398,7 +398,7 @@ int irdma_cm_stop(struct irdma_device *dev);
 bool irdma_ipv4_is_lpb(u32 loc_addr, u32 rem_addr);
 bool irdma_ipv6_is_lpb(u32 *loc_addr, u32 *rem_addr);
 int irdma_arp_table(struct irdma_pci_f *rf, u32 *ip_addr, bool ipv4,
-		    u8 *mac_addr, u32 action);
+		    const u8 *mac_addr, u32 action);
 void irdma_if_notify(struct irdma_device *iwdev, struct net_device *netdev,
 		     u32 *ipaddr, bool ipv4, bool ifup);
 bool irdma_port_in_use(struct irdma_cm_core *cm_core, u16 port);
drivers/infiniband/hw/irdma/hw.c +4 -3
index 7de525a5ccf8..4108dcabece2 100644
@@ -1057,7 +1057,7 @@ static enum irdma_status_code irdma_alloc_set_mac(struct irdma_device *iwdev)
 					     &iwdev->mac_ip_table_idx);
 	if (!status) {
 		status = irdma_add_local_mac_entry(iwdev->rf,
-						   (u8 *)iwdev->netdev->dev_addr,
+						   (const u8 *)iwdev->netdev->dev_addr,
 						   (u8)iwdev->mac_ip_table_idx);
 		if (status)
 			irdma_del_local_mac_entry(iwdev->rf,
@@ -2191,7 +2191,7 @@ void irdma_del_local_mac_entry(struct irdma_pci_f *rf, u16 idx)
  * @mac_addr: pointer to mac address
  * @idx: the index of the mac ip address to add
  */
-int irdma_add_local_mac_entry(struct irdma_pci_f *rf, u8 *mac_addr, u16 idx)
+int irdma_add_local_mac_entry(struct irdma_pci_f *rf, const u8 *mac_addr, u16 idx)
 {
 	struct irdma_local_mac_entry_info *info;
 	struct irdma_cqp *iwcqp = &rf->cqp;
@@ -2362,7 +2362,8 @@ void irdma_del_apbvt(struct irdma_device *iwdev,
  * @ipv4: flag inicating IPv4
  * @action: add, delete or modify
  */
-void irdma_manage_arp_cache(struct irdma_pci_f *rf, unsigned char *mac_addr,
+void irdma_manage_arp_cache(struct irdma_pci_f *rf,
+			    const unsigned char *mac_addr,
 			    u32 *ip_addr, bool ipv4, u32 action)
 {
 	struct irdma_add_arp_cache_entry_info *info;
drivers/infiniband/hw/irdma/main.h +3 -2
index b678fe712447..91a497139ba3 100644
@@ -467,7 +467,8 @@ void irdma_qp_rem_ref(struct ib_qp *ibqp);
 void irdma_free_lsmm_rsrc(struct irdma_qp *iwqp);
 struct ib_qp *irdma_get_qp(struct ib_device *ibdev, int qpn);
 void irdma_flush_wqes(struct irdma_qp *iwqp, u32 flush_mask);
-void irdma_manage_arp_cache(struct irdma_pci_f *rf, unsigned char *mac_addr,
+void irdma_manage_arp_cache(struct irdma_pci_f *rf,
+			    const unsigned char *mac_addr,
 			    u32 *ip_addr, bool ipv4, u32 action);
 struct irdma_apbvt_entry *irdma_add_apbvt(struct irdma_device *iwdev, u16 port);
 void irdma_del_apbvt(struct irdma_device *iwdev,
@@ -479,7 +480,7 @@ void irdma_free_cqp_request(struct irdma_cqp *cqp,
 void irdma_put_cqp_request(struct irdma_cqp *cqp,
 			   struct irdma_cqp_request *cqp_request);
 int irdma_alloc_local_mac_entry(struct irdma_pci_f *rf, u16 *mac_tbl_idx);
-int irdma_add_local_mac_entry(struct irdma_pci_f *rf, u8 *mac_addr, u16 idx);
+int irdma_add_local_mac_entry(struct irdma_pci_f *rf, const u8 *mac_addr, u16 idx);
 void irdma_del_local_mac_entry(struct irdma_pci_f *rf, u16 idx);
 
 u32 irdma_initialize_hw_rsrc(struct irdma_pci_f *rf);
drivers/infiniband/hw/irdma/trace_cm.h +5 -3
index bcf10ec427d6..f633fb343328 100644
@@ -144,7 +144,7 @@ DEFINE_EVENT(tos_template, irdma_dcb_tos,
 DECLARE_EVENT_CLASS(qhash_template,
 		    TP_PROTO(struct irdma_device *iwdev,
 			     struct irdma_cm_listener *listener,
-			     char *dev_addr),
+			     const char *dev_addr),
 		    TP_ARGS(iwdev, listener, dev_addr),
 		    TP_STRUCT__entry(__field(struct irdma_device *, iwdev)
 				     __field(u16, lport)
@@ -173,12 +173,14 @@ DECLARE_EVENT_CLASS(qhash_template,
 
 DEFINE_EVENT(qhash_template, irdma_add_mqh_6,
 	     TP_PROTO(struct irdma_device *iwdev,
-		      struct irdma_cm_listener *listener, char *dev_addr),
+		      struct irdma_cm_listener *listener,
+		      const char *dev_addr),
 	     TP_ARGS(iwdev, listener, dev_addr));
 
 DEFINE_EVENT(qhash_template, irdma_add_mqh_4,
 	     TP_PROTO(struct irdma_device *iwdev,
-		      struct irdma_cm_listener *listener, char *dev_addr),
+		      struct irdma_cm_listener *listener,
+		      const char *dev_addr),
 	     TP_ARGS(iwdev, listener, dev_addr));
 
 TRACE_EVENT(irdma_addr_resolve,
drivers/infiniband/hw/irdma/utils.c +2 -2
index 0ebce57e8756..8b42c43fc14f 100644
@@ -11,7 +11,7 @@
  * @action: modify, delete or add
  */
 int irdma_arp_table(struct irdma_pci_f *rf, u32 *ip_addr, bool ipv4,
-		    u8 *mac_addr, u32 action)
+		    const u8 *mac_addr, u32 action)
 {
 	unsigned long flags;
 	int arp_index;
@@ -77,7 +77,7 @@ int irdma_arp_table(struct irdma_pci_f *rf, u32 *ip_addr, bool ipv4,
  * @ipv4: IPv4 flag
  * @mac: MAC address
  */
-int irdma_add_arp(struct irdma_pci_f *rf, u32 *ip, bool ipv4, u8 *mac)
+int irdma_add_arp(struct irdma_pci_f *rf, u32 *ip, bool ipv4, const u8 *mac)
 {
 	int arpidx;
 
drivers/infiniband/hw/irdma/verbs.c +1 -1
index 6a544c253603..aa38ace15c07 100644
@@ -4326,7 +4326,7 @@ static enum rdma_link_layer irdma_get_link_layer(struct ib_device *ibdev,
 
 static __be64 irdma_mac_to_guid(struct net_device *ndev)
 {
-	unsigned char *mac = ndev->dev_addr;
+	const unsigned char *mac = ndev->dev_addr;
 	__be64 guid;
 	unsigned char *dst = (unsigned char *)&guid;
 
drivers/infiniband/hw/usnic/usnic_fwd.c +1 -1
index 398c4c00b932..18a70850b738 100644
@@ -103,7 +103,7 @@ void usnic_fwd_dev_free(struct usnic_fwd_dev *ufdev)
 	kfree(ufdev);
 }
 
-void usnic_fwd_set_mac(struct usnic_fwd_dev *ufdev, char mac[ETH_ALEN])
+void usnic_fwd_set_mac(struct usnic_fwd_dev *ufdev, const char mac[ETH_ALEN])
 {
 	spin_lock(&ufdev->lock);
 	memcpy(&ufdev->mac, mac, sizeof(ufdev->mac));
drivers/infiniband/hw/usnic/usnic_fwd.h +1 -1
index f0b71d593da5..a91200886922 100644
@@ -74,7 +74,7 @@ struct usnic_filter_action {
 struct usnic_fwd_dev *usnic_fwd_dev_alloc(struct pci_dev *pdev);
 void usnic_fwd_dev_free(struct usnic_fwd_dev *ufdev);
 
-void usnic_fwd_set_mac(struct usnic_fwd_dev *ufdev, char mac[ETH_ALEN]);
+void usnic_fwd_set_mac(struct usnic_fwd_dev *ufdev, const char mac[ETH_ALEN]);
 void usnic_fwd_add_ipaddr(struct usnic_fwd_dev *ufdev, __be32 inaddr);
 void usnic_fwd_del_ipaddr(struct usnic_fwd_dev *ufdev);
 void usnic_fwd_carrier_up(struct usnic_fwd_dev *ufdev);
Signature · 1 line
2.31.1
author maintainer
#3 lore raw

PATCH 2/3 mlx5: use dev_addr_mod()

In reply to Jakub Kicinski

Commit 406f42fa0d3c ("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintain netdev->dev_addr in this tree we need to make all the writes to it got through appropriate helpers.

---
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +5 -3
index 67571e5040d6..fe76c27835ae 100644
@@ -472,11 +472,13 @@ int mlx5i_dev_init(struct net_device *dev)
 {
 	struct mlx5e_priv    *priv   = mlx5i_epriv(dev);
 	struct mlx5i_priv    *ipriv  = priv->ppriv;
+	u8 addr_mod[3];
 
 	/* Set dev address using underlay QP */
-	dev->dev_addr[1] = (ipriv->qpn >> 16) & 0xff;
-	dev->dev_addr[2] = (ipriv->qpn >>  8) & 0xff;
-	dev->dev_addr[3] = (ipriv->qpn) & 0xff;
+	addr_mod[0] = (ipriv->qpn >> 16) & 0xff;
+	addr_mod[1] = (ipriv->qpn >>  8) & 0xff;
+	addr_mod[2] = (ipriv->qpn) & 0xff;
+	dev_addr_mod(dev, 1, addr_mod, sizeof(addr_mod));
 
 	/* Add QPN to net-device mapping to HT */
 	mlx5i_pkey_add_qpn(dev, ipriv->qpn);
Signature · 1 line
2.31.1
#4 lore raw

Re: [PATCH rdma-next 2/3] mlx5: use dev_addr_mod()

Quoted 22 lines · Jakub Kicinski

Commit 406f42fa0d3c ("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintain netdev->dev_addr in this tree we need to make all the writes to it got through appropriate helpers.

---
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +0 -0
index 67571e5040d6..fe76c27835ae 100644
@@ -472,11 +472,13 @@ int mlx5i_dev_init(struct net_device *dev)
 {
 	struct mlx5e_priv    *priv   = mlx5i_epriv(dev);
 	struct mlx5i_priv    *ipriv  = priv->ppriv;

drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c int mlx5i_dev_init(struct net_device *dev) · line 481

Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +5 -3
+	u8 addr_mod[3];
 
 	/* Set dev address using underlay QP */
-	dev->dev_addr[1] = (ipriv->qpn >> 16) & 0xff;
-	dev->dev_addr[2] = (ipriv->qpn >>  8) & 0xff;
-	dev->dev_addr[3] = (ipriv->qpn) & 0xff;
+	addr_mod[0] = (ipriv->qpn >> 16) & 0xff;
+	addr_mod[1] = (ipriv->qpn >>  8) & 0xff;
+	addr_mod[2] = (ipriv->qpn) & 0xff;
+	dev_addr_mod(dev, 1, addr_mod, sizeof(addr_mod));
                         ^^^ It should be 0, no?
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +0 -0
 	/* Add QPN to net-device mapping to HT */
 	mlx5i_pkey_add_qpn(dev, ipriv->qpn);
Signature · 1 line
2.31.1
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH rdma-next 1/3] ipoib: use dev_addr_mod()

In reply to Jakub Kicinski
Quoted 17 lines · Jakub Kicinski

Commit 406f42fa0d3c ("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintain netdev->dev_addr in this tree we need to make all the writes to it got through appropriate helpers.

---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]

Quoted 6 lines
---
 drivers/infiniband/ulp/ipoib/ipoib_cm.c   |  4 +++-
 drivers/infiniband/ulp/ipoib/ipoib_ib.c   |  9 ++++-----
 drivers/infiniband/ulp/ipoib/ipoib_main.c | 17 +++++++++--------
 3 files changed, 16 insertions(+), 14 deletions(-)

Thanks,

Reviewed-by on v1 3/3
#9 lore raw

Re: [PATCH rdma-next 3/3] RDMA: constify netdev->dev_addr accesses

In reply to Jakub Kicinski
Quoted 27 lines · Jakub Kicinski

netdev->dev_addr will become const soon, make sure drivers propagate the qualifier.

---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 drivers/infiniband/hw/bnxt_re/qplib_res.c   |  2 +-
 drivers/infiniband/hw/bnxt_re/qplib_res.h   |  2 +-
 drivers/infiniband/hw/bnxt_re/qplib_sp.c    |  6 +++---
 drivers/infiniband/hw/bnxt_re/qplib_sp.h    |  5 +++--
 drivers/infiniband/hw/hfi1/ipoib_main.c     |  2 +-
 drivers/infiniband/hw/hns/hns_roce_device.h |  3 ++-
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c  | 10 +++++-----
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  |  6 +++---
 drivers/infiniband/hw/hns/hns_roce_main.c   |  3 ++-
 drivers/infiniband/hw/irdma/cm.h            |  4 ++--
Quoted 9 lines
 drivers/infiniband/hw/irdma/hw.c            |  7 ++++---
 drivers/infiniband/hw/irdma/main.h          |  5 +++--
 drivers/infiniband/hw/irdma/trace_cm.h      |  8 +++++---
 drivers/infiniband/hw/irdma/utils.c         |  4 ++--
 drivers/infiniband/hw/irdma/verbs.c         |  2 +-
 drivers/infiniband/hw/usnic/usnic_fwd.c     |  2 +-
 drivers/infiniband/hw/usnic/usnic_fwd.h     |  2 +-
 17 files changed, 40 insertions(+), 33 deletions(-)

Thanks,

maintainer Acked-by on v1 3/3
#10 lore raw

Re: [PATCH rdma-next 3/3] RDMA: constify netdev->dev_addr accesses

In reply to Jakub Kicinski
Quoted 27 lines · Jakub Kicinski

netdev->dev_addr will become const soon, make sure drivers propagate the qualifier.

---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 drivers/infiniband/hw/bnxt_re/qplib_res.c   |  2 +-
 drivers/infiniband/hw/bnxt_re/qplib_res.h   |  2 +-
 drivers/infiniband/hw/bnxt_re/qplib_sp.c    |  6 +++---
 drivers/infiniband/hw/bnxt_re/qplib_sp.h    |  5 +++--
 drivers/infiniband/hw/hfi1/ipoib_main.c     |  2 +-
 drivers/infiniband/hw/hns/hns_roce_device.h |  3 ++-
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c  | 10 +++++-----
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  |  6 +++---
 drivers/infiniband/hw/hns/hns_roce_main.c   |  3 ++-
 drivers/infiniband/hw/irdma/cm.h            |  4 ++--
Quoted 8 lines
 drivers/infiniband/hw/irdma/hw.c            |  7 ++++---
 drivers/infiniband/hw/irdma/main.h          |  5 +++--
 drivers/infiniband/hw/irdma/trace_cm.h      |  8 +++++---
 drivers/infiniband/hw/irdma/utils.c         |  4 ++--
 drivers/infiniband/hw/irdma/verbs.c         |  2 +-
 drivers/infiniband/hw/usnic/usnic_fwd.c     |  2 +-
 drivers/infiniband/hw/usnic/usnic_fwd.h     |  2 +-
 17 files changed, 40 insertions(+), 33 deletions(-)

For hfi1:

author maintainer
#5 lore raw

Re: [PATCH rdma-next 2/3] mlx5: use dev_addr_mod()

In reply to Leon Romanovsky
Quoted 1 line · On Thu, 21 Oct 2021 12:49:53 +0300 Leon Romanovsky wrote:

drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c int mlx5i_dev_init(struct net_device *dev) · line 477

Quoted 1 line
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +0 -1
-	dev->dev_addr[1] = (ipriv->qpn >> 16) & 0xff;

^ the original modifies starting at offset 1

Quoted 7 lines

drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c int mlx5i_dev_init(struct net_device *dev) · line 481

Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +4 -2
-	dev->dev_addr[2] = (ipriv->qpn >>  8) & 0xff;
-	dev->dev_addr[3] = (ipriv->qpn) & 0xff;
+	addr_mod[0] = (ipriv->qpn >> 16) & 0xff;
+	addr_mod[1] = (ipriv->qpn >>  8) & 0xff;
+	addr_mod[2] = (ipriv->qpn) & 0xff;
+	dev_addr_mod(dev, 1, addr_mod, sizeof(addr_mod));  
                         ^^^ It should be 0, no?
#6 lore raw

Re: [PATCH rdma-next 2/3] mlx5: use dev_addr_mod()

Quoted 4 lines · Jakub Kicinski
Quoted 1 line · On Thu, 21 Oct 2021 12:49:53 +0300 Leon Romanovsky wrote:

drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c int mlx5i_dev_init(struct net_device *dev) · line 477

Quoted 1 line
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +0 -1
-	dev->dev_addr[1] = (ipriv->qpn >> 16) & 0xff;

^ the original modifies starting at offset 1

Ahh, right.

Quoted 8 lines
Quoted 8 lines

drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c int mlx5i_dev_init(struct net_device *dev) · line 481

Quoted 7 lines
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +4 -2
-	dev->dev_addr[2] = (ipriv->qpn >>  8) & 0xff;
-	dev->dev_addr[3] = (ipriv->qpn) & 0xff;
+	addr_mod[0] = (ipriv->qpn >> 16) & 0xff;
+	addr_mod[1] = (ipriv->qpn >>  8) & 0xff;
+	addr_mod[2] = (ipriv->qpn) & 0xff;
+	dev_addr_mod(dev, 1, addr_mod, sizeof(addr_mod));  
                         ^^^ It should be 0, no?
Reviewed-by on v1 2/3
#7 lore raw

Re: [PATCH rdma-next 2/3] mlx5: use dev_addr_mod()

In reply to Jakub Kicinski
Quoted 5 lines · Jakub Kicinski

Commit 406f42fa0d3c ("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintain netdev->dev_addr in this tree we need to make all the writes to it got through appropriate helpers.

Quoted 9 lines

---
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Thanks,

maintainer Applied
#11 lore raw
In reply to Jakub Kicinski
Quoted 9 lines · Jakub Kicinski

Hi!

These are RDMA changes needed to make netdev->dev_addr const. These can go via rdma-next.

Jakub Kicinski (3):
ipoib: use dev_addr_mod()
mlx5: use dev_addr_mod()
RDMA: constify netdev->dev_addr accesses

Applied to for-next, thanks

Jason