[ofa-general] RE: [PATCH RFC] rds: add iwarp support
Sean Hefty
sean.hefty at intel.com
Thu Jul 3 17:15:05 PDT 2008
>+struct ib_device *ipaddr_to_ibdev(u32 addr)
>+{
>+ struct rdma_dev_addr dev_addr;
>+ struct cma_device *cma_dev;
>+ struct net_device *dev;
>+ union ib_gid gid;
>+
>+ dev = ip_dev_find(addr);
>+ if (!dev)
>+ goto out;
>+
>+ rdma_copy_addr(&dev_addr, dev, NULL);
>+
>+ switch (dev->type) {
>+ case ARPHRD_INFINIBAND:
>+ ib_addr_get_sgid(&dev_addr, &gid);
>+ break;
>+ case ARPHRD_ETHER:
>+ iw_addr_get_sgid(&dev_addr, &gid);
>+ break;
>+ default:
>+ goto out;
>+ }
>+
>+ list_for_each_entry(cma_dev, &dev_list, list) {
>+ int ret;
>+ u8 port;
>+
>+ ret = ib_find_cached_gid(cma_dev->device, &gid, &port, NULL);
>+ if (!ret)
>+ return cma_dev->device;
>+ }
>+out:
>+ return NULL;
>+}
>+EXPORT_SYMBOL(ipaddr_to_ibdev);
You should be able to use either rdma_resolve_addr or rdma_bind_addr (if this is
a local address) to get what you need. Alternately, look at the ib_addr module
for lower-level calls.
- Sean
More information about the general
mailing list