From bc7ec5cc70f27d432cf32764bd7798fad0acb99b Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Tue, 25 Jan 2011 13:52:06 -0800 Subject: [PATCH] refresh --- meta | 7 +- patches/ep_active | 246 +++++++++++++++++++++++++++++++++++++++++- patches/refresh-temp | 252 ------------------------------------------- 3 files changed, 247 insertions(+), 258 deletions(-) delete mode 100644 patches/refresh-temp diff --git a/meta b/meta index fc6411f..98fd5b3 100644 --- a/meta +++ b/meta @@ -1,11 +1,10 @@ Version: 1 -Previous: 160038dbef4993e975e7ffc5c040c81ac0862172 -Head: 5f05a809163f29d75e0d619ba1fcecec20a97e6c +Previous: ba2eeb5137e0f740ed802641aa1730b26cb99b88 +Head: 38eedd0ad594487b25d55c54212b5571480deb95 Applied: addr_open: 1fd2bfd86e2e2fe78f9d5d6d39aa5502938923f0 open_dev: 4687a6571146acd8d9a1553a96e2e4f7e8318761 - ep_active: 50169b7dea41041cdd04d42d7fb3b6e2cecdd8d2 - refresh-temp: 5f05a809163f29d75e0d619ba1fcecec20a97e6c + ep_active: 38eedd0ad594487b25d55c54212b5571480deb95 Unapplied: autoaddr: 36281f18de15f2482e21ae1304f2e34e9ecf187d async_mc: c51c6e84981821b2541daba97cee9a29cd1d3709 diff --git a/patches/ep_active b/patches/ep_active index 1eae360..54e69c8 100644 --- a/patches/ep_active +++ b/patches/ep_active @@ -1,5 +1,5 @@ Bottom: fb1d0cc95bf413473d6098cbb67824845146864e -Top: fb1d0cc95bf413473d6098cbb67824845146864e +Top: 5d77ccab732b248e36bffb1e4801f9c26c3fe7e2 Author: Sean Hefty Date: 2011-01-20 17:06:28 -0800 @@ -23,4 +23,246 @@ Signed-off-by: Sean Hefty --- - +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"); diff --git a/patches/refresh-temp b/patches/refresh-temp deleted file mode 100644 index 865c36c..0000000 --- a/patches/refresh-temp +++ /dev/null @@ -1,252 +0,0 @@ -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"); -- 2.41.0