InfiniBand updates for 2.6.17
Subsystems (2)
Linus, please pull from
master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git for-linus
This tree is also available from kernel.org mirrors at:
git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband.git for-linus
The pull will get the following changes:
Hal Rosenstock:
IB/mad: RMPP support for additional classes
Jack Morgenstein:
IB/mthca: Fix check of size in SRQ creation IB/mad: include GID/class when matching receives
Roland Dreier:
IB/srp: Fix unmapping of fake scatterlist
IPoIB: Fix oops with raw sockets
IB/mthca: Fix section mismatch problems
drivers/infiniband/core/mad.c | 112 ++++++++++++++++++++++++++--- drivers/infiniband/core/mad_rmpp.c | 54 ++++---------- drivers/infiniband/core/user_mad.c | 30 ++------ drivers/infiniband/hw/mthca/mthca_av.c | 2 - drivers/infiniband/hw/mthca/mthca_cq.c | 2 - drivers/infiniband/hw/mthca/mthca_eq.c | 6 +- drivers/infiniband/hw/mthca/mthca_mad.c | 2 - drivers/infiniband/hw/mthca/mthca_mcg.c | 2 - drivers/infiniband/hw/mthca/mthca_mr.c | 4 + drivers/infiniband/hw/mthca/mthca_pd.c | 2 - drivers/infiniband/hw/mthca/mthca_qp.c | 2 - drivers/infiniband/hw/mthca/mthca_srq.c | 4 + drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 - drivers/infiniband/ulp/srp/ib_srp.c | 4 + include/rdma/ib_mad.h | 27 +++++++ 15 files changed, 166 insertions(+), 89 deletions(-)
drivers/infiniband/core/mad.c +101 -11
@@ -227,6 +227,14 @@ struct ib_mad_agent *ib_register_mad_ageif (!is_vendor_oui (mad_reg_req->oui)) goto error1; } +/* Make sure class supplied is consistent with RMPP */ +if (ib_is_mad_class_rmpp (mad_reg_req->mgmt_class)) { +if (!rmpp_version) + goto error1; + }else { +if (rmpp_version) + goto error1; + }/* Make sure class supplied is consistent with QP type */ if (qp_type ==IB_QPT_SMI ) { if ((mad_reg_req->mgmt_class !=
@@ -890,6 +898,35 @@ struct ib_mad_send_buf * ib_create_send_ }EXPORT_SYMBOL (ib_create_send_mad); +int ib_get_mad_data_offset (u8 mgmt_class) +{ +if (mgmt_class ==IB_MGMT_CLASS_SUBN_ADM ) +return IB_MGMT_SA_HDR ; +else if ((mgmt_class ==IB_MGMT_CLASS_DEVICE_MGMT ) || + (mgmt_class ==IB_MGMT_CLASS_DEVICE_ADM ) || + (mgmt_class ==IB_MGMT_CLASS_BIS )) +return IB_MGMT_DEVICE_HDR ; +else if ((mgmt_class >=IB_MGMT_CLASS_VENDOR_RANGE2_START ) && + (mgmt_class <=IB_MGMT_CLASS_VENDOR_RANGE2_END )) +return IB_MGMT_VENDOR_HDR ; +else +return IB_MGMT_MAD_HDR ; +} +EXPORT_SYMBOL (ib_get_mad_data_offset); + +int ib_is_mad_class_rmpp (u8 mgmt_class) +{ +if ((mgmt_class ==IB_MGMT_CLASS_SUBN_ADM ) || + (mgmt_class ==IB_MGMT_CLASS_DEVICE_MGMT ) || + (mgmt_class ==IB_MGMT_CLASS_DEVICE_ADM ) || + (mgmt_class ==IB_MGMT_CLASS_BIS ) || + ((mgmt_class >=IB_MGMT_CLASS_VENDOR_RANGE2_START ) && + (mgmt_class <=IB_MGMT_CLASS_VENDOR_RANGE2_END ))) +return 1 ; +return 0 ; +} +EXPORT_SYMBOL (ib_is_mad_class_rmpp); +void *ib_get_rmpp_segment (struct ib_mad_send_buf *send_buf,int seg_num) {struct ib_mad_send_wr_private *mad_send_wr;
@@ -1022,6 +1059,13 @@ int ib_post_send_mad(struct ib_mad_send_ goto error; } +if (!ib_is_mad_class_rmpp (((struct ib_mad_hdr *) send_buf->mad)->mgmt_class)) { +if (mad_agent_priv->agent.rmpp_version) { + ret = -EINVAL ; + goto error; + } + } +/* * Save pointer to next work request to post in case the * current one completes, and the user modifies the work
@@ -1618,14 +1662,59 @@ static int is_data_mad(struct ib_mad_age (rmpp_mad->rmpp_hdr.rmpp_type ==IB_MGMT_RMPP_TYPE_DATA ); } +static inline int rcv_has_same_class (struct ib_mad_send_wr_private *wr, +struct ib_mad_recv_wc *rwc) +{ +return ((struct ib_mad *)(wr->send_buf.mad))->mad_hdr.mgmt_class == + rwc->recv_buf.mad->mad_hdr.mgmt_class; +} + +static inline int rcv_has_same_gid (struct ib_mad_send_wr_private *wr, +struct ib_mad_recv_wc *rwc ) +{ +struct ib_ah_attr attr; +u8 send_resp, rcv_resp; + + send_resp = ((struct ib_mad *)(wr->send_buf.mad))-> + mad_hdr.method &IB_MGMT_METHOD_RESP ; + rcv_resp = rwc->recv_buf.mad->mad_hdr.method &IB_MGMT_METHOD_RESP ; + +if (!send_resp && rcv_resp) +/* is request/response. GID/LIDs are both local (same). */ +return 1 ; + +if (send_resp == rcv_resp) +/* both requests, or both responses. GIDs different */ +return 0 ; + +if (ib_query_ah (wr->send_buf.ah, &attr)) +/* Assume not equal, to avoid false positives. */ +return 0 ; + +if (!(attr.ah_flags &IB_AH_GRH ) && !(rwc->wc->wc_flags &IB_WC_GRH )) +return attr.dlid == rwc->wc->slid; +else if ((attr.ah_flags &IB_AH_GRH ) && + (rwc->wc->wc_flags &IB_WC_GRH )) +return memcmp (attr.grh.dgid.raw, + rwc->recv_buf.grh->sgid.raw,16 ) ==0 ; +else +/* one has GID, other does not. Assume different */ +return 0 ; +}struct ib_mad_send_wr_private * -ib_find_send_mad (struct ib_mad_agent_private *mad_agent_priv,__be64 tid) +ib_find_send_mad (struct ib_mad_agent_private *mad_agent_priv, +struct ib_mad_recv_wc *mad_recv_wc) {struct ib_mad_send_wr_private *mad_send_wr; +struct ib_mad *mad; + + mad = (struct ib_mad *)mad_recv_wc->recv_buf.mad;list_for_each_entry (mad_send_wr, &mad_agent_priv->wait_list, agent_list) { -if (mad_send_wr->tid == tid) +if ((mad_send_wr->tid == mad->mad_hdr.tid) && +rcv_has_same_class (mad_send_wr, mad_recv_wc) && +rcv_has_same_gid (mad_send_wr, mad_recv_wc))return mad_send_wr; }
@@ -1636,7 +1725,10 @@ ib_find_send_mad(struct ib_mad_agent_prilist_for_each_entry (mad_send_wr, &mad_agent_priv->send_list, agent_list) {if (is_data_mad (mad_agent_priv, mad_send_wr->send_buf.mad) && - mad_send_wr->tid == tid && mad_send_wr->timeout) { + mad_send_wr->tid == mad->mad_hdr.tid && + mad_send_wr->timeout && +rcv_has_same_class (mad_send_wr, mad_recv_wc) && +rcv_has_same_gid (mad_send_wr, mad_recv_wc)) {/* Verify request has not been canceled */ return (mad_send_wr->status ==IB_WC_SUCCESS ) ? mad_send_wr :NULL ;
@@ -1661,7 +1753,6 @@ static void ib_mad_complete_recv(structstruct ib_mad_send_wr_private *mad_send_wr;struct ib_mad_send_wc mad_send_wc;unsigned long flags; -__be64 tid;INIT_LIST_HEAD (&mad_recv_wc->rmpp_list);list_add (&mad_recv_wc->recv_buf.list, &mad_recv_wc->rmpp_list);
@@ -1677,9 +1768,8 @@ static void ib_mad_complete_recv(struct/* Complete corresponding request */ if (response_mad (mad_recv_wc->recv_buf.mad)) { - tid = mad_recv_wc->recv_buf.mad->mad_hdr.tid;spin_lock_irqsave (&mad_agent_priv->lock, flags); - mad_send_wr =ib_find_send_mad (mad_agent_priv, tid); + mad_send_wr =ib_find_send_mad (mad_agent_priv, mad_recv_wc);if (!mad_send_wr) {spin_unlock_irqrestore (&mad_agent_priv->lock, flags);ib_free_recv_mad (mad_recv_wc);
@@ -2408,11 +2498,11 @@ static int ib_mad_post_receive_mads(stru } } sg_list.addr =dma_map_single (qp_info->port_priv-> - device->dma_device, - &mad_priv->grh, -sizeof *mad_priv - -sizeof mad_priv->header, -DMA_FROM_DEVICE ); + device->dma_device, + &mad_priv->grh, +sizeof *mad_priv - +sizeof mad_priv->header, +DMA_FROM_DEVICE );pci_unmap_addr_set (&mad_priv->header, mapping, sg_list.addr); recv_wr.wr_id = (unsigned long )&mad_priv->header.mad_list; mad_priv->header.mad_list.mad_queue = recv_queue;
drivers/infiniband/core/mad_rmpp.c +17 -37
146 lines not on this page · raw message
drivers/infiniband/core/user_mad.c +6 -24
@@ -177,17 +177,6 @@ static int queue_packet(struct ib_umad_freturn ret; } -static int data_offset (u8 mgmt_class) -{ -if (mgmt_class ==IB_MGMT_CLASS_SUBN_ADM ) -return IB_MGMT_SA_HDR ; -else if ((mgmt_class >=IB_MGMT_CLASS_VENDOR_RANGE2_START ) && - (mgmt_class <=IB_MGMT_CLASS_VENDOR_RANGE2_END )) -return IB_MGMT_VENDOR_HDR ; -else -return IB_MGMT_RMPP_HDR ; -} -static void send_handler (struct ib_mad_agent *agent,struct ib_mad_send_wc *send_wc) {
@@ -283,7 +272,7 @@ static ssize_t copy_recv_mad(char __user*/ return -ENOSPC ; } - offset =data_offset (recv_buf->mad->mad_hdr.mgmt_class); + offset =ib_get_mad_data_offset (recv_buf->mad->mad_hdr.mgmt_class); max_seg_payload =sizeof (struct ib_mad ) - offset; for (left = packet->length - seg_payload, buf += seg_payload;
@@ -441,21 +430,14 @@ static ssize_t ib_umad_write(struct file } rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data; -if (rmpp_mad->mad_hdr.mgmt_class ==IB_MGMT_CLASS_SUBN_ADM ) { - hdr_len =IB_MGMT_SA_HDR ; - copy_offset =IB_MGMT_RMPP_HDR ; - rmpp_active =ib_get_rmpp_flags (&rmpp_mad->rmpp_hdr) & -IB_MGMT_RMPP_FLAG_ACTIVE ; - }else if (rmpp_mad->mad_hdr.mgmt_class >=IB_MGMT_CLASS_VENDOR_RANGE2_START && - rmpp_mad->mad_hdr.mgmt_class <=IB_MGMT_CLASS_VENDOR_RANGE2_END ) { - hdr_len =IB_MGMT_VENDOR_HDR ; + hdr_len =ib_get_mad_data_offset (rmpp_mad->mad_hdr.mgmt_class); +if (!ib_is_mad_class_rmpp (rmpp_mad->mad_hdr.mgmt_class)) { + copy_offset =IB_MGMT_MAD_HDR ; + rmpp_active =0 ; + }else { copy_offset =IB_MGMT_RMPP_HDR ; rmpp_active =ib_get_rmpp_flags (&rmpp_mad->rmpp_hdr) &IB_MGMT_RMPP_FLAG_ACTIVE ; - }else { - hdr_len =IB_MGMT_MAD_HDR ; - copy_offset =IB_MGMT_MAD_HDR ; - rmpp_active =0 ; } data_len = count -sizeof (struct ib_user_mad ) - hdr_len;
drivers/infiniband/hw/mthca/mthca_av.c +1 -1
@@ -265,7 +265,7 @@ int __devinit mthca_init_av_table(structreturn -ENOMEM ; } -void __devexit mthca_cleanup_av_table(struct mthca_dev *dev) +void mthca_cleanup_av_table (struct mthca_dev *dev) {if (mthca_is_memfree (dev))return ;
drivers/infiniband/hw/mthca/mthca_cq.c +1 -1
@@ -973,7 +973,7 @@ int __devinit mthca_init_cq_table(structreturn err; } -void __devexit mthca_cleanup_cq_table(struct mthca_dev *dev) +void mthca_cleanup_cq_table (struct mthca_dev *dev) {mthca_array_cleanup (&dev->cq_table.cq, dev->limits.num_cqs);mthca_alloc_cleanup (&dev->cq_table.alloc);
drivers/infiniband/hw/mthca/mthca_eq.c +3 -3
@@ -765,7 +765,7 @@ static int __devinit mthca_map_eq_regs(s } -static void __devexit mthca_unmap_eq_regs(struct mthca_dev *dev) +static void mthca_unmap_eq_regs (struct mthca_dev *dev) {if (mthca_is_memfree (dev)) { mthca_unmap_reg(dev, (pci_resource_len(dev->pdev, 0) - 1) &
@@ -821,7 +821,7 @@ int __devinit mthca_map_eq_icm(struct mtreturn ret; } -void __devexit mthca_unmap_eq_icm(struct mthca_dev *dev) +void mthca_unmap_eq_icm (struct mthca_dev *dev) {u8 status;
@@ -954,7 +954,7 @@ err_out_free:return err; } -void __devexit mthca_cleanup_eq_table(struct mthca_dev *dev) +void mthca_cleanup_eq_table (struct mthca_dev *dev) {u8 status;int i;
drivers/infiniband/hw/mthca/mthca_mad.c +1 -1
@@ -271,7 +271,7 @@ err:return PTR_ERR (agent); } -void mthca_free_agents (struct mthca_dev *dev) +void __devexit mthca_free_agents(struct mthca_dev *dev) {struct ib_mad_agent *agent;int p, q;
drivers/infiniband/hw/mthca/mthca_mcg.c +1 -1
@@ -388,7 +388,7 @@ int __devinit mthca_init_mcg_table(strucreturn 0 ; } -void __devexit mthca_cleanup_mcg_table(struct mthca_dev *dev) +void mthca_cleanup_mcg_table (struct mthca_dev *dev) {mthca_alloc_cleanup (&dev->mcg_table.alloc); }
drivers/infiniband/hw/mthca/mthca_mr.c +2 -2
@@ -170,7 +170,7 @@ err_out:return -ENOMEM ; } -static void __devexit mthca_buddy_cleanup(struct mthca_buddy *buddy) +static void mthca_buddy_cleanup (struct mthca_buddy *buddy) {int i;
@@ -866,7 +866,7 @@ err_mtt_buddy:return err; } -void __devexit mthca_cleanup_mr_table(struct mthca_dev *dev) +void mthca_cleanup_mr_table (struct mthca_dev *dev) {/* XXX check if any MRs are still allocated? */ if (dev->limits.fmr_reserved_mtts)
drivers/infiniband/hw/mthca/mthca_pd.c +1 -1
@@ -77,7 +77,7 @@ int __devinit mthca_init_pd_table(struct dev->limits.reserved_pds); } -void __devexit mthca_cleanup_pd_table(struct mthca_dev *dev) +void mthca_cleanup_pd_table (struct mthca_dev *dev) {/* XXX check if any PDs are still allocated? */ mthca_alloc_cleanup (&dev->pd_table.alloc);
drivers/infiniband/hw/mthca/mthca_qp.c +1 -1
@@ -2204,7 +2204,7 @@ int __devinit mthca_init_qp_table(structreturn err; } -void __devexit mthca_cleanup_qp_table(struct mthca_dev *dev) +void mthca_cleanup_qp_table (struct mthca_dev *dev) {int i;u8 status;
drivers/infiniband/hw/mthca/mthca_srq.c +2 -2
@@ -206,7 +206,7 @@ int mthca_alloc_srq(struct mthca_dev *deroundup_pow_of_two (sizeof (struct mthca_next_seg ) + srq->max_gs * sizeof (struct mthca_data_seg))); -if (ds > dev->limits.max_desc_sz) +if (!mthca_is_memfree (dev) && (ds > dev->limits.max_desc_sz))return -EINVAL ; srq->wqe_shift =long_log2 (ds);
@@ -684,7 +684,7 @@ int __devinit mthca_init_srq_table(strucreturn err; } -void __devexit mthca_cleanup_srq_table(struct mthca_dev *dev) +void mthca_cleanup_srq_table (struct mthca_dev *dev) {if (!(dev->mthca_flags &MTHCA_FLAG_SRQ ))return ;
drivers/infiniband/ulp/ipoib/ipoib_main.c +1 -1
@@ -723,7 +723,7 @@ static int ipoib_hard_header(struct sk_b* destination address onto the front of the skb so we can * figure out where to send the packet later. */ -if (!skb->dst || !skb->dst->neighbour) { +if ((!skb->dst || !skb->dst->neighbour) && daddr) {struct ipoib_pseudoheader *phdr = (struct ipoib_pseudoheader *)skb_push (skb,sizeof *phdr);memcpy (phdr->hwaddr, daddr,INFINIBAND_ALEN );
drivers/infiniband/ulp/srp/ib_srp.c +2 -2
@@ -607,10 +607,10 @@ static void srp_unmap_data(struct scsi_c*/ if (likely (scmnd->use_sg)) { nents = scmnd->use_sg; - scat = (struct scatterlist *) scmnd->request_buffer; + scat = scmnd->request_buffer; }else { nents =1 ; - scat = (struct scatterlist *) scmnd->request_buffer; + scat = &req->fake_sg; } dma_unmap_sg(target->srp_host->dev->dma_device, scat, nents,
include/rdma/ib_mad.h +26 -1
@@ -3,7 +3,7 @@* Copyright (c) 2004 Infinicon Corporation. All rights reserved. * Copyright (c) 2004 Intel Corporation. All rights reserved. * Copyright (c) 2004 Topspin Corporation. All rights reserved. -* Copyright (c) 2004 Voltaire Corporation. All rights reserved. +* Copyright (c) 2004-2006 Voltaire Corporation. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU
@@ -55,6 +55,10 @@#define IB_MGMT_CLASS_DEVICE_MGMT 0x06#define IB_MGMT_CLASS_CM 0x07#define IB_MGMT_CLASS_SNMP 0x08 +#define IB_MGMT_CLASS_DEVICE_ADM 0x10 +#define IB_MGMT_CLASS_BOOT_MGMT 0x11 +#define IB_MGMT_CLASS_BIS 0x12 +#define IB_MGMT_CLASS_CONG_MGMT 0x21#define IB_MGMT_CLASS_VENDOR_RANGE2_START 0x30#define IB_MGMT_CLASS_VENDOR_RANGE2_END 0x4F
@@ -117,6 +121,8 @@ enum {IB_MGMT_VENDOR_DATA =216 ,IB_MGMT_SA_HDR =56 ,IB_MGMT_SA_DATA =200 , +IB_MGMT_DEVICE_HDR =64 , + IB_MGMT_DEVICE_DATA = 192, }; struct ib_mad_hdr {
@@ -603,6 +609,25 @@ struct ib_mad_send_buf * ib_create_send_ gfp_t gfp_mask);/** +* ib_is_mad_class_rmpp - returns whether given management class +* supports RMPP. +* @mgmt_class: management class +* +* This routine returns whether the management class supports RMPP. +*/ +int ib_is_mad_class_rmpp (u8 mgmt_class); + +/** +* ib_get_mad_data_offset - returns the data offset for a given +* management class. +* @mgmt_class: management class +* +* This routine returns the data offset in the MAD for the management +* class requested. +*/ +int ib_get_mad_data_offset (u8 mgmt_class); + +/** * ib_get_rmpp_segment - returns the data buffer for a given RMPP segment. * @send_buf: Previously allocated send data buffer. * @seg_num: number of segment to return