From: Sean Hefty Date: Tue, 25 Jan 2011 21:52:06 +0000 (-0800) Subject: refresh (create temporary patch) X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=a13c46917437c9f0c21af0459cb98103f3fc1f6f;p=~shefty%2Fibacm.git refresh (create temporary patch) --- diff --git a/meta b/meta index 354f58d..fc6411f 100644 --- a/meta +++ b/meta @@ -1,10 +1,11 @@ Version: 1 -Previous: fb01b1c436db445184494c8071a3a7ea8f1db296 -Head: 50169b7dea41041cdd04d42d7fb3b6e2cecdd8d2 +Previous: 160038dbef4993e975e7ffc5c040c81ac0862172 +Head: 5f05a809163f29d75e0d619ba1fcecec20a97e6c Applied: addr_open: 1fd2bfd86e2e2fe78f9d5d6d39aa5502938923f0 open_dev: 4687a6571146acd8d9a1553a96e2e4f7e8318761 ep_active: 50169b7dea41041cdd04d42d7fb3b6e2cecdd8d2 + refresh-temp: 5f05a809163f29d75e0d619ba1fcecec20a97e6c Unapplied: autoaddr: 36281f18de15f2482e21ae1304f2e34e9ecf187d async_mc: c51c6e84981821b2541daba97cee9a29cd1d3709 diff --git a/patches/refresh-temp b/patches/refresh-temp new file mode 100644 index 0000000..865c36c --- /dev/null +++ b/patches/refresh-temp @@ -0,0 +1,252 @@ +Bottom: fb1d0cc95bf413473d6098cbb67824845146864e +Top: 5d77ccab732b248e36bffb1e4801f9c26c3fe7e2 +Author: Sean Hefty +Date: 2011-01-25 13:52:06 -0800 + +Refresh of ep_active + +--- + +diff --git a/src/acm.c b/src/acm.c +index f21f702..6515185 100644 +--- a/src/acm.c ++++ b/src/acm.c +@@ -294,15 +294,22 @@ static int acm_compare_dest(const void *dest1, const void *dest2) + } + + static void +-acm_init_dest(struct acm_dest *dest, uint8_t addr_type, uint8_t *addr, size_t size) ++acm_set_dest_addr(struct acm_dest *dest, uint8_t addr_type, uint8_t *addr, size_t size) + { + memcpy(dest->address, addr, size); + dest->addr_type = addr_type; ++ acm_format_name(0, dest->name, sizeof dest->name, addr_type, addr, size); ++} ++ ++static void ++acm_init_dest(struct acm_dest *dest, uint8_t addr_type, uint8_t *addr, size_t size) ++{ + DListInit(&dest->req_queue); + atomic_init(&dest->refcnt); + atomic_set(&dest->refcnt, 1); + lock_init(&dest->lock); +- acm_format_name(0, dest->name, sizeof dest->name, addr_type, addr, size); ++ if (size) ++ acm_set_dest_addr(dest, addr_type, addr, size); + } + + static struct acm_dest * +@@ -2647,37 +2654,7 @@ err1: + port->state = IBV_PORT_NOP; + } + +-static int acm_activate_dev(struct acm_device *dev) +-{ +- int i; +- +- acm_log(1, "%s\n", dev->verbs->device->name); +- dev->pd = ibv_alloc_pd(dev->verbs); +- if (!dev->pd) +- return ACM_STATUS_ENOMEM; +- +- dev->channel = ibv_create_comp_channel(dev->verbs); +- if (!dev->channel) { +- acm_log(0, "ERROR - unable to create comp channel\n"); +- goto err; +- } +- +- for (i = 0; i < dev->port_cnt; i++) { +- acm_log(2, "checking port %d\n", dev->port[i].port_num); +- if (dev->port[i].state == IBV_PORT_ACTIVE) +- acm_activate_port(&dev->port[i]); +- } +- +- acm_log(1, "starting completion thread\n"); +- beginthread(acm_comp_handler, dev); +- return 0; +- +-err: +- ibv_dealloc_pd(dev->pd); +- return -1; +-} +- +-static void acm_init_port(struct acm_port *port) ++static void acm_open_port(struct acm_port *port) + { + struct ibv_port_attr attr; + union ibv_gid gid; +@@ -2685,10 +2662,8 @@ static void acm_init_port(struct acm_port *port) + int ret; + + acm_log(1, "%s %d\n", port->dev->verbs->device->name, port->port_num); +- lock_init(&port->lock); +- DListInit(&port->ep_list); + ret = ibv_query_port(port->dev->verbs, port->port_num, &attr); +- if (ret) ++ if (ret || attr.state != IBV_PORT_ACTIVE) + return; + + port->state = attr.state; +@@ -2709,7 +2684,7 @@ static void acm_init_port(struct acm_port *port) + port->lid = attr.lid; + port->lid_mask = 0xffff - ((1 << attr.lmc) - 1); + +- acm_init_dest(&port->sa_dest, ACM_ADDRESS_LID, ++ acm_set_dest_addr(&port->sa_dest, ACM_ADDRESS_LID, + (uint8_t *) &attr.sm_lid, sizeof(attr.sm_lid)); + port->sa_dest.av.src_path_bits = 0; + port->sa_dest.av.dlid = attr.sm_lid; +@@ -2718,6 +2693,54 @@ static void acm_init_port(struct acm_port *port) + port->sa_dest.remote_qpn = 1; + } + ++static void CDECL_FUNC acm_event_handler(void *context) ++{ ++ struct acm_device *dev = (struct acm_device *) context; ++} ++ ++static void acm_join_groups(void) ++{ ++ struct acm_device *dev; ++ struct acm_port *port; ++ DLIST_ENTRY *dev_entry; ++ int i; ++ ++ acm_log(1, "initiating multicast joins for all ports\n"); ++ for (dev_entry = dev_list.Next; dev_entry != &dev_list; ++ dev_entry = dev_entry->Next) { ++ ++ dev = container_of(dev_entry, struct acm_device, entry); ++ ++ for (i = 0; i < dev->port_cnt; i++) { ++ port = &dev->port[i]; ++ if (port->state != IBV_PORT_ACTIVE) ++ continue; ++ ++ acm_log(1, "starting join for device %s, port %d\n", ++ dev->verbs->device->name, port->port_num); ++ // TODO: handle dynamic changes ++ //beginthread(acm_port_join, port); ++ acm_port_join(port); ++ } ++ } ++} ++static void acm_activate_dev(struct acm_device *dev) ++{ ++ acm_log(1, "\n"); ++ beginthread(acm_event_handler, dev); ++ beginthread(acm_comp_handler, dev); ++} ++ ++static void acm_init_port(struct acm_port *port, struct acm_device *dev, uint8_t port_num) ++{ ++ acm_log(1, "%s %d\n", dev->verbs->device->name, port_num); ++ port->dev = dev; ++ port->port_num = port_num; ++ lock_init(&port->lock); ++ DListInit(&port->ep_list); ++ acm_init_dest(&port->sa_dest, ACM_ADDRESS_LID, NULL, 0); ++} ++ + static void acm_open_dev(struct ibv_device *ibdev) + { + struct acm_device *dev; +@@ -2748,25 +2771,59 @@ static void acm_open_dev(struct ibv_device *ibdev) + dev->guid = ibv_get_device_guid(ibdev); + dev->port_cnt = attr.phys_port_cnt; + +- for (i = 0; i < dev->port_cnt; i++) { +- dev->port[i].dev = dev; +- dev->port[i].port_num = i + 1; +- acm_init_port(&dev->port[i]); ++ dev->pd = ibv_alloc_pd(dev->verbs); ++ if (!dev->pd) { ++ acm_log(0, "ERROR - unable to allocate PD\n"); ++ goto err2; + } + +- if (acm_activate_dev(dev)) +- goto err2; ++ dev->channel = ibv_create_comp_channel(dev->verbs); ++ if (!dev->channel) { ++ acm_log(0, "ERROR - unable to create comp channel\n"); ++ goto err3; ++ } ++ ++ for (i = 0; i < dev->port_cnt; i++) ++ acm_init_port(&dev->port[i], dev, i + 1); + +- acm_log(1, "%s opened\n", ibdev->name); + DListInsertHead(&dev->entry, &dev_list); ++ ++ acm_log(1, "%s opened\n", ibdev->name); + return; + ++err3: ++ ibv_dealloc_pd(dev->pd); + err2: + free(dev); + err1: + ibv_close_device(verbs); + } + ++static int acm_open_devices(void) ++{ ++ struct ibv_device **ibdev; ++ int dev_cnt; ++ int i; ++ ++ acm_log(1, "\n"); ++ ibdev = ibv_get_device_list(&dev_cnt); ++ if (!ibdev) { ++ acm_log(0, "ERROR - unable to get device list\n"); ++ return -1; ++ } ++ ++ for (i = 0; i < dev_cnt; i++) ++ acm_open_dev(ibdev[i]); ++ ++ ibv_free_device_list(ibdev); ++ if (DListEmpty(&dev_list)) { ++ acm_log(0, "ERROR - no devices\n"); ++ return -1; ++ } ++ ++ return 0; ++} ++ + static void acm_set_options(void) + { + FILE *f; +@@ -2965,25 +3022,15 @@ int CDECL_FUNC main(int argc, char **argv) + event_init(&timeout_event); + + umad_init(); +- ibdev = ibv_get_device_list(&dev_cnt); +- if (!ibdev) { +- acm_log(0, "ERROR - unable to get device list\n"); +- return -1; +- } +- +- acm_log(1, "opening devices\n"); +- for (i = 0; i < dev_cnt; i++) +- acm_open_dev(ibdev[i]); +- +- ibv_free_device_list(ibdev); +- if (DListEmpty(&dev_list)) { +- acm_log(0, "ERROR - no devices\n"); ++ if (acm_open_devices()) { ++ acm_log(0, "ERROR - unable to open any devices\n"); + return -1; + } + +- acm_log(1, "initiating multicast joins\n"); +- acm_join_groups(); +- acm_log(1, "multicast joins done\n"); ++// acm_log(1, "initiating multicast joins\n"); ++ acm_activate_devices(); ++// acm_join_groups(); ++// acm_log(1, "multicast joins done\n"); + acm_log(1, "starting timeout/retry thread\n"); + beginthread(acm_retry_handler, NULL); + acm_log(1, "starting server\n");