RDMA: Constify netdev->dev_addr accesses
authorJakub Kicinski <kuba@kernel.org>
Tue, 19 Oct 2021 18:26:04 +0000 (11:26 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 25 Oct 2021 17:33:09 +0000 (14:33 -0300)
netdev->dev_addr will become const soon, make sure drivers propagate the
qualifier.

Link: https://lore.kernel.org/r/20211019182604.1441387-4-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
17 files changed:
drivers/infiniband/hw/bnxt_re/qplib_res.c
drivers/infiniband/hw/bnxt_re/qplib_res.h
drivers/infiniband/hw/bnxt_re/qplib_sp.c
drivers/infiniband/hw/bnxt_re/qplib_sp.h
drivers/infiniband/hw/hfi1/ipoib_main.c
drivers/infiniband/hw/hns/hns_roce_device.h
drivers/infiniband/hw/hns/hns_roce_hw_v1.c
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/hns/hns_roce_main.c
drivers/infiniband/hw/irdma/cm.h
drivers/infiniband/hw/irdma/hw.c
drivers/infiniband/hw/irdma/main.h
drivers/infiniband/hw/irdma/trace_cm.h
drivers/infiniband/hw/irdma/utils.c
drivers/infiniband/hw/irdma/verbs.c
drivers/infiniband/hw/usnic/usnic_fwd.c
drivers/infiniband/hw/usnic/usnic_fwd.h

index bf49363f590e6d8ccc2c7930467de6d615bf3e3b..a1d8a87dc678c38fed72c0f87bdcabc7b88309f9 100644 (file)
@@ -573,7 +573,7 @@ fail:
 }
 
 /* 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];
 
index c39b20236f16d0647189558f41348ab72077e8b2..d2951a713cc824d7417241b9d37e46f4f0cc9ee8 100644 (file)
@@ -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,
index cbe83e9bce5cfd345dcf506c0beb315a0dfada43..379e715ebd30a7f67f7f2c4c057b9623ff32441a 100644 (file)
@@ -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,
index 3d5c418416682e878c290ccef91ae0dce0dac68e..a18f568cb23e08fabe8fab45324333e060064e6d 100644 (file)
@@ -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);
index e594a961f513e2e4a4c3c77426e43f2c3addf0f5..e1a2b02bbd91bea1323f006436639e1ed5cfa2d6 100644 (file)
@@ -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];
 }
index 9467c39e3d2884021243ddba3aa305ad9494670d..e5dadcd118acbc6c78dfbf00faee328fc116e992 100644 (file)
@@ -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,
index e0f59b8d7d5d6d3e98496eb5eff17743244a72b8..f4af3992ba955375dd649021113cc7e05272cd55 100644 (file)
@@ -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)
index 91990fad718561778774f09a6bd8c29bad3f949f..c2916b170a41c7be98d361706dcafa524f99d3dc 100644 (file)
@@ -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) ||
index 5d39bd08582afda61b12579d2460fa59b5f77d61..b3595b6079b554dc11781d1eb479fd7966538d4c 100644 (file)
@@ -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;
index 1fbe72e18625e1558e400c3d5c6f410ca8d736fc..3bf42728e9b7b9b554a745b37714dfeb07af7c63 100644 (file)
@@ -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);
index 7de525a5ccf8c9a6d72f5c92d6fe05098325bb9b..4108dcabece2390229ff3efd014a1551cccfb6e8 100644 (file)
@@ -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;
index b678fe712447e1bf0126574f12eacee6716c2d34..91a497139ba3a690af37f75c5342480d43c7b8d3 100644 (file)
@@ -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);
index bcf10ec427d6499c0c81d3b7d3297da510719d65..f633fb3433288b041cd3bf5b6923e802bc48b9e4 100644 (file)
@@ -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,
index 0ebce57e87562b41d022d2a6fa7c4b52befd62e0..8b42c43fc14fe89dfd504c90edffcf9975daa464 100644 (file)
@@ -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;
 
index 6a544c2536035426e391e944d6e2dcec94adb7a9..aa38ace15c07268b16e99f8db366d3b5c60f9d2b 100644 (file)
@@ -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;
 
index 398c4c00b932d392494a9ab8b199ad64e95b968b..18a70850b738ea38a386ae5242bfb3ef46dc8fb9 100644 (file)
@@ -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));
index f0b71d593da54b753e702505fab36fef0c4ac7a5..a912008869226695467d675e94abced18b2d3a70 100644 (file)
@@ -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);