Commit e7ff98ae authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

RDMA/cma: Constify path record, ib_cm_event, listen_id pointers

Constify several pointers such as path_rec, ib_cm_event and listen_id
pointers in several functions.
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 2df7dba8
...@@ -641,7 +641,7 @@ static void cma_bind_sgid_attr(struct rdma_id_private *id_priv, ...@@ -641,7 +641,7 @@ static void cma_bind_sgid_attr(struct rdma_id_private *id_priv,
} }
static int cma_acquire_dev(struct rdma_id_private *id_priv, static int cma_acquire_dev(struct rdma_id_private *id_priv,
struct rdma_id_private *listen_id_priv) const struct rdma_id_private *listen_id_priv)
{ {
struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr; struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
const struct ib_gid_attr *sgid_attr; const struct ib_gid_attr *sgid_attr;
...@@ -1122,8 +1122,8 @@ static inline int cma_any_port(const struct sockaddr *addr) ...@@ -1122,8 +1122,8 @@ static inline int cma_any_port(const struct sockaddr *addr)
static void cma_save_ib_info(struct sockaddr *src_addr, static void cma_save_ib_info(struct sockaddr *src_addr,
struct sockaddr *dst_addr, struct sockaddr *dst_addr,
struct rdma_cm_id *listen_id, const struct rdma_cm_id *listen_id,
struct sa_path_rec *path) const struct sa_path_rec *path)
{ {
struct sockaddr_ib *listen_ib, *ib; struct sockaddr_ib *listen_ib, *ib;
...@@ -1208,7 +1208,7 @@ static u16 cma_port_from_service_id(__be64 service_id) ...@@ -1208,7 +1208,7 @@ static u16 cma_port_from_service_id(__be64 service_id)
static int cma_save_ip_info(struct sockaddr *src_addr, static int cma_save_ip_info(struct sockaddr *src_addr,
struct sockaddr *dst_addr, struct sockaddr *dst_addr,
struct ib_cm_event *ib_event, const struct ib_cm_event *ib_event,
__be64 service_id) __be64 service_id)
{ {
struct cma_hdr *hdr; struct cma_hdr *hdr;
...@@ -1238,8 +1238,8 @@ static int cma_save_ip_info(struct sockaddr *src_addr, ...@@ -1238,8 +1238,8 @@ static int cma_save_ip_info(struct sockaddr *src_addr,
static int cma_save_net_info(struct sockaddr *src_addr, static int cma_save_net_info(struct sockaddr *src_addr,
struct sockaddr *dst_addr, struct sockaddr *dst_addr,
struct rdma_cm_id *listen_id, const struct rdma_cm_id *listen_id,
struct ib_cm_event *ib_event, const struct ib_cm_event *ib_event,
sa_family_t sa_family, __be64 service_id) sa_family_t sa_family, __be64 service_id)
{ {
if (sa_family == AF_IB) { if (sa_family == AF_IB) {
...@@ -1387,7 +1387,7 @@ roce_get_net_dev_by_cm_event(const struct ib_cm_event *ib_event) ...@@ -1387,7 +1387,7 @@ roce_get_net_dev_by_cm_event(const struct ib_cm_event *ib_event)
return sgid_attr->ndev; return sgid_attr->ndev;
} }
static struct net_device *cma_get_net_dev(struct ib_cm_event *ib_event, static struct net_device *cma_get_net_dev(const struct ib_cm_event *ib_event,
struct cma_req_info *req) struct cma_req_info *req)
{ {
struct sockaddr *listen_addr = struct sockaddr *listen_addr =
...@@ -1516,9 +1516,10 @@ static struct rdma_id_private *cma_find_listener( ...@@ -1516,9 +1516,10 @@ static struct rdma_id_private *cma_find_listener(
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
static struct rdma_id_private *cma_id_from_event(struct ib_cm_id *cm_id, static struct rdma_id_private *
struct ib_cm_event *ib_event, cma_id_from_event(struct ib_cm_id *cm_id,
struct net_device **net_dev) const struct ib_cm_event *ib_event,
struct net_device **net_dev)
{ {
struct cma_req_info req; struct cma_req_info req;
struct rdma_bind_list *bind_list; struct rdma_bind_list *bind_list;
...@@ -1766,7 +1767,7 @@ static int cma_rep_recv(struct rdma_id_private *id_priv) ...@@ -1766,7 +1767,7 @@ static int cma_rep_recv(struct rdma_id_private *id_priv)
} }
static void cma_set_rep_event_data(struct rdma_cm_event *event, static void cma_set_rep_event_data(struct rdma_cm_event *event,
struct ib_cm_rep_event_param *rep_data, const struct ib_cm_rep_event_param *rep_data,
void *private_data) void *private_data)
{ {
event->param.conn.private_data = private_data; event->param.conn.private_data = private_data;
...@@ -1779,7 +1780,8 @@ static void cma_set_rep_event_data(struct rdma_cm_event *event, ...@@ -1779,7 +1780,8 @@ static void cma_set_rep_event_data(struct rdma_cm_event *event,
event->param.conn.qp_num = rep_data->remote_qpn; event->param.conn.qp_num = rep_data->remote_qpn;
} }
static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) static int cma_ib_handler(struct ib_cm_id *cm_id,
const struct ib_cm_event *ib_event)
{ {
struct rdma_id_private *id_priv = cm_id->context; struct rdma_id_private *id_priv = cm_id->context;
struct rdma_cm_event event; struct rdma_cm_event event;
...@@ -1861,9 +1863,10 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) ...@@ -1861,9 +1863,10 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
return ret; return ret;
} }
static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id, static struct rdma_id_private *
struct ib_cm_event *ib_event, cma_new_conn_id(const struct rdma_cm_id *listen_id,
struct net_device *net_dev) const struct ib_cm_event *ib_event,
struct net_device *net_dev)
{ {
struct rdma_id_private *listen_id_priv; struct rdma_id_private *listen_id_priv;
struct rdma_id_private *id_priv; struct rdma_id_private *id_priv;
...@@ -1924,11 +1927,12 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id, ...@@ -1924,11 +1927,12 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
return NULL; return NULL;
} }
static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id, static struct rdma_id_private *
struct ib_cm_event *ib_event, cma_new_udp_id(const struct rdma_cm_id *listen_id,
struct net_device *net_dev) const struct ib_cm_event *ib_event,
struct net_device *net_dev)
{ {
struct rdma_id_private *listen_id_priv; const struct rdma_id_private *listen_id_priv;
struct rdma_id_private *id_priv; struct rdma_id_private *id_priv;
struct rdma_cm_id *id; struct rdma_cm_id *id;
const sa_family_t ss_family = listen_id->route.addr.src_addr.ss_family; const sa_family_t ss_family = listen_id->route.addr.src_addr.ss_family;
...@@ -1968,7 +1972,7 @@ static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id, ...@@ -1968,7 +1972,7 @@ static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id,
} }
static void cma_set_req_event_data(struct rdma_cm_event *event, static void cma_set_req_event_data(struct rdma_cm_event *event,
struct ib_cm_req_event_param *req_data, const struct ib_cm_req_event_param *req_data,
void *private_data, int offset) void *private_data, int offset)
{ {
event->param.conn.private_data = private_data + offset; event->param.conn.private_data = private_data + offset;
...@@ -1982,7 +1986,8 @@ static void cma_set_req_event_data(struct rdma_cm_event *event, ...@@ -1982,7 +1986,8 @@ static void cma_set_req_event_data(struct rdma_cm_event *event,
event->param.conn.qp_num = req_data->remote_qpn; event->param.conn.qp_num = req_data->remote_qpn;
} }
static int cma_check_req_qp_type(struct rdma_cm_id *id, struct ib_cm_event *ib_event) static int cma_check_req_qp_type(const struct rdma_cm_id *id,
const struct ib_cm_event *ib_event)
{ {
return (((ib_event->event == IB_CM_REQ_RECEIVED) && return (((ib_event->event == IB_CM_REQ_RECEIVED) &&
(ib_event->param.req_rcvd.qp_type == id->qp_type)) || (ib_event->param.req_rcvd.qp_type == id->qp_type)) ||
...@@ -1991,7 +1996,8 @@ static int cma_check_req_qp_type(struct rdma_cm_id *id, struct ib_cm_event *ib_e ...@@ -1991,7 +1996,8 @@ static int cma_check_req_qp_type(struct rdma_cm_id *id, struct ib_cm_event *ib_e
(!id->qp_type)); (!id->qp_type));
} }
static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) static int cma_req_handler(struct ib_cm_id *cm_id,
const struct ib_cm_event *ib_event)
{ {
struct rdma_id_private *listen_id, *conn_id = NULL; struct rdma_id_private *listen_id, *conn_id = NULL;
struct rdma_cm_event event; struct rdma_cm_event event;
...@@ -3479,11 +3485,12 @@ static int cma_format_hdr(void *hdr, struct rdma_id_private *id_priv) ...@@ -3479,11 +3485,12 @@ static int cma_format_hdr(void *hdr, struct rdma_id_private *id_priv)
} }
static int cma_sidr_rep_handler(struct ib_cm_id *cm_id, static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
struct ib_cm_event *ib_event) const struct ib_cm_event *ib_event)
{ {
struct rdma_id_private *id_priv = cm_id->context; struct rdma_id_private *id_priv = cm_id->context;
struct rdma_cm_event event; struct rdma_cm_event event;
struct ib_cm_sidr_rep_event_param *rep = &ib_event->param.sidr_rep_rcvd; const struct ib_cm_sidr_rep_event_param *rep =
&ib_event->param.sidr_rep_rcvd;
int ret = 0; int ret = 0;
mutex_lock(&id_priv->handler_mutex); mutex_lock(&id_priv->handler_mutex);
......
...@@ -78,7 +78,7 @@ static struct ib_send_wr ipoib_cm_rx_drain_wr = { ...@@ -78,7 +78,7 @@ static struct ib_send_wr ipoib_cm_rx_drain_wr = {
}; };
static int ipoib_cm_tx_handler(struct ib_cm_id *cm_id, static int ipoib_cm_tx_handler(struct ib_cm_id *cm_id,
struct ib_cm_event *event); const struct ib_cm_event *event);
static void ipoib_cm_dma_unmap_rx(struct ipoib_dev_priv *priv, int frags, static void ipoib_cm_dma_unmap_rx(struct ipoib_dev_priv *priv, int frags,
u64 mapping[IPOIB_CM_RX_SG]) u64 mapping[IPOIB_CM_RX_SG])
...@@ -418,7 +418,8 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i ...@@ -418,7 +418,8 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i
} }
static int ipoib_cm_send_rep(struct net_device *dev, struct ib_cm_id *cm_id, static int ipoib_cm_send_rep(struct net_device *dev, struct ib_cm_id *cm_id,
struct ib_qp *qp, struct ib_cm_req_event_param *req, struct ib_qp *qp,
const struct ib_cm_req_event_param *req,
unsigned int psn) unsigned int psn)
{ {
struct ipoib_dev_priv *priv = ipoib_priv(dev); struct ipoib_dev_priv *priv = ipoib_priv(dev);
...@@ -438,7 +439,8 @@ static int ipoib_cm_send_rep(struct net_device *dev, struct ib_cm_id *cm_id, ...@@ -438,7 +439,8 @@ static int ipoib_cm_send_rep(struct net_device *dev, struct ib_cm_id *cm_id,
return ib_send_cm_rep(cm_id, &rep); return ib_send_cm_rep(cm_id, &rep);
} }
static int ipoib_cm_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) static int ipoib_cm_req_handler(struct ib_cm_id *cm_id,
const struct ib_cm_event *event)
{ {
struct net_device *dev = cm_id->context; struct net_device *dev = cm_id->context;
struct ipoib_dev_priv *priv = ipoib_priv(dev); struct ipoib_dev_priv *priv = ipoib_priv(dev);
...@@ -500,7 +502,7 @@ static int ipoib_cm_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *even ...@@ -500,7 +502,7 @@ static int ipoib_cm_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *even
} }
static int ipoib_cm_rx_handler(struct ib_cm_id *cm_id, static int ipoib_cm_rx_handler(struct ib_cm_id *cm_id,
struct ib_cm_event *event) const struct ib_cm_event *event)
{ {
struct ipoib_cm_rx *p; struct ipoib_cm_rx *p;
struct ipoib_dev_priv *priv; struct ipoib_dev_priv *priv;
...@@ -978,7 +980,8 @@ void ipoib_cm_dev_stop(struct net_device *dev) ...@@ -978,7 +980,8 @@ void ipoib_cm_dev_stop(struct net_device *dev)
cancel_delayed_work(&priv->cm.stale_task); cancel_delayed_work(&priv->cm.stale_task);
} }
static int ipoib_cm_rep_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) static int ipoib_cm_rep_handler(struct ib_cm_id *cm_id,
const struct ib_cm_event *event)
{ {
struct ipoib_cm_tx *p = cm_id->context; struct ipoib_cm_tx *p = cm_id->context;
struct ipoib_dev_priv *priv = ipoib_priv(p->dev); struct ipoib_dev_priv *priv = ipoib_priv(p->dev);
...@@ -1244,7 +1247,7 @@ static void ipoib_cm_tx_destroy(struct ipoib_cm_tx *p) ...@@ -1244,7 +1247,7 @@ static void ipoib_cm_tx_destroy(struct ipoib_cm_tx *p)
} }
static int ipoib_cm_tx_handler(struct ib_cm_id *cm_id, static int ipoib_cm_tx_handler(struct ib_cm_id *cm_id,
struct ib_cm_event *event) const struct ib_cm_event *event)
{ {
struct ipoib_cm_tx *tx = cm_id->context; struct ipoib_cm_tx *tx = cm_id->context;
struct ipoib_dev_priv *priv = ipoib_priv(tx->dev); struct ipoib_dev_priv *priv = ipoib_priv(tx->dev);
......
...@@ -142,7 +142,8 @@ static void srp_remove_one(struct ib_device *device, void *client_data); ...@@ -142,7 +142,8 @@ static void srp_remove_one(struct ib_device *device, void *client_data);
static void srp_recv_done(struct ib_cq *cq, struct ib_wc *wc); static void srp_recv_done(struct ib_cq *cq, struct ib_wc *wc);
static void srp_handle_qp_err(struct ib_cq *cq, struct ib_wc *wc, static void srp_handle_qp_err(struct ib_cq *cq, struct ib_wc *wc,
const char *opname); const char *opname);
static int srp_ib_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event); static int srp_ib_cm_handler(struct ib_cm_id *cm_id,
const struct ib_cm_event *event);
static int srp_rdma_cm_handler(struct rdma_cm_id *cm_id, static int srp_rdma_cm_handler(struct rdma_cm_id *cm_id,
struct rdma_cm_event *event); struct rdma_cm_event *event);
...@@ -2553,7 +2554,7 @@ static void srp_cm_rep_handler(struct ib_cm_id *cm_id, ...@@ -2553,7 +2554,7 @@ static void srp_cm_rep_handler(struct ib_cm_id *cm_id,
} }
static void srp_ib_cm_rej_handler(struct ib_cm_id *cm_id, static void srp_ib_cm_rej_handler(struct ib_cm_id *cm_id,
struct ib_cm_event *event, const struct ib_cm_event *event,
struct srp_rdma_ch *ch) struct srp_rdma_ch *ch)
{ {
struct srp_target_port *target = ch->target; struct srp_target_port *target = ch->target;
...@@ -2638,7 +2639,8 @@ static void srp_ib_cm_rej_handler(struct ib_cm_id *cm_id, ...@@ -2638,7 +2639,8 @@ static void srp_ib_cm_rej_handler(struct ib_cm_id *cm_id,
} }
} }
static int srp_ib_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) static int srp_ib_cm_handler(struct ib_cm_id *cm_id,
const struct ib_cm_event *event)
{ {
struct srp_rdma_ch *ch = cm_id->context; struct srp_rdma_ch *ch = cm_id->context;
struct srp_target_port *target = ch->target; struct srp_target_port *target = ch->target;
......
...@@ -2401,7 +2401,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev, ...@@ -2401,7 +2401,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
} }
static int srpt_ib_cm_req_recv(struct ib_cm_id *cm_id, static int srpt_ib_cm_req_recv(struct ib_cm_id *cm_id,
struct ib_cm_req_event_param *param, const struct ib_cm_req_event_param *param,
void *private_data) void *private_data)
{ {
char sguid[40]; char sguid[40];
...@@ -2513,7 +2513,8 @@ static void srpt_cm_rtu_recv(struct srpt_rdma_ch *ch) ...@@ -2513,7 +2513,8 @@ static void srpt_cm_rtu_recv(struct srpt_rdma_ch *ch)
* a non-zero value in any other case will trigger a race with the * a non-zero value in any other case will trigger a race with the
* ib_destroy_cm_id() call in srpt_release_channel(). * ib_destroy_cm_id() call in srpt_release_channel().
*/ */
static int srpt_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) static int srpt_cm_handler(struct ib_cm_id *cm_id,
const struct ib_cm_event *event)
{ {
struct srpt_rdma_ch *ch = cm_id->context; struct srpt_rdma_ch *ch = cm_id->context;
int ret; int ret;
......
...@@ -311,7 +311,7 @@ struct ib_cm_event { ...@@ -311,7 +311,7 @@ struct ib_cm_event {
* destroy the @cm_id after the callback completes. * destroy the @cm_id after the callback completes.
*/ */
typedef int (*ib_cm_handler)(struct ib_cm_id *cm_id, typedef int (*ib_cm_handler)(struct ib_cm_id *cm_id,
struct ib_cm_event *event); const struct ib_cm_event *event);
struct ib_cm_id { struct ib_cm_id {
ib_cm_handler cm_handler; ib_cm_handler cm_handler;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment