struct acmp_port *port;
struct acm_endpoint endpoint;
struct acm_addr addr_info[MAX_EP_ADDR];
+ lock_t lock;
};
struct acmp_ep {
static struct acm_device *
acm_get_device_from_gid(union ibv_gid *sgid, uint8_t *port);
-static struct acmp_ep *acm_find_ep(struct acmp_port *port, uint16_t pkey);
-static int acm_ep_insert_addr(struct acmp_ep *ep, const char *name, uint8_t *addr,
+static struct acm_ep *acm_find_ep(struct acmp_port *port, uint16_t pkey);
+static int acm_ep_insert_addr(struct acm_ep *ep, const char *name, uint8_t *addr,
size_t addr_len, uint8_t addr_type);
/*
lock_release(&ep->lock);
}
-static void acm_mark_addr_invalid(struct acmp_ep *ep,
+static void acm_mark_addr_invalid(struct acm_ep *ep,
struct acm_ep_addr_data *data)
{
int i;
lock_acquire(&ep->lock);
for (i = 0; i < MAX_EP_ADDR; i++) {
- if (ep->ep->addr_info[i].addr.type != data->type)
+ if (ep->addr_info[i].addr.type != data->type)
continue;
if ((data->type == ACM_ADDRESS_NAME &&
- !strnicmp((char *) ep->ep->addr_info[i].addr.info.name,
+ !strnicmp((char *) ep->addr_info[i].addr.info.name,
(char *) data->info.addr, ACM_MAX_ADDRESS)) ||
- !memcmp(ep->ep->addr_info[i].addr.info.addr, data->info.addr,
+ !memcmp(ep->addr_info[i].addr.info.addr, data->info.addr,
ACM_MAX_ADDRESS)) {
- ep->ep->addr_info[i].addr.type = ACM_ADDRESS_INVALID;
+ ep->addr_info[i].addr.type = ACM_ADDRESS_INVALID;
break;
}
}
return;
}
- addr = acm_addr_lookup(&ep->ep->endpoint, rec->dest, rec->dest_type);
+ addr = acm_addr_lookup(ep->endpoint, rec->dest, rec->dest_type);
if (addr)
dest->req_id = mad->tid;
return 0;
}
-static struct acmp_ep *
+static struct acm_ep *
acm_get_port_ep(struct acmp_port *port, struct acm_ep_addr_data *data)
{
struct acmp_ep *ep;
ep = container_of(ep_entry, struct acmp_ep, entry);
if ((data->type == ACM_EP_INFO_PATH) &&
(!data->info.path.pkey || (ntohs(data->info.path.pkey) == ep->pkey)))
- return ep;
+ return ep->ep;
- if (acm_addr_lookup(&ep->ep->endpoint, data->info.addr,
+ if (acm_addr_lookup(ep->endpoint, data->info.addr,
(uint8_t) data->type))
- return ep;
+ return ep->ep;
}
return NULL;
}
-static struct acmp_ep *
-acm_get_ep(struct acm_ep_addr_data *data)
+static struct acm_ep *acm_get_ep(struct acm_ep_addr_data *data)
{
struct acm_device *dev;
- struct acmp_ep *ep;
+ struct acm_ep *ep;
DLIST_ENTRY *dev_entry;
int i;
static int
acm_svr_query_path(struct acm_client *client, struct acm_msg *msg)
{
- struct acmp_ep *ep;
+ struct acm_ep *ep;
acm_log(2, "client %d\n", client->index);
if (msg->hdr.length != ACM_MSG_HDR_LENGTH + ACM_MSG_EP_LENGTH) {
return acm_query_response(client->index, msg, ACM_STATUS_ESRCADDR);
}
- return ep->port->prov->query(ep->endpoint, msg, client->index);
+ return ep->port->prov->query(&ep->endpoint, msg, client->index);
}
static int
static int
acm_svr_resolve_dest(struct acm_client *client, struct acm_msg *msg)
{
- struct acmp_ep *ep;
+ struct acm_ep *ep;
struct acm_ep_addr_data *saddr, *daddr;
uint8_t status;
ACM_STATUS_ESRCADDR);
}
- return ep->port->prov->resolve(ep->endpoint, msg, client->index);
+ return ep->port->prov->resolve(&ep->endpoint, msg, client->index);
}
static int
static int
acm_svr_resolve_path(struct acm_client *client, struct acm_msg *msg)
{
- struct acmp_ep *ep;
+ struct acm_ep *ep;
struct ibv_path_record *path;
acm_log(2, "client %d\n", client->index);
ACM_STATUS_ESRCADDR);
}
- return ep->port->prov->resolve(ep->endpoint, msg, client->index);
+ return ep->port->prov->resolve(&ep->endpoint, msg, client->index);
}
static int
static void acm_add_ep_ip(char *ifname, struct acm_ep_addr_data *data, char *ip_str)
{
- struct acmp_ep *ep;
+ struct acm_ep *ep;
struct acm_device *dev;
uint8_t port_num;
uint16_t pkey;
static void acm_rm_ep_ip(struct acm_ep_addr_data *data)
{
- struct acmp_ep *ep;
+ struct acm_ep *ep;
ep = acm_get_ep(data);
if (ep) {
{
int ret = EINVAL;
struct acm_device *dev;
- struct acmp_ep *ep = NULL;
+ struct acm_ep *ep;
uint8_t port_num;
char gid_str[INET6_ADDRSTRLEN];
dev = acm_get_device_from_gid(gid, &port_num);
- if (dev)
+ if (dev) {
ep = acm_find_ep(&dev->port[port_num - 1], pkey);
-
- if (ep)
- ret = acm_ep_insert_addr(ep, ip_str, addr, addr_len, addr_type);
+ if (ep)
+ ret = acm_ep_insert_addr(ep, ip_str, addr, addr_len, addr_type);
+ }
if (ret) {
inet_ntop(AF_INET6, gid->raw, gid_str, sizeof(gid_str));
}
static int
-acm_ep_insert_addr(struct acmp_ep *ep, const char *name, uint8_t *addr,
+acm_ep_insert_addr(struct acm_ep *ep, const char *name, uint8_t *addr,
size_t addr_len, uint8_t addr_type)
{
int i, ret;
memcpy(tmp, addr, addr_len);
lock_acquire(&ep->lock);
- if (!acm_addr_lookup(&ep->ep->endpoint, addr, addr_type)) {
+ if (!acm_addr_lookup(&ep->endpoint, addr, addr_type)) {
for (i = 0; (i < MAX_EP_ADDR) &&
- (ep->ep->addr_info[i].addr.type != ACM_ADDRESS_INVALID); i++)
+ (ep->addr_info[i].addr.type != ACM_ADDRESS_INVALID); i++)
;
if (i == MAX_EP_ADDR) {
ret = ENOMEM;
goto out;
}
- ep->ep->addr_info[i].addr.type = addr_type;
- strncpy(ep->ep->addr_info[i].string_buf, name, ACM_MAX_ADDRESS);
- memcpy(ep->ep->addr_info[i].addr.info.addr, tmp, ACM_MAX_ADDRESS);
+ ep->addr_info[i].addr.type = addr_type;
+ strncpy(ep->addr_info[i].string_buf, name, ACM_MAX_ADDRESS);
+ memcpy(ep->addr_info[i].addr.info.addr, tmp, ACM_MAX_ADDRESS);
}
ret = 0;
out:
{
uint8_t port_num;
struct acm_device *dev;
- struct acmp_ep *ep = (struct acmp_ep *)ctx;
+ struct acm_ep *ep = ctx;
dev = acm_get_device_from_gid(gid, &port_num);
if (dev && ep->port->dev == dev
- && ep->port->port_num == port_num && ep->pkey == pkey) {
+ && ep->port->port_num == port_num && ep->endpoint.pkey == pkey) {
if (!acm_ep_insert_addr(ep, ip_str, addr, addr_len, addr_type)) {
acm_log(0, "Added %s %s %d 0x%x from %s\n", ip_str,
dev->verbs->device->name, port_num, pkey,
}
}
-static int acm_get_system_ips(struct acmp_ep *ep)
+static int acm_get_system_ips(struct acm_ep *ep)
{
- return acm_if_iter_sys(acm_ep_ip_iter_cb, (void *)ep);
+ return acm_if_iter_sys(acm_ep_ip_iter_cb, ep);
}
-static int acm_assign_ep_names(struct acmp_ep *ep)
+static int acm_assign_ep_names(struct acm_ep *ep)
{
FILE *faddr;
char *dev_name;
dev_name = ep->port->dev->verbs->device->name;
acm_log(1, "device %s, port %d, pkey 0x%x\n",
- dev_name, ep->port->port_num, ep->pkey);
+ dev_name, ep->port->port_num, ep->endpoint.pkey);
acm_get_system_ips(ep);
}
if (!stricmp(dev_name, dev) && (ep->port->port_num == (uint8_t) port) &&
- (ep->pkey == pkey)) {
+ (ep->endpoint.pkey == pkey)) {
acm_log(1, "assigning %s\n", name);
if ((ret = acm_ep_insert_addr(ep, name, addr,
addr_len, type)) != 0) {
return 0;
}
-static struct acmp_ep *acm_find_ep(struct acmp_port *port, uint16_t pkey)
+static struct acm_ep *acm_find_ep(struct acmp_port *port, uint16_t pkey)
{
- struct acmp_ep *ep, *res = NULL;
+ struct acmp_ep *ep;
+ struct acm_ep *res = NULL;
DLIST_ENTRY *entry;
acm_log(2, "pkey 0x%x\n", pkey);
lock_acquire(&port->lock);
for (entry = port->ep_list.Next; entry != &port->ep_list; entry = entry->Next) {
ep = container_of(entry, struct acmp_ep, entry);
- if (ep->pkey == pkey) {
- res = ep;
+ if (ep->ep->endpoint.pkey == pkey) {
+ res = ep->ep;
break;
}
}
return NULL;
}
+ ep->endpoint = &ep->ep->endpoint;
ep->port = port;
ep->pkey = pkey;
ep->pkey_index = pkey_index;
ep->endpoint->dev_guid = port->dev->guid;
ep->endpoint->port_num = port->port_num;
ep->endpoint->pkey = pkey;
+ lock_init(&ep->ep->lock);
for (i = 0; i < MAX_EP_ADDR; i++) {
ep->ep->addr_info[i].addr.endpoint = ep->endpoint;
if (!ep)
return;
- ret = acm_assign_ep_names(ep);
+ ret = acm_assign_ep_names(ep->ep);
if (ret) {
acm_log(0, "ERROR - unable to assign EP name for pkey 0x%x\n", pkey);
goto err0;