From 402657854f2b9df79e972fdda871743f00400595 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 23 Feb 2011 16:50:10 -0800 Subject: [PATCH] refresh (create temporary patch) --- meta | 5 +- patches/refresh-temp | 169 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 patches/refresh-temp diff --git a/meta b/meta index 4026768..841d2da 100644 --- a/meta +++ b/meta @@ -1,6 +1,6 @@ Version: 1 -Previous: 961e2c46838c721f9696426be135abf59964571c -Head: 2c5102e66c464b5516c0042add768e774254b7ce +Previous: 81d1c940131f061809a7013bbd7b01d89c43ebcb +Head: b931fa32f8190d2a6c6e055f58167e9947d7b9ad Applied: addr_open: 1fd2bfd86e2e2fe78f9d5d6d39aa5502938923f0 open_dev: 4687a6571146acd8d9a1553a96e2e4f7e8318761 @@ -8,6 +8,7 @@ Applied: sm_lid: eb7c2092cc0a44cf84428c536c9dd65da97b8069 sm_lid_get: dc8017769d3dfcbd85ae7ec037c871ac476a4c2d port_up: 2c5102e66c464b5516c0042add768e774254b7ce + refresh-temp: b931fa32f8190d2a6c6e055f58167e9947d7b9ad Unapplied: port_down: 8208380a044b1c2c1fc5c7a9732169b8a5e42430 autoaddr: 36281f18de15f2482e21ae1304f2e34e9ecf187d diff --git a/patches/refresh-temp b/patches/refresh-temp new file mode 100644 index 0000000..644b688 --- /dev/null +++ b/patches/refresh-temp @@ -0,0 +1,169 @@ +Bottom: a26b996b6ad8b504352351b10c17639e2292c170 +Top: 28bffa69a25094b9fce611952901c92c0f397e10 +Author: Sean Hefty +Date: 2011-02-23 16:50:10 -0800 + +Refresh of port_up + +--- + +diff --git a/src/acm.c b/src/acm.c +index af18c3d..624c3d3 100644 +--- a/src/acm.c ++++ b/src/acm.c +@@ -2499,14 +2499,35 @@ static int acm_init_ep_loopback(struct acm_ep *ep) + return 0; + } + +-static int acm_ep_up(struct acm_port *port, struct acm_ep *ep, uint16_t pkey_index) ++static acm_ep *acm_find_ep(struct acm_port *port, uint16_t pkey) + { +- struct ibv_qp_init_attr init_attr; +- struct ibv_qp_attr attr; +- int ret, sq_size; ++ struct acm_ep *ep, *res = NULL; ++ DLIST_ENTRY *entry; ++ ++ acm_log(2, "pkey %d\n", pkey); ++ ++ lock_acquire(&port->lock); ++ for (entry = port->ep_list.Next; entry != &port->ep_list; entry = entry->Next) { ++ ep = container_of(ep_entry, struct acm_ep, entry); ++ if (ep->pkey == pkey) { ++ res = ep; ++ break; ++ } ++ } ++ lock_release(&port->lock); ++ return res; ++} ++ ++static struct acm_alloc_ep(struct acm_port *port, uint16_t pkey, uint16_t pkey_index) ++{ ++ struct acm_ep *ep; ++ ++ ep = calloc(1, sizeof *ep); ++ if (!ep) ++ return NULL; + +- acm_log(1, "\n"); + ep->port = port; ++ ep->pkey = pkey; + ep->pkey_index = pkey_index; + ep->resolve_queue.credits = resolve_depth; + ep->sa_queue.credits = sa_depth; +@@ -2517,15 +2538,33 @@ static int acm_ep_up(struct acm_port *port, struct acm_ep *ep, uint16_t pkey_ind + DListInit(&ep->active_queue); + DListInit(&ep->wait_queue); + lock_init(&ep->lock); ++ return ep; ++} + +- ret = ibv_query_pkey(port->dev->verbs, port->port_num, pkey_index, &ep->pkey); ++static void acm_ep_up(struct acm_port *port, uint16_t pkey_index) ++{ ++ struct acm_ep *ep; ++ struct ibv_qp_init_attr init_attr; ++ struct ibv_qp_attr attr; ++ int ret, sq_size; ++ uint16_t pkey; ++ ++ acm_log(1, "\n"); ++ ret = ibv_query_pkey(port->dev->verbs, port->port_num, pkey_index, &pkey); + if (ret) +- return ACM_STATUS_EINVAL; ++ return; ++ ++ if (acm_find_ep(port, pkey)) ++ return; ++ ++ ep = acm_alloc_ep(port, pkey, pkey_index); ++ if (!ep) ++ return; + + ret = acm_assign_ep_names(ep); + if (ret) { + acm_log(0, "ERROR - unable to assign EP name\n"); +- return ret; ++ goto err0; + } + + sq_size = resolve_depth + sa_depth + send_depth; +@@ -2533,7 +2572,7 @@ static int acm_ep_up(struct acm_port *port, struct acm_ep *ep, uint16_t pkey_ind + ep, port->dev->channel, 0); + if (!ep->cq) { + acm_log(0, "ERROR - failed to create CQ\n"); +- return -1; ++ goto err0; + } + + ret = ibv_req_notify_cq(ep->cq, 0); +@@ -2593,13 +2632,17 @@ static int acm_ep_up(struct acm_port *port, struct acm_ep *ep, uint16_t pkey_ind + acm_log(0, "ERROR - unable to init loopback\n"); + goto err2; + } +- return 0; ++ lock_acquire(&port->lock); ++ DListInsertHead(&ep->entry, &port->ep_list); ++ lock_release(&port->lock); ++ return; + + err2: + ibv_destroy_qp(ep->qp); + err1: + ibv_destroy_cq(ep->cq); +- return -1; ++err0: ++ free(ep); + } + + static void acm_port_up(struct acm_port *port) +@@ -2611,6 +2654,9 @@ static void acm_port_up(struct acm_port *port) + int i, ret; + + acm_log(1, "%s %d\n", port->dev->verbs->device->name, port->port_num); ++ if (port->state == IBV_PORT_ACTIVE) ++ return; ++ + ret = ibv_query_port(port->dev->verbs, port->port_num, &attr); + if (ret) { + acm_log(0, "ERROR - unable to get port state\n"); +@@ -2624,13 +2670,13 @@ static void acm_port_up(struct acm_port *port) + port->mtu = attr.active_mtu; + port->rate = acm_get_rate(attr.active_width, attr.active_speed); + port->subnet_timeout = 1 << (attr.subnet_timeout - 8); +- for (;; port->gid_cnt++) { ++ for (port->gid_cnt = 0;; port->gid_cnt++) { + ret = ibv_query_gid(port->dev->verbs, port->port_num, port->gid_cnt, &gid); + if (ret || !gid.global.interface_id) + break; + } + +- for (;; port->pkey_cnt++) { ++ for (port->pkey_cnt = 0;; port->pkey_cnt++) { + ret = ibv_query_pkey(port->dev->verbs, port->port_num, port->pkey_cnt, &pkey); + if (ret || !pkey) + break; +@@ -2651,20 +2697,8 @@ static void acm_port_up(struct acm_port *port) + if (!port->sa_dest.ah) + return; + +- for (i = 0; i < port->pkey_cnt; i++) { +- /* TODO: Check if endpoint already exists in port list */ +- ep = calloc(1, sizeof *ep); +- if (!ep) +- break; +- +- ret = acm_ep_up(port, ep, (uint16_t) i); +- if (!ret) { +- DListInsertHead(&ep->entry, &port->ep_list); +- } else { +- acm_log(0, "ERROR - failed to activate EP\n"); +- free(ep); +- } +- } ++ for (i = 0; i < port->pkey_cnt; i++) ++ acm_ep_up(port, ep, (uint16_t) i); + + acm_port_join(port); + lock_acquire(&port->lock); -- 2.46.0