···2626 ioctl. Also, all agents registered through a file descriptor will2727 be unregistered when the descriptor is closed.28282929+ 2014 -- a new registration ioctl is now provided which allows additional3030+ fields to be provided during registration.3131+ Users of this registration call are implicitly setting the use of3232+ pkey_index (see below).3333+2934Receiving MADs30353136 MADs are received using read(). The receive side now supports···109104 The old ib_umad interface did not allow setting the P_Key index for110105 MADs that are sent and did not provide a way for obtaining the P_Key111106 index of received MADs. A new layout for struct ib_user_mad_hdr112112- with a pkey_index member has been defined; however, to preserve113113- binary compatibility with older applications, this new layout will114114- not be used unless the IB_USER_MAD_ENABLE_PKEY ioctl is called115115- before a file descriptor is used for anything else.107107+ with a pkey_index member has been defined; however, to preserve binary108108+ compatibility with older applications, this new layout will not be used109109+ unless one of IB_USER_MAD_ENABLE_PKEY or IB_USER_MAD_REGISTER_AGENT2 ioctl's110110+ are called before a file descriptor is used for anything else.116111117112 In September 2008, the IB_USER_MAD_ABI_VERSION will be incremented118113 to 6, the new layout of struct ib_user_mad_hdr will be used by
+8-8
drivers/infiniband/core/agent.c
···9494 port_priv = ib_get_agent_port(device, port_num);95959696 if (!port_priv) {9797- printk(KERN_ERR SPFX "Unable to find port agent\n");9797+ dev_err(&device->dev, "Unable to find port agent\n");9898 return;9999 }100100101101 agent = port_priv->agent[qpn];102102 ah = ib_create_ah_from_wc(agent->qp->pd, wc, grh, port_num);103103 if (IS_ERR(ah)) {104104- printk(KERN_ERR SPFX "ib_create_ah_from_wc error %ld\n",104104+ dev_err(&device->dev, "ib_create_ah_from_wc error %ld\n",105105 PTR_ERR(ah));106106 return;107107 }···110110 IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,111111 GFP_KERNEL);112112 if (IS_ERR(send_buf)) {113113- printk(KERN_ERR SPFX "ib_create_send_mad error\n");113113+ dev_err(&device->dev, "ib_create_send_mad error\n");114114 goto err1;115115 }116116···125125 }126126127127 if (ib_post_send_mad(send_buf, NULL)) {128128- printk(KERN_ERR SPFX "ib_post_send_mad error\n");128128+ dev_err(&device->dev, "ib_post_send_mad error\n");129129 goto err2;130130 }131131 return;···151151 /* Create new device info */152152 port_priv = kzalloc(sizeof *port_priv, GFP_KERNEL);153153 if (!port_priv) {154154- printk(KERN_ERR SPFX "No memory for ib_agent_port_private\n");154154+ dev_err(&device->dev, "No memory for ib_agent_port_private\n");155155 ret = -ENOMEM;156156 goto error1;157157 }···161161 port_priv->agent[0] = ib_register_mad_agent(device, port_num,162162 IB_QPT_SMI, NULL, 0,163163 &agent_send_handler,164164- NULL, NULL);164164+ NULL, NULL, 0);165165 if (IS_ERR(port_priv->agent[0])) {166166 ret = PTR_ERR(port_priv->agent[0]);167167 goto error2;···172172 port_priv->agent[1] = ib_register_mad_agent(device, port_num,173173 IB_QPT_GSI, NULL, 0,174174 &agent_send_handler,175175- NULL, NULL);175175+ NULL, NULL, 0);176176 if (IS_ERR(port_priv->agent[1])) {177177 ret = PTR_ERR(port_priv->agent[1]);178178 goto error3;···202202 port_priv = __ib_get_agent_port(device, port_num);203203 if (port_priv == NULL) {204204 spin_unlock_irqrestore(&ib_agent_port_list_lock, flags);205205- printk(KERN_ERR SPFX "Port %d not found\n", port_num);205205+ dev_err(&device->dev, "Port %d not found\n", port_num);206206 return -ENODEV;207207 }208208 list_del(&port_priv->port_list);
···531531 return !wq->rq.queue[wq->rq.size].status.db_off;532532}533533534534+enum t4_cq_flags {535535+ CQ_ARMED = 1,536536+};537537+534538struct t4_cq {535539 struct t4_cqe *queue;536540 dma_addr_t dma_addr;···555551 u16 cidx_inc;556552 u8 gen;557553 u8 error;554554+ unsigned long flags;558555};556556+557557+static inline int t4_clear_cq_armed(struct t4_cq *cq)558558+{559559+ return test_and_clear_bit(CQ_ARMED, &cq->flags);560560+}559561560562static inline int t4_arm_cq(struct t4_cq *cq, int se)561563{562564 u32 val;563565566566+ set_bit(CQ_ARMED, &cq->flags);564567 while (cq->cidx_inc > CIDXINC_MASK) {565568 val = SEINTARM(0) | CIDXINC(CIDXINC_MASK) | TIMERREG(7) |566569 INGRESSQID(cq->cqid);
+10-4
drivers/infiniband/hw/ipath/ipath_mad.c
···726726 * @dd: the infinipath device727727 * @pkeys: the PKEY table728728 */729729-static int set_pkeys(struct ipath_devdata *dd, u16 *pkeys)729729+static int set_pkeys(struct ipath_devdata *dd, u16 *pkeys, u8 port)730730{731731 struct ipath_portdata *pd;732732 int i;···759759 }760760 if (changed) {761761 u64 pkey;762762+ struct ib_event event;762763763764 pkey = (u64) dd->ipath_pkeys[0] |764765 ((u64) dd->ipath_pkeys[1] << 16) |···769768 (unsigned long long) pkey);770769 ipath_write_kreg(dd, dd->ipath_kregs->kr_partitionkey,771770 pkey);771771+772772+ event.event = IB_EVENT_PKEY_CHANGE;773773+ event.device = &dd->verbs_dev->ibdev;774774+ event.element.port_num = port;775775+ ib_dispatch_event(&event);772776 }773777 return 0;774778}775779776780static int recv_subn_set_pkeytable(struct ib_smp *smp,777777- struct ib_device *ibdev)781781+ struct ib_device *ibdev, u8 port)778782{779783 u32 startpx = 32 * (be32_to_cpu(smp->attr_mod) & 0xffff);780784 __be16 *p = (__be16 *) smp->data;···790784 for (i = 0; i < n; i++)791785 q[i] = be16_to_cpu(p[i]);792786793793- if (startpx != 0 || set_pkeys(dev->dd, q) != 0)787787+ if (startpx != 0 || set_pkeys(dev->dd, q, port) != 0)794788 smp->status |= IB_SMP_INVALID_FIELD;795789796790 return recv_subn_get_pkeytable(smp, ibdev);···13481342 ret = recv_subn_set_portinfo(smp, ibdev, port_num);13491343 goto bail;13501344 case IB_SMP_ATTR_PKEY_TABLE:13511351- ret = recv_subn_set_pkeytable(smp, ibdev);13451345+ ret = recv_subn_set_pkeytable(smp, ibdev, port_num);13521346 goto bail;13531347 case IB_SMP_ATTR_SM_INFO:13541348 if (dev->port_cap_flags & IB_PORT_SM_DISABLED) {
+1-1
drivers/infiniband/hw/mlx4/mad.c
···891891 agent = ib_register_mad_agent(&dev->ib_dev, p + 1,892892 q ? IB_QPT_GSI : IB_QPT_SMI,893893 NULL, 0, send_handler,894894- NULL, NULL);894894+ NULL, NULL, 0);895895 if (IS_ERR(agent)) {896896 ret = PTR_ERR(agent);897897 goto err;
+2-4
drivers/infiniband/hw/mlx4/main.c
···910910 const struct default_rules *pdefault_rules = default_table;911911 u8 link_layer = rdma_port_get_link_layer(qp->device, flow_attr->port);912912913913- for (i = 0; i < sizeof(default_table)/sizeof(default_table[0]); i++,914914- pdefault_rules++) {913913+ for (i = 0; i < ARRAY_SIZE(default_table); i++, pdefault_rules++) {915914 __u32 field_types[IB_FLOW_SPEC_SUPPORT_LAYERS];916915 memset(&field_types, 0, sizeof(field_types));917916···964965 int size = 0;965966 int i;966967967967- for (i = 0; i < sizeof(pdefault_rules->rules_create_list)/968968- sizeof(pdefault_rules->rules_create_list[0]); i++) {968968+ for (i = 0; i < ARRAY_SIZE(pdefault_rules->rules_create_list); i++) {969969 int ret;970970 union ib_flow_spec ib_spec;971971 switch (pdefault_rules->rules_create_list[i]) {
···491491}492492493493/**494494- * releases the QP objects, returns 0 on success,495495- * -1 on failure494494+ * releases the QP object496495 */497497-static int iser_free_ib_conn_res(struct iser_conn *ib_conn)496496+static void iser_free_ib_conn_res(struct iser_conn *ib_conn)498497{499498 int cq_index;500499 BUG_ON(ib_conn == NULL);···512513 }513514514515 ib_conn->qp = NULL;515515-516516- return 0;517516}518517519518/**···565568 mutex_unlock(&ig.device_list_mutex);566569}567570571571+/**572572+ * Called with state mutex held573573+ **/568574static int iser_conn_state_comp_exch(struct iser_conn *ib_conn,569575 enum iser_ib_conn_state comp,570576 enum iser_ib_conn_state exch)571577{572578 int ret;573579574574- spin_lock_bh(&ib_conn->lock);575580 if ((ret = (ib_conn->state == comp)))576581 ib_conn->state = exch;577577- spin_unlock_bh(&ib_conn->lock);578582 return ret;579583}580584581585void iser_release_work(struct work_struct *work)582586{583587 struct iser_conn *ib_conn;588588+ int rc;584589585590 ib_conn = container_of(work, struct iser_conn, release_work);586591587592 /* wait for .conn_stop callback */588588- wait_for_completion(&ib_conn->stop_completion);593593+ rc = wait_for_completion_timeout(&ib_conn->stop_completion, 30 * HZ);594594+ WARN_ON(rc == 0);589595590596 /* wait for the qp`s post send and post receive buffers to empty */591591- wait_event_interruptible(ib_conn->wait,592592- ib_conn->state == ISER_CONN_DOWN);597597+ rc = wait_for_completion_timeout(&ib_conn->flush_completion, 30 * HZ);598598+ WARN_ON(rc == 0);599599+600600+ ib_conn->state = ISER_CONN_DOWN;601601+602602+ mutex_lock(&ib_conn->state_mutex);603603+ ib_conn->state = ISER_CONN_DOWN;604604+ mutex_unlock(&ib_conn->state_mutex);593605594606 iser_conn_release(ib_conn);595607}···610604{611605 struct iser_device *device = ib_conn->device;612606613613- BUG_ON(ib_conn->state == ISER_CONN_UP);614614-615607 mutex_lock(&ig.connlist_mutex);616608 list_del(&ib_conn->conn_list);617609 mutex_unlock(&ig.connlist_mutex);610610+611611+ mutex_lock(&ib_conn->state_mutex);612612+ BUG_ON(ib_conn->state != ISER_CONN_DOWN);613613+618614 iser_free_rx_descriptors(ib_conn);619615 iser_free_ib_conn_res(ib_conn);620616 ib_conn->device = NULL;621617 /* on EVENT_ADDR_ERROR there's no device yet for this conn */622618 if (device != NULL)623619 iser_device_try_release(device);620620+ mutex_unlock(&ib_conn->state_mutex);621621+624622 /* if cma handler context, the caller actually destroy the id */625623 if (ib_conn->cma_id != NULL) {626624 rdma_destroy_id(ib_conn->cma_id);627625 ib_conn->cma_id = NULL;628626 }629629- iscsi_destroy_endpoint(ib_conn->ep);627627+ kfree(ib_conn);630628}631629632630/**···652642 ib_conn,err);653643}654644645645+/**646646+ * Called with state mutex held647647+ **/655648static void iser_connect_error(struct rdma_cm_id *cma_id)656649{657650 struct iser_conn *ib_conn;658651659652 ib_conn = (struct iser_conn *)cma_id->context;660660-661653 ib_conn->state = ISER_CONN_DOWN;662662- wake_up_interruptible(&ib_conn->wait);663654}664655656656+/**657657+ * Called with state mutex held658658+ **/665659static void iser_addr_handler(struct rdma_cm_id *cma_id)666660{667661 struct iser_device *device;668662 struct iser_conn *ib_conn;669663 int ret;664664+665665+ ib_conn = (struct iser_conn *)cma_id->context;666666+ if (ib_conn->state != ISER_CONN_PENDING)667667+ /* bailout */668668+ return;670669671670 device = iser_device_find_by_ib_device(cma_id);672671 if (!device) {···684665 return;685666 }686667687687- ib_conn = (struct iser_conn *)cma_id->context;688668 ib_conn->device = device;689669690670 /* connection T10-PI support */···707689 }708690}709691692692+/**693693+ * Called with state mutex held694694+ **/710695static void iser_route_handler(struct rdma_cm_id *cma_id)711696{712697 struct rdma_conn_param conn_param;713698 int ret;714699 struct iser_cm_hdr req_hdr;700700+ struct iser_conn *ib_conn = (struct iser_conn *)cma_id->context;701701+ struct iser_device *device = ib_conn->device;702702+703703+ if (ib_conn->state != ISER_CONN_PENDING)704704+ /* bailout */705705+ return;715706716707 ret = iser_create_ib_conn_res((struct iser_conn *)cma_id->context);717708 if (ret)718709 goto failure;719710720711 memset(&conn_param, 0, sizeof conn_param);721721- conn_param.responder_resources = 4;712712+ conn_param.responder_resources = device->dev_attr.max_qp_rd_atom;722713 conn_param.initiator_depth = 1;723714 conn_param.retry_count = 7;724715 conn_param.rnr_retry_count = 6;···755728 struct ib_qp_attr attr;756729 struct ib_qp_init_attr init_attr;757730731731+ ib_conn = (struct iser_conn *)cma_id->context;732732+ if (ib_conn->state != ISER_CONN_PENDING)733733+ /* bailout */734734+ return;735735+758736 (void)ib_query_qp(cma_id->qp, &attr, ~0, &init_attr);759737 iser_info("remote qpn:%x my qpn:%x\n", attr.dest_qp_num, cma_id->qp->qp_num);760738761761- ib_conn = (struct iser_conn *)cma_id->context;762762- if (iser_conn_state_comp_exch(ib_conn, ISER_CONN_PENDING, ISER_CONN_UP))763763- wake_up_interruptible(&ib_conn->wait);739739+ ib_conn->state = ISER_CONN_UP;740740+ complete(&ib_conn->up_completion);764741}765742766743static void iser_disconnected_handler(struct rdma_cm_id *cma_id)···783752 iser_err("iscsi_iser connection isn't bound\n");784753 }785754786786- /* Complete the termination process if no posts are pending */755755+ /* Complete the termination process if no posts are pending. This code756756+ * block also exists in iser_handle_comp_error(), but it is needed here757757+ * for cases of no flushes at all, e.g. discovery over rdma.758758+ */787759 if (ib_conn->post_recv_buf_count == 0 &&788760 (atomic_read(&ib_conn->post_send_buf_count) == 0)) {789789- ib_conn->state = ISER_CONN_DOWN;790790- wake_up_interruptible(&ib_conn->wait);761761+ complete(&ib_conn->flush_completion);791762 }792763}793764794765static int iser_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)795766{767767+ struct iser_conn *ib_conn;768768+769769+ ib_conn = (struct iser_conn *)cma_id->context;796770 iser_info("event %d status %d conn %p id %p\n",797771 event->event, event->status, cma_id->context, cma_id);798772773773+ mutex_lock(&ib_conn->state_mutex);799774 switch (event->event) {800775 case RDMA_CM_EVENT_ADDR_RESOLVED:801776 iser_addr_handler(cma_id);···822785 case RDMA_CM_EVENT_DISCONNECTED:823786 case RDMA_CM_EVENT_DEVICE_REMOVAL:824787 case RDMA_CM_EVENT_ADDR_CHANGE:788788+ case RDMA_CM_EVENT_TIMEWAIT_EXIT:825789 iser_disconnected_handler(cma_id);826790 break;827791 default:828792 iser_err("Unexpected RDMA CM event (%d)\n", event->event);829793 break;830794 }795795+ mutex_unlock(&ib_conn->state_mutex);831796 return 0;832797}833798834799void iser_conn_init(struct iser_conn *ib_conn)835800{836801 ib_conn->state = ISER_CONN_INIT;837837- init_waitqueue_head(&ib_conn->wait);838802 ib_conn->post_recv_buf_count = 0;839803 atomic_set(&ib_conn->post_send_buf_count, 0);840804 init_completion(&ib_conn->stop_completion);805805+ init_completion(&ib_conn->flush_completion);806806+ init_completion(&ib_conn->up_completion);841807 INIT_LIST_HEAD(&ib_conn->conn_list);842808 spin_lock_init(&ib_conn->lock);809809+ mutex_init(&ib_conn->state_mutex);843810}844811845812 /**···851810 * sleeps until the connection is established or rejected852811 */853812int iser_connect(struct iser_conn *ib_conn,854854- struct sockaddr_in *src_addr,855855- struct sockaddr_in *dst_addr,813813+ struct sockaddr *src_addr,814814+ struct sockaddr *dst_addr,856815 int non_blocking)857816{858858- struct sockaddr *src, *dst;859817 int err = 0;860818861861- sprintf(ib_conn->name, "%pI4:%d",862862- &dst_addr->sin_addr.s_addr, dst_addr->sin_port);819819+ mutex_lock(&ib_conn->state_mutex);820820+821821+ sprintf(ib_conn->name, "%pISp", dst_addr);822822+823823+ iser_info("connecting to: %s\n", ib_conn->name);863824864825 /* the device is known only --after-- address resolution */865826 ib_conn->device = NULL;866866-867867- iser_info("connecting to: %pI4, port 0x%x\n",868868- &dst_addr->sin_addr, dst_addr->sin_port);869827870828 ib_conn->state = ISER_CONN_PENDING;871829···877837 goto id_failure;878838 }879839880880- src = (struct sockaddr *)src_addr;881881- dst = (struct sockaddr *)dst_addr;882882- err = rdma_resolve_addr(ib_conn->cma_id, src, dst, 1000);840840+ err = rdma_resolve_addr(ib_conn->cma_id, src_addr, dst_addr, 1000);883841 if (err) {884842 iser_err("rdma_resolve_addr failed: %d\n", err);885843 goto addr_failure;886844 }887845888846 if (!non_blocking) {889889- wait_event_interruptible(ib_conn->wait,890890- (ib_conn->state != ISER_CONN_PENDING));847847+ wait_for_completion_interruptible(&ib_conn->up_completion);891848892849 if (ib_conn->state != ISER_CONN_UP) {893850 err = -EIO;894851 goto connect_failure;895852 }896853 }854854+ mutex_unlock(&ib_conn->state_mutex);897855898856 mutex_lock(&ig.connlist_mutex);899857 list_add(&ib_conn->conn_list, &ig.connlist);···903865addr_failure:904866 ib_conn->state = ISER_CONN_DOWN;905867connect_failure:868868+ mutex_unlock(&ib_conn->state_mutex);906869 iser_conn_release(ib_conn);907870 return err;908871}···1088104910891050 if (ib_conn->post_recv_buf_count == 0 &&10901051 atomic_read(&ib_conn->post_send_buf_count) == 0) {10911091- /* getting here when the state is UP means that the conn is *10921092- * being terminated asynchronously from the iSCSI layer's *10931093- * perspective. */10941094- if (iser_conn_state_comp_exch(ib_conn, ISER_CONN_UP,10951095- ISER_CONN_TERMINATING))10521052+ /**10531053+ * getting here when the state is UP means that the conn is10541054+ * being terminated asynchronously from the iSCSI layer's10551055+ * perspective. It is safe to peek at the connection state10561056+ * since iscsi_conn_failure is allowed to be called twice.10571057+ **/10581058+ if (ib_conn->state == ISER_CONN_UP)10961059 iscsi_conn_failure(ib_conn->iscsi_conn,10971060 ISCSI_ERR_CONN_FAILED);1098106110991062 /* no more non completed posts to the QP, complete the11001063 * termination process w.o worrying on disconnect event */11011101- ib_conn->state = ISER_CONN_DOWN;11021102- wake_up_interruptible(&ib_conn->wait);10641064+ complete(&ib_conn->flush_completion);11031065 }11041066}11051067
+35-13
drivers/infiniband/ulp/srp/ib_srp.c
···130130static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event);131131132132static struct scsi_transport_template *ib_srp_transport_template;133133+static struct workqueue_struct *srp_remove_wq;133134134135static struct ib_client srp_client = {135136 .name = "srp",···732731 spin_unlock_irq(&target->lock);733732734733 if (changed)735735- queue_work(system_long_wq, &target->remove_work);734734+ queue_work(srp_remove_wq, &target->remove_work);736735737736 return changed;738737}···16441643 SCSI_SENSE_BUFFERSIZE));16451644 }1646164516471647- if (rsp->flags & (SRP_RSP_FLAG_DOOVER | SRP_RSP_FLAG_DOUNDER))16481648- scsi_set_resid(scmnd, be32_to_cpu(rsp->data_out_res_cnt));16491649- else if (rsp->flags & (SRP_RSP_FLAG_DIOVER | SRP_RSP_FLAG_DIUNDER))16461646+ if (unlikely(rsp->flags & SRP_RSP_FLAG_DIUNDER))16501647 scsi_set_resid(scmnd, be32_to_cpu(rsp->data_in_res_cnt));16481648+ else if (unlikely(rsp->flags & SRP_RSP_FLAG_DIOVER))16491649+ scsi_set_resid(scmnd, -be32_to_cpu(rsp->data_in_res_cnt));16501650+ else if (unlikely(rsp->flags & SRP_RSP_FLAG_DOUNDER))16511651+ scsi_set_resid(scmnd, be32_to_cpu(rsp->data_out_res_cnt));16521652+ else if (unlikely(rsp->flags & SRP_RSP_FLAG_DOOVER))16531653+ scsi_set_resid(scmnd, -be32_to_cpu(rsp->data_out_res_cnt));1651165416521655 srp_free_req(target, req, scmnd,16531656 be32_to_cpu(rsp->req_lim_delta));···32663261 spin_unlock(&host->target_lock);3267326232683263 /*32693269- * Wait for target port removal tasks.32643264+ * Wait for tl_err and target port removal tasks.32703265 */32713266 flush_workqueue(system_long_wq);32673267+ flush_workqueue(srp_remove_wq);3272326832733269 kfree(host);32743270 }···33193313 indirect_sg_entries = cmd_sg_entries;33203314 }3321331533163316+ srp_remove_wq = create_workqueue("srp_remove");33173317+ if (!srp_remove_wq) {33183318+ ret = -ENOMEM;33193319+ goto out;33203320+ }33213321+33223322+ ret = -ENOMEM;33223323 ib_srp_transport_template =33233324 srp_attach_transport(&ib_srp_transport_functions);33243325 if (!ib_srp_transport_template)33253325- return -ENOMEM;33263326+ goto destroy_wq;3326332733273328 ret = class_register(&srp_class);33283329 if (ret) {33293330 pr_err("couldn't register class infiniband_srp\n");33303330- srp_release_transport(ib_srp_transport_template);33313331- return ret;33313331+ goto release_tr;33323332 }3333333333343334 ib_sa_register_client(&srp_sa_client);···33423330 ret = ib_register_client(&srp_client);33433331 if (ret) {33443332 pr_err("couldn't register IB client\n");33453345- srp_release_transport(ib_srp_transport_template);33463346- ib_sa_unregister_client(&srp_sa_client);33473347- class_unregister(&srp_class);33483348- return ret;33333333+ goto unreg_sa;33493334 }3350333533513351- return 0;33363336+out:33373337+ return ret;33383338+33393339+unreg_sa:33403340+ ib_sa_unregister_client(&srp_sa_client);33413341+ class_unregister(&srp_class);33423342+33433343+release_tr:33443344+ srp_release_transport(ib_srp_transport_template);33453345+33463346+destroy_wq:33473347+ destroy_workqueue(srp_remove_wq);33483348+ goto out;33523349}3353335033543351static void __exit srp_cleanup_module(void)···33663345 ib_sa_unregister_client(&srp_sa_client);33673346 class_unregister(&srp_class);33683347 srp_release_transport(ib_srp_transport_template);33483348+ destroy_workqueue(srp_remove_wq);33693349}3370335033713351module_init(srp_init_module);
+2-1
drivers/infiniband/ulp/srpt/ib_srpt.c
···198198 case IB_EVENT_PKEY_CHANGE:199199 case IB_EVENT_SM_CHANGE:200200 case IB_EVENT_CLIENT_REREGISTER:201201+ case IB_EVENT_GID_CHANGE:201202 /* Refresh port data asynchronously. */202203 if (event->element.port_num <= sdev->device->phys_port_cnt) {203204 sport = &sdev->port[event->element.port_num - 1];···564563 ®_req, 0,565564 srpt_mad_send_handler,566565 srpt_mad_recv_handler,567567- sport);566566+ sport, 0);568567 if (IS_ERR(sport->mad_agent)) {569568 ret = PTR_ERR(sport->mad_agent);570569 sport->mad_agent = NULL;
···136136 [7] = "FSM (MAC anti-spoofing) support",137137 [8] = "Dynamic QP updates support",138138 [9] = "Device managed flow steering IPoIB support",139139- [10] = "TCP/IP offloads/flow-steering for VXLAN support"139139+ [10] = "TCP/IP offloads/flow-steering for VXLAN support",140140+ [11] = "MAD DEMUX (Secure-Host) support"140141 };141142 int i;142143···572571#define QUERY_DEV_CAP_MAX_ICM_SZ_OFFSET 0xa0573572#define QUERY_DEV_CAP_FW_REASSIGN_MAC 0x9d574573#define QUERY_DEV_CAP_VXLAN 0x9e574574+#define QUERY_DEV_CAP_MAD_DEMUX_OFFSET 0xb0575575576576 dev_cap->flags2 = 0;577577 mailbox = mlx4_alloc_cmd_mailbox(dev);···749747 if (dev_cap->flags & MLX4_DEV_CAP_FLAG_COUNTERS)750748 MLX4_GET(dev_cap->max_counters, outbox,751749 QUERY_DEV_CAP_MAX_COUNTERS_OFFSET);750750+751751+ MLX4_GET(field32, outbox,752752+ QUERY_DEV_CAP_MAD_DEMUX_OFFSET);753753+ if (field32 & (1 << 0))754754+ dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_MAD_DEMUX;752755753756 MLX4_GET(field32, outbox, QUERY_DEV_CAP_EXT_2_FLAGS_OFFSET);754757 if (field32 & (1 << 16))···2022201520232016out:20242017 mlx4_free_cmd_mailbox(dev, mailbox);20182018+}20192019+20202020+static int mlx4_check_smp_firewall_active(struct mlx4_dev *dev,20212021+ struct mlx4_cmd_mailbox *mailbox)20222022+{20232023+#define MLX4_CMD_MAD_DEMUX_SET_ATTR_OFFSET 0x1020242024+#define MLX4_CMD_MAD_DEMUX_GETRESP_ATTR_OFFSET 0x2020252025+#define MLX4_CMD_MAD_DEMUX_TRAP_ATTR_OFFSET 0x4020262026+#define MLX4_CMD_MAD_DEMUX_TRAP_REPRESS_ATTR_OFFSET 0x7020272027+20282028+ u32 set_attr_mask, getresp_attr_mask;20292029+ u32 trap_attr_mask, traprepress_attr_mask;20302030+20312031+ MLX4_GET(set_attr_mask, mailbox->buf,20322032+ MLX4_CMD_MAD_DEMUX_SET_ATTR_OFFSET);20332033+ mlx4_dbg(dev, "SMP firewall set_attribute_mask = 0x%x\n",20342034+ set_attr_mask);20352035+20362036+ MLX4_GET(getresp_attr_mask, mailbox->buf,20372037+ MLX4_CMD_MAD_DEMUX_GETRESP_ATTR_OFFSET);20382038+ mlx4_dbg(dev, "SMP firewall getresp_attribute_mask = 0x%x\n",20392039+ getresp_attr_mask);20402040+20412041+ MLX4_GET(trap_attr_mask, mailbox->buf,20422042+ MLX4_CMD_MAD_DEMUX_TRAP_ATTR_OFFSET);20432043+ mlx4_dbg(dev, "SMP firewall trap_attribute_mask = 0x%x\n",20442044+ trap_attr_mask);20452045+20462046+ MLX4_GET(traprepress_attr_mask, mailbox->buf,20472047+ MLX4_CMD_MAD_DEMUX_TRAP_REPRESS_ATTR_OFFSET);20482048+ mlx4_dbg(dev, "SMP firewall traprepress_attribute_mask = 0x%x\n",20492049+ traprepress_attr_mask);20502050+20512051+ if (set_attr_mask && getresp_attr_mask && trap_attr_mask &&20522052+ traprepress_attr_mask)20532053+ return 1;20542054+20552055+ return 0;20562056+}20572057+20582058+int mlx4_config_mad_demux(struct mlx4_dev *dev)20592059+{20602060+ struct mlx4_cmd_mailbox *mailbox;20612061+ int secure_host_active;20622062+ int err;20632063+20642064+ /* Check if mad_demux is supported */20652065+ if (!(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_MAD_DEMUX))20662066+ return 0;20672067+20682068+ mailbox = mlx4_alloc_cmd_mailbox(dev);20692069+ if (IS_ERR(mailbox)) {20702070+ mlx4_warn(dev, "Failed to allocate mailbox for cmd MAD_DEMUX");20712071+ return -ENOMEM;20722072+ }20732073+20742074+ /* Query mad_demux to find out which MADs are handled by internal sma */20752075+ err = mlx4_cmd_box(dev, 0, mailbox->dma, 0x01 /* subn mgmt class */,20762076+ MLX4_CMD_MAD_DEMUX_QUERY_RESTR, MLX4_CMD_MAD_DEMUX,20772077+ MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);20782078+ if (err) {20792079+ mlx4_warn(dev, "MLX4_CMD_MAD_DEMUX: query restrictions failed (%d)\n",20802080+ err);20812081+ goto out;20822082+ }20832083+20842084+ secure_host_active = mlx4_check_smp_firewall_active(dev, mailbox);20852085+20862086+ /* Config mad_demux to handle all MADs returned by the query above */20872087+ err = mlx4_cmd(dev, mailbox->dma, 0x01 /* subn mgmt class */,20882088+ MLX4_CMD_MAD_DEMUX_CONFIG, MLX4_CMD_MAD_DEMUX,20892089+ MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);20902090+ if (err) {20912091+ mlx4_warn(dev, "MLX4_CMD_MAD_DEMUX: configure failed (%d)\n", err);20922092+ goto out;20932093+ }20942094+20952095+ if (secure_host_active)20962096+ mlx4_warn(dev, "HCA operating in secure-host mode. SMP firewall activated.\n");20972097+out:20982098+ mlx4_free_cmd_mailbox(dev, mailbox);20992099+ return err;20252100}
+5
drivers/net/ethernet/mellanox/mlx4/main.c
···18311831 mlx4_err(dev, "Failed to initialize multicast group table, aborting\n");18321832 goto err_mr_table_free;18331833 }18341834+ err = mlx4_config_mad_demux(dev);18351835+ if (err) {18361836+ mlx4_err(dev, "Failed in config_mad_demux, aborting\n");18371837+ goto err_mcg_table_free;18381838+ }18341839 }1835184018361841 err = mlx4_init_eq_table(dev);
+1
drivers/net/ethernet/mellanox/mlx4/mlx4.h
···13131313int mlx4_get_slave_num_gids(struct mlx4_dev *dev, int slave, int port);13141314/* Returns the VF index of slave */13151315int mlx4_get_vf_indx(struct mlx4_dev *dev, int slave);13161316+int mlx4_config_mad_demux(struct mlx4_dev *dev);1316131713171318#endif /* MLX4_H */
+2-1
drivers/scsi/scsi_transport_srp.c
···473473 if (delay > 0)474474 queue_delayed_work(system_long_wq, &rport->reconnect_work,475475 1UL * delay * HZ);476476- if (srp_rport_set_state(rport, SRP_RPORT_BLOCKED) == 0) {476476+ if ((fast_io_fail_tmo >= 0 || dev_loss_tmo >= 0) &&477477+ srp_rport_set_state(rport, SRP_RPORT_BLOCKED) == 0) {477478 pr_debug("%s new state: %d\n", dev_name(&shost->shost_gendev),478479 rport->state);479480 scsi_target_block(&shost->shost_gendev);
···4040#include <linux/list.h>41414242#include <rdma/ib_verbs.h>4343+#include <uapi/rdma/ib_user_mad.h>43444445/* Management base version */4546#define IB_MGMT_BASE_VERSION 1···356355 * @hi_tid: Access layer assigned transaction ID for this client.357356 * Unsolicited MADs sent by this client will have the upper 32-bits358357 * of their TID set to this value.358358+ * @flags: registration flags359359 * @port_num: Port number on which QP is registered360360 * @rmpp_version: If set, indicates the RMPP version used by this agent.361361 */362362+enum {363363+ IB_MAD_USER_RMPP = IB_USER_MAD_USER_RMPP,364364+};362365struct ib_mad_agent {363366 struct ib_device *device;364367 struct ib_qp *qp;···372367 ib_mad_snoop_handler snoop_handler;373368 void *context;374369 u32 hi_tid;370370+ u32 flags;375371 u8 port_num;376372 u8 rmpp_version;377373};···432426 * in the range from 0x30 to 0x4f. Otherwise not used.433427 * @method_mask: The caller will receive unsolicited MADs for any method434428 * where @method_mask = 1.429429+ *435430 */436431struct ib_mad_reg_req {437432 u8 mgmt_class;···458451 * @recv_handler: The completion callback routine invoked for a received459452 * MAD.460453 * @context: User specified context associated with the registration.454454+ * @registration_flags: Registration flags to set for this agent461455 */462456struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,463457 u8 port_num,···467459 u8 rmpp_version,468460 ib_mad_send_handler send_handler,469461 ib_mad_recv_handler recv_handler,470470- void *context);462462+ void *context,463463+ u32 registration_flags);471464472465enum ib_mad_snoop_flags {473466 /*IB_MAD_SNOOP_POSTED_SENDS = 1,*/···669660 * @send_buf: Previously allocated send data buffer.670661 */671662void ib_free_send_mad(struct ib_mad_send_buf *send_buf);663663+664664+/**665665+ * ib_mad_kernel_rmpp_agent - Returns if the agent is performing RMPP.666666+ * @agent: the agent in question667667+ * @return: true if agent is performing rmpp, false otherwise.668668+ */669669+int ib_mad_kernel_rmpp_agent(struct ib_mad_agent *agent);672670673671#endif /* IB_MAD_H */
+42
include/uapi/rdma/ib_user_mad.h
···191191 __u8 rmpp_version;192192};193193194194+/**195195+ * ib_user_mad_reg_req2 - MAD registration request196196+ *197197+ * @id - Set by the _kernel_; used by userspace to identify the198198+ * registered agent in future requests.199199+ * @qpn - Queue pair number; must be 0 or 1.200200+ * @mgmt_class - Indicates which management class of MADs should be201201+ * receive by the caller. This field is only required if202202+ * the user wishes to receive unsolicited MADs, otherwise203203+ * it should be 0.204204+ * @mgmt_class_version - Indicates which version of MADs for the given205205+ * management class to receive.206206+ * @res - Ignored.207207+ * @flags - additional registration flags; Must be in the set of208208+ * flags defined in IB_USER_MAD_REG_FLAGS_CAP209209+ * @method_mask - The caller wishes to receive unsolicited MADs for the210210+ * methods whose bit(s) is(are) set.211211+ * @oui - Indicates IEEE OUI to use when mgmt_class is a vendor212212+ * class in the range from 0x30 to 0x4f. Otherwise not213213+ * used.214214+ * @rmpp_version - If set, indicates the RMPP version to use.215215+ */216216+enum {217217+ IB_USER_MAD_USER_RMPP = (1 << 0),218218+};219219+#define IB_USER_MAD_REG_FLAGS_CAP (IB_USER_MAD_USER_RMPP)220220+struct ib_user_mad_reg_req2 {221221+ __u32 id;222222+ __u32 qpn;223223+ __u8 mgmt_class;224224+ __u8 mgmt_class_version;225225+ __u16 res;226226+ __u32 flags;227227+ __u64 method_mask[2];228228+ __u32 oui;229229+ __u8 rmpp_version;230230+ __u8 reserved[3];231231+};232232+194233#define IB_IOCTL_MAGIC 0x1b195234196235#define IB_USER_MAD_REGISTER_AGENT _IOWR(IB_IOCTL_MAGIC, 1, \···238199#define IB_USER_MAD_UNREGISTER_AGENT _IOW(IB_IOCTL_MAGIC, 2, __u32)239200240201#define IB_USER_MAD_ENABLE_PKEY _IO(IB_IOCTL_MAGIC, 3)202202+203203+#define IB_USER_MAD_REGISTER_AGENT2 _IOWR(IB_IOCTL_MAGIC, 4, \204204+ struct ib_user_mad_reg_req2)241205242206#endif /* IB_USER_MAD_H */