Page MenuHomeFreeBSD
Authored By
bartosz.sobczak_intel.com
Apr 20 2023, 7:23 PM
Size
30 KB
Referenced Files
None
Subscribers
None

d38960_3.diff

diff --git a/sys/contrib/rdma/krping/krping.c b/sys/contrib/rdma/krping/krping.c
index fe8ff9ed924..ead1bf54dca 100644
--- a/sys/contrib/rdma/krping/krping.c
+++ b/sys/contrib/rdma/krping/krping.c
@@ -1988,7 +1988,7 @@ krping_get_ipv6_scope_id(char *name)
CURVNET_RESTORE();
if (ifp == NULL)
return (0);
- retval = ifp->if_index;
+ retval = if_getindex(ifp);
if_rele(ifp);
return (retval);
}
diff --git a/sys/dev/irdma/fbsd_kcompat.c b/sys/dev/irdma/fbsd_kcompat.c
index 7a17b7e5f0f..001b73342bc 100644
--- a/sys/dev/irdma/fbsd_kcompat.c
+++ b/sys/dev/irdma/fbsd_kcompat.c
@@ -183,6 +183,32 @@ irdma_ieq_check_mpacrc(void *desc,
return ret_code;
}
+static u_int
+irdma_add_ipv6_cb(void *arg, struct ifaddr *addr, u_int count __unused)
+{
+ struct irdma_device *iwdev = arg;
+ struct sockaddr_in6 *sin6;
+ u32 local_ipaddr6[4] = {};
+ char ip6buf[INET6_ADDRSTRLEN];
+ u8 *mac_addr;
+
+ sin6 = (struct sockaddr_in6 *)addr->ifa_addr;
+
+ irdma_copy_ip_ntohl(local_ipaddr6, (u32 *)&sin6->sin6_addr);
+
+ mac_addr = if_getlladdr(addr->ifa_ifp);
+
+ printf("%s:%d IP=%s, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
+ __func__, __LINE__,
+ ip6_sprintf(ip6buf, &sin6->sin6_addr),
+ mac_addr[0], mac_addr[1], mac_addr[2],
+ mac_addr[3], mac_addr[4], mac_addr[5]);
+
+ irdma_manage_arp_cache(iwdev->rf, mac_addr, local_ipaddr6,
+ IRDMA_ARP_ADD);
+ return (0);
+}
+
/**
* irdma_add_ipv6_addr - add ipv6 address to the hw arp table
* @iwdev: irdma device
@@ -191,32 +217,37 @@ irdma_ieq_check_mpacrc(void *desc,
static void
irdma_add_ipv6_addr(struct irdma_device *iwdev, struct ifnet *ifp)
{
- struct ifaddr *ifa, *tmp;
- struct sockaddr_in6 *sin6;
- u32 local_ipaddr6[4];
- u8 *mac_addr;
- char ip6buf[INET6_ADDRSTRLEN];
-
if_addr_rlock(ifp);
- IRDMA_TAILQ_FOREACH_SAFE(ifa, &ifp->if_addrhead, ifa_link, tmp) {
- sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
- if (sin6->sin6_family != AF_INET6)
- continue;
+ if_foreach_addr_type(ifp, AF_INET6, irdma_add_ipv6_cb, iwdev);
+ if_addr_runlock(ifp);
+}
- irdma_copy_ip_ntohl(local_ipaddr6, (u32 *)&sin6->sin6_addr);
- mac_addr = IF_LLADDR(ifp);
+static u_int
+irdma_add_ipv4_cb(void *arg, struct ifaddr *addr, u_int count __unused)
+{
+ struct irdma_device *iwdev = arg;
+ struct sockaddr_in *sin;
+ u32 ip_addr[4] = {};
+ uint8_t *mac_addr;
- printf("%s:%d IP=%s, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
- __func__, __LINE__,
- ip6_sprintf(ip6buf, &sin6->sin6_addr),
- mac_addr[0], mac_addr[1], mac_addr[2],
- mac_addr[3], mac_addr[4], mac_addr[5]);
+ sin = (struct sockaddr_in *)addr->ifa_addr;
- irdma_manage_arp_cache(iwdev->rf, mac_addr, local_ipaddr6,
- IRDMA_ARP_ADD);
+ ip_addr[0] = ntohl(sin->sin_addr.s_addr);
- }
- if_addr_runlock(ifp);
+ mac_addr = if_getlladdr(addr->ifa_ifp);
+
+ printf("%s:%d IP=%d.%d.%d.%d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
+ __func__, __LINE__,
+ ip_addr[0] >> 24,
+ (ip_addr[0] >> 16) & 0xFF,
+ (ip_addr[0] >> 8) & 0xFF,
+ ip_addr[0] & 0xFF,
+ mac_addr[0], mac_addr[1], mac_addr[2],
+ mac_addr[3], mac_addr[4], mac_addr[5]);
+
+ irdma_manage_arp_cache(iwdev->rf, mac_addr, ip_addr,
+ IRDMA_ARP_ADD);
+ return (0);
}
/**
@@ -227,32 +258,8 @@ irdma_add_ipv6_addr(struct irdma_device *iwdev, struct ifnet *ifp)
static void
irdma_add_ipv4_addr(struct irdma_device *iwdev, struct ifnet *ifp)
{
- struct ifaddr *ifa;
- struct sockaddr_in *sin;
- u32 ip_addr[4] = {};
- u8 *mac_addr;
-
if_addr_rlock(ifp);
- IRDMA_TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
- sin = (struct sockaddr_in *)ifa->ifa_addr;
- if (sin->sin_family != AF_INET)
- continue;
-
- ip_addr[0] = ntohl(sin->sin_addr.s_addr);
- mac_addr = IF_LLADDR(ifp);
-
- printf("%s:%d IP=%d.%d.%d.%d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
- __func__, __LINE__,
- ip_addr[0] >> 24,
- (ip_addr[0] >> 16) & 0xFF,
- (ip_addr[0] >> 8) & 0xFF,
- ip_addr[0] & 0xFF,
- mac_addr[0], mac_addr[1], mac_addr[2],
- mac_addr[3], mac_addr[4], mac_addr[5]);
-
- irdma_manage_arp_cache(iwdev->rf, mac_addr, ip_addr,
- IRDMA_ARP_ADD);
- }
+ if_foreach_addr_type(ifp, AF_INET, irdma_add_ipv4_cb, iwdev);
if_addr_runlock(ifp);
}
@@ -271,7 +278,7 @@ irdma_add_ip(struct irdma_device *iwdev)
irdma_add_ipv4_addr(iwdev, ifp);
irdma_add_ipv6_addr(iwdev, ifp);
- for (i = 0; ifp->if_vlantrunk != NULL && i < VLAN_N_VID; ++i) {
+ for (i = 0; if_getvlantrunk(ifp) != NULL && i < VLAN_N_VID; ++i) {
ifv = VLAN_DEVAT(ifp, i);
if (!ifv)
continue;
@@ -293,7 +300,7 @@ irdma_ifaddrevent_handler(void *arg, struct ifnet *ifp, struct ifaddr *ifa, int
if (!ifa || !ifa->ifa_addr || !ifp)
return;
if (rf->iwdev->netdev != ifp) {
- for (i = 0; rf->iwdev->netdev->if_vlantrunk != NULL && i < VLAN_N_VID; ++i) {
+ for (i = 0; if_getvlantrunk(rf->iwdev->netdev) != NULL && i < VLAN_N_VID; ++i) {
NET_EPOCH_ENTER(et);
ifv = VLAN_DEVAT(rf->iwdev->netdev, i);
NET_EPOCH_EXIT(et);
@@ -467,7 +474,7 @@ irdma_addr_resolve_neigh_ipv6(struct irdma_cm_node *cm_node,
dst_addr.sin6_family = AF_INET6;
dst_addr.sin6_len = sizeof(dst_addr);
- dst_addr.sin6_scope_id = iwdev->netdev->if_index;
+ dst_addr.sin6_scope_id = if_getindex(iwdev->netdev);
irdma_copy_ip_htonl(dst_addr.sin6_addr.__u6_addr.__u6_addr32, dest);
err = irdma_get_dst_mac(cm_node, (struct sockaddr *)&dst_addr, dst_mac);
diff --git a/sys/dev/irdma/icrdma.c b/sys/dev/irdma/icrdma.c
index a3dee284adc..fa87086e2f4 100644
--- a/sys/dev/irdma/icrdma.c
+++ b/sys/dev/irdma/icrdma.c
@@ -55,8 +55,6 @@
*/
char irdma_driver_version[] = "1.1.11-k";
-#define pf_if_d(peer) peer->ifp->if_dunit
-
/**
* irdma_init_tunable - prepare tunables
* @rf: RDMA PCI function
@@ -247,7 +245,7 @@ irdma_event_handler(struct ice_rdma_peer *peer, struct ice_rdma_event *event)
(event->type == 1) ? "LINK CHANGE" :
(event->type == 2) ? "MTU CHANGE" :
(event->type == 3) ? "TC CHANGE" : "UNKNOWN",
- event->type, peer->pf_id, pf_if_d(peer));
+ event->type, peer->pf_id, if_getdunit(peer->ifp));
iwdev = peer_to_iwdev(peer);
if (!iwdev) {
printf("%s:%d rdma device not found\n", __func__, __LINE__);
@@ -257,7 +255,8 @@ irdma_event_handler(struct ice_rdma_peer *peer, struct ice_rdma_event *event)
switch (event->type) {
case ICE_RDMA_EVENT_LINK_CHANGE:
printf("%s:%d PF: %x (%x), state: %d, speed: %lu\n", __func__, __LINE__,
- peer->pf_id, pf_if_d(peer), event->linkstate, event->baudrate);
+ peer->pf_id, if_getdunit(peer->ifp), event->linkstate,
+ event->baudrate);
break;
case ICE_RDMA_EVENT_MTU_CHANGE:
if (iwdev->vsi.mtu != event->mtu) {
@@ -317,7 +316,7 @@ static void
irdma_link_change(struct ice_rdma_peer *peer, int linkstate, uint64_t baudrate)
{
printf("%s:%d PF: %x (%x), state: %d, speed: %lu\n", __func__, __LINE__,
- peer->pf_id, pf_if_d(peer), linkstate, baudrate);
+ peer->pf_id, if_getdunit(peer->ifp), linkstate, baudrate);
}
/**
@@ -342,7 +341,7 @@ irdma_finalize_task(void *context, int pending)
if (iwdev->iw_status) {
irdma_debug(&rf->sc_dev, IRDMA_DEBUG_INIT,
"Starting deferred closing %d (%d)\n",
- rf->peer_info->pf_id, pf_if_d(peer));
+ rf->peer_info->pf_id, if_getdunit(peer->ifp));
irdma_dereg_ipaddr_event_cb(rf);
irdma_ib_unregister_device(iwdev);
req.type = ICE_RDMA_EVENT_VSI_FILTER_UPDATE;
@@ -353,7 +352,7 @@ irdma_finalize_task(void *context, int pending)
} else {
irdma_debug(&rf->sc_dev, IRDMA_DEBUG_INIT,
"Starting deferred opening %d (%d)\n",
- rf->peer_info->pf_id, pf_if_d(peer));
+ rf->peer_info->pf_id, if_getdunit(peer->ifp));
irdma_get_qos_info(&l2params, &peer->initial_qos_info);
if (iwdev->rf->protocol_used != IRDMA_IWARP_PROTOCOL_ONLY)
iwdev->dcb_vlan_mode = l2params.num_tc > 1 && !l2params.dscp_mode;
@@ -377,7 +376,7 @@ irdma_finalize_task(void *context, int pending)
irdma_reg_ipaddr_event_cb(rf);
irdma_debug(&rf->sc_dev, IRDMA_DEBUG_INIT,
"Deferred opening finished %d (%d)\n",
- rf->peer_info->pf_id, pf_if_d(peer));
+ rf->peer_info->pf_id, if_getdunit(peer->ifp));
}
}
@@ -516,7 +515,7 @@ irdma_probe(struct ice_rdma_peer *peer)
irdma_pr_info("probe: irdma-%s peer=%p, peer->pf_id=%d, peer->ifp=%p, peer->ifp->if_dunit=%d, peer->pci_mem->r_bustag=%p\n",
irdma_driver_version, peer, peer->pf_id, peer->ifp,
- pf_if_d(peer), (void *)(uintptr_t)peer->pci_mem->r_bustag);
+ if_getdunit(peer->ifp), (void *)(uintptr_t)peer->pci_mem->r_bustag);
hdl = irdma_find_handler(peer);
if (hdl)
@@ -541,7 +540,7 @@ irdma_probe(struct ice_rdma_peer *peer)
hdl->iwdev = iwdev;
iwdev->hdl = hdl;
- irdma_init_tunable(iwdev->rf, pf_if_d(peer));
+ irdma_init_tunable(iwdev->rf, if_getdunit(peer->ifp));
irdma_fill_device_info(iwdev, peer);
rf = iwdev->rf;
@@ -594,7 +593,7 @@ irdma_remove(struct ice_rdma_peer *peer)
struct irdma_device *iwdev;
irdma_debug((struct irdma_sc_dev *)NULL, IRDMA_DEBUG_INIT,
- "removing %s irdma%d\n", __func__, pf_if_d(peer));
+ "removing %s irdma%d\n", __func__, if_getdunit(peer->ifp));
hdl = irdma_find_handler(peer);
if (!hdl)
@@ -626,7 +625,7 @@ irdma_remove(struct ice_rdma_peer *peer)
kfree(iwdev->rf);
ib_dealloc_device(&iwdev->ibdev);
irdma_pr_info("IRDMA hardware deinitialization complete irdma%d\n",
- pf_if_d(peer));
+ if_getdunit(peer->ifp));
return 0;
}
diff --git a/sys/dev/irdma/irdma_cm.c b/sys/dev/irdma/irdma_cm.c
index daf11606559..206314797e3 100644
--- a/sys/dev/irdma/irdma_cm.c
+++ b/sys/dev/irdma/irdma_cm.c
@@ -1630,11 +1630,12 @@ static u8 irdma_get_egress_vlan_prio(u32 *loc_addr, u8 prio, bool ipv4){
* Returns the net_device of the IPv6 address and also sets the
* vlan id and mac for that address.
*/
-struct ifnet *
+if_t
irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac)
{
- struct ifnet *ip_dev = NULL;
+ if_t ip_dev = NULL;
struct in6_addr laddr6;
+ struct ifaddr *ifa;
u16 scope_id = 0;
irdma_copy_ip_htonl(laddr6.__u6_addr.__u6_addr32, addr);
@@ -1651,8 +1652,9 @@ irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac)
if (ip_dev) {
if (vlan_id)
*vlan_id = rdma_vlan_dev_vlan_id(ip_dev);
- if (ip_dev->if_addr && ip_dev->if_addr->ifa_addr && mac)
- ether_addr_copy(mac, IF_LLADDR(ip_dev));
+ ifa = if_getifaddr(ip_dev);
+ if (ifa && ifa->ifa_addr && mac)
+ ether_addr_copy(mac, if_getlladdr(ip_dev));
}
return ip_dev;
@@ -1665,7 +1667,7 @@ irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac)
u16
irdma_get_vlan_ipv4(u32 *addr)
{
- struct ifnet *netdev;
+ if_t netdev;
u16 vlan_id = 0xFFFF;
netdev = ip_ifp_find(&init_net, htonl(addr[0]));
@@ -1677,179 +1679,92 @@ irdma_get_vlan_ipv4(u32 *addr)
return vlan_id;
}
-/**
- * irdma_add_mqh_6 - Adds multiple qhashes for IPv6
- * @iwdev: iWarp device
- * @cm_info: CM info for parent listen node
- * @cm_parent_listen_node: The parent listen node
- *
- * Adds a qhash and a child listen node for every IPv6 address
- * on the adapter and adds the associated qhash filter
- */
-static int
-irdma_add_mqh_6(struct irdma_device *iwdev,
- struct irdma_cm_info *cm_info,
- struct irdma_cm_listener *cm_parent_listen_node)
-{
- struct ifnet *ip_dev;
- struct ifaddr *ifp;
- struct irdma_cm_listener *child_listen_node;
- unsigned long flags;
- int ret = 0;
-
- IFNET_RLOCK();
- IRDMA_TAILQ_FOREACH((ip_dev), &V_ifnet, if_link) {
- if (!(ip_dev->if_flags & IFF_UP))
- continue;
-
- if (((rdma_vlan_dev_vlan_id(ip_dev) >= VLAN_N_VID) ||
- (rdma_vlan_dev_real_dev(ip_dev) != iwdev->netdev)) &&
- ip_dev != iwdev->netdev)
- continue;
-
- if_addr_rlock(ip_dev);
- IRDMA_TAILQ_FOREACH(ifp, &ip_dev->if_addrhead, ifa_link) {
- irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_CM,
- "IP=%pI6, vlan_id=%d, MAC=%pM\n",
- &((struct sockaddr_in6 *)ifp->ifa_addr)->sin6_addr, rdma_vlan_dev_vlan_id(ip_dev),
- IF_LLADDR(ip_dev));
- if (((struct sockaddr_in6 *)ifp->ifa_addr)->sin6_family != AF_INET6)
- continue;
- child_listen_node = kzalloc(sizeof(*child_listen_node), GFP_KERNEL);
- irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_CM,
- "Allocating child listener %p\n",
- child_listen_node);
- if (!child_listen_node) {
- irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_CM, "listener memory allocation\n");
- ret = -ENOMEM;
- if_addr_runlock(ip_dev);
- goto exit;
- }
-
- memcpy(child_listen_node, cm_parent_listen_node,
- sizeof(*child_listen_node));
- cm_info->vlan_id = rdma_vlan_dev_vlan_id(ip_dev);
- child_listen_node->vlan_id = cm_info->vlan_id;
- irdma_copy_ip_ntohl(child_listen_node->loc_addr,
- ((struct sockaddr_in6 *)ifp->ifa_addr)->sin6_addr.__u6_addr.__u6_addr32);
- memcpy(cm_info->loc_addr, child_listen_node->loc_addr,
- sizeof(cm_info->loc_addr));
- if (!iwdev->vsi.dscp_mode)
- cm_info->user_pri =
- irdma_get_egress_vlan_prio(child_listen_node->loc_addr,
- cm_info->user_pri,
- false);
- ret = irdma_manage_qhash(iwdev, cm_info,
- IRDMA_QHASH_TYPE_TCP_SYN,
- IRDMA_QHASH_MANAGE_TYPE_ADD,
- NULL, true);
- if (ret) {
- kfree(child_listen_node);
- continue;
- }
-
- child_listen_node->qhash_set = true;
- spin_lock_irqsave(&iwdev->cm_core.listen_list_lock, flags);
- list_add(&child_listen_node->child_listen_list,
- &cm_parent_listen_node->child_listen_list);
- spin_unlock_irqrestore(&iwdev->cm_core.listen_list_lock, flags);
- cm_parent_listen_node->cm_core->stats_listen_nodes_created++;
- }
- if_addr_runlock(ip_dev);
- }
-exit:
- IFNET_RUNLOCK();
-
- return ret;
-}
+struct irdma_add_mqh_cbs {
+ struct irdma_device *iwdev;
+ struct irdma_cm_info *cm_info;
+ struct irdma_cm_listener *cm_listen_node;
+};
/**
- * irdma_add_mqh_4 - Adds multiple qhashes for IPv4
- * @iwdev: iWarp device
- * @cm_info: CM info for parent listen node
- * @cm_parent_listen_node: The parent listen node
+ * irdma_add_mqh_ifa_cb - Adds multiple qhashes for IPv6
+ * @arg: Calback argument structure from irdma_add_mqh
+ * @ifa: Current address to compute against
+ * @count: Current cumulative output of all callbacks in this iteration
*
- * Adds a qhash and a child listen node for every IPv4 address
+ * Adds a qhash and a child listen node for a single IPv6 address
* on the adapter and adds the associated qhash filter
*/
-static int
-irdma_add_mqh_4(struct irdma_device *iwdev,
- struct irdma_cm_info *cm_info,
- struct irdma_cm_listener *cm_parent_listen_node)
+static u_int
+irdma_add_mqh_ifa_cb(void *arg, struct ifaddr *ifa, u_int count)
{
- struct ifnet *ip_dev;
+ struct irdma_add_mqh_cbs *cbs = arg;
struct irdma_cm_listener *child_listen_node;
+ struct irdma_cm_info *cm_info = cbs->cm_info;
+ struct irdma_device *iwdev = cbs->iwdev;
+ struct irdma_cm_listener *cm_parent_listen_node = cbs->cm_listen_node;
+ if_t ip_dev = ifa->ifa_ifp;
unsigned long flags;
- struct ifaddr *ifa;
- int ret = 0;
-
- IFNET_RLOCK();
- IRDMA_TAILQ_FOREACH((ip_dev), &V_ifnet, if_link) {
- if (!(ip_dev->if_flags & IFF_UP))
- continue;
-
- if (((rdma_vlan_dev_vlan_id(ip_dev) >= VLAN_N_VID) ||
- (rdma_vlan_dev_real_dev(ip_dev) != iwdev->netdev)) &&
- ip_dev != iwdev->netdev)
- continue;
+ int ret;
- if_addr_rlock(ip_dev);
- IRDMA_TAILQ_FOREACH(ifa, &ip_dev->if_addrhead, ifa_link) {
- irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_CM,
- "Allocating child CM Listener forIP=%pI4, vlan_id=%d, MAC=%pM\n",
- &ifa->ifa_addr, rdma_vlan_dev_vlan_id(ip_dev),
- IF_LLADDR(ip_dev));
- if (((struct sockaddr_in *)ifa->ifa_addr)->sin_family != AF_INET)
- continue;
- child_listen_node = kzalloc(sizeof(*child_listen_node), GFP_KERNEL);
- cm_parent_listen_node->cm_core->stats_listen_nodes_created++;
- irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_CM,
- "Allocating child listener %p\n",
- child_listen_node);
- if (!child_listen_node) {
- irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_CM, "listener memory allocation\n");
- if_addr_runlock(ip_dev);
- ret = -ENOMEM;
- goto exit;
- }
+ if (count)
+ return 0;
- memcpy(child_listen_node, cm_parent_listen_node,
- sizeof(*child_listen_node));
- child_listen_node->vlan_id = rdma_vlan_dev_vlan_id(ip_dev);
- cm_info->vlan_id = child_listen_node->vlan_id;
- child_listen_node->loc_addr[0] =
- ntohl(((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr);
- memcpy(cm_info->loc_addr, child_listen_node->loc_addr,
- sizeof(cm_info->loc_addr));
- if (!iwdev->vsi.dscp_mode)
- cm_info->user_pri =
- irdma_get_egress_vlan_prio(child_listen_node->loc_addr,
- cm_info->user_pri,
- true);
- ret = irdma_manage_qhash(iwdev, cm_info,
- IRDMA_QHASH_TYPE_TCP_SYN,
- IRDMA_QHASH_MANAGE_TYPE_ADD,
- NULL, true);
- if (ret) {
- kfree(child_listen_node);
- cm_parent_listen_node->cm_core
- ->stats_listen_nodes_created--;
- continue;
- }
+ if (cm_info->ipv4)
+ irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_CM,
+ "Allocating child CM Listener forIP=%pI4, vlan_id=%d, MAC=%pM\n",
+ &ifa->ifa_addr,
+ rdma_vlan_dev_vlan_id(ip_dev), if_getlladdr(ip_dev));
+ else
+ irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_CM,
+ "IP=%pI6, vlan_id=%d, MAC=%pM\n",
+ &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr,
+ rdma_vlan_dev_vlan_id(ip_dev),
+ if_getlladdr(ip_dev));
+ child_listen_node = kzalloc(sizeof(*child_listen_node), GFP_KERNEL);
+ irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_CM,
+ "Allocating child listener %p\n",
+ child_listen_node);
+ if (!child_listen_node) {
+ irdma_debug(&iwdev->rf->sc_dev,
+ IRDMA_DEBUG_CM,
+ "listener memory allocation\n");
+ return -ENOMEM;
+ }
- child_listen_node->qhash_set = true;
- spin_lock_irqsave(&iwdev->cm_core.listen_list_lock,
- flags);
- list_add(&child_listen_node->child_listen_list,
- &cm_parent_listen_node->child_listen_list);
- spin_unlock_irqrestore(&iwdev->cm_core.listen_list_lock, flags);
- }
- if_addr_runlock(ip_dev);
+ memcpy(child_listen_node, cm_parent_listen_node,
+ sizeof(*child_listen_node));
+ cm_info->vlan_id = rdma_vlan_dev_vlan_id(ip_dev);
+ child_listen_node->vlan_id = cm_info->vlan_id;
+ if (cm_info->ipv4)
+ child_listen_node->loc_addr[0] =
+ ntohl(((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr);
+ else
+ irdma_copy_ip_ntohl(child_listen_node->loc_addr,
+ ((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr.__u6_addr.__u6_addr32);
+ memcpy(cm_info->loc_addr, child_listen_node->loc_addr,
+ sizeof(cm_info->loc_addr));
+ if (!iwdev->vsi.dscp_mode)
+ cm_info->user_pri =
+ irdma_get_egress_vlan_prio(child_listen_node->loc_addr,
+ cm_info->user_pri,
+ false);
+ ret = irdma_manage_qhash(iwdev, cm_info,
+ IRDMA_QHASH_TYPE_TCP_SYN,
+ IRDMA_QHASH_MANAGE_TYPE_ADD,
+ NULL, true);
+ if (ret) {
+ kfree(child_listen_node);
+ return ret;
}
-exit:
- IFNET_RUNLOCK();
- return ret;
+ child_listen_node->qhash_set = true;
+ spin_lock_irqsave(&iwdev->cm_core.listen_list_lock, flags);
+ list_add(&child_listen_node->child_listen_list,
+ &cm_parent_listen_node->child_listen_list);
+ spin_unlock_irqrestore(&iwdev->cm_core.listen_list_lock, flags);
+ cm_parent_listen_node->cm_core->stats_listen_nodes_created++;
+
+ return 0;
}
/**
@@ -1863,21 +1778,42 @@ irdma_add_mqh(struct irdma_device *iwdev,
struct irdma_cm_info *cm_info,
struct irdma_cm_listener *cm_listen_node)
{
+ struct epoch_tracker et;
+ struct irdma_add_mqh_cbs cbs;
+ struct if_iter iter;
+ if_t ifp;
int err;
+
+ cbs.iwdev = iwdev;
+ cbs.cm_info = cm_info;
+ cbs.cm_listen_node = cm_listen_node;
+
VNET_ITERATOR_DECL(vnet_iter);
VNET_LIST_RLOCK();
+ NET_EPOCH_ENTER(et);
VNET_FOREACH(vnet_iter) {
- IFNET_RLOCK();
CURVNET_SET_QUIET(vnet_iter);
+ for (ifp = if_iter_start(&iter); ifp != NULL; ifp = if_iter_next(&iter)) {
+ if (!(if_getflags(ifp) & IFF_UP))
+ continue;
- if (cm_info->ipv4)
- err = irdma_add_mqh_4(iwdev, cm_info, cm_listen_node);
- else
- err = irdma_add_mqh_6(iwdev, cm_info, cm_listen_node);
+ if (((rdma_vlan_dev_vlan_id(ifp) >= VLAN_N_VID) ||
+ (rdma_vlan_dev_real_dev(ifp) != iwdev->netdev)) &&
+ ifp != iwdev->netdev)
+ continue;
+
+ if_addr_rlock(ifp);
+ if (cm_info->ipv4)
+ err = if_foreach_addr_type(ifp, AF_INET, irdma_add_mqh_ifa_cb, &cbs);
+ else
+ err = if_foreach_addr_type(ifp, AF_INET6, irdma_add_mqh_ifa_cb, &cbs);
+ if_addr_runlock(ifp);
+ }
+ if_iter_finish(&iter);
CURVNET_RESTORE();
- IFNET_RUNLOCK();
}
+ NET_EPOCH_EXIT(et);
VNET_LIST_RUNLOCK();
return err;
@@ -2110,7 +2046,7 @@ irdma_cm_create_ah(struct irdma_cm_node *cm_node, bool wait)
struct vnet *vnet = rdma_id->route.addr.dev_addr.net;
#endif
- ether_addr_copy(ah_info.mac_addr, IF_LLADDR(iwdev->netdev));
+ ether_addr_copy(ah_info.mac_addr, if_getlladdr(iwdev->netdev));
ah_info.hop_ttl = 0x40;
ah_info.tc_tos = cm_node->tos;
@@ -2178,7 +2114,7 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev,
{
struct irdma_cm_node *cm_node;
int arpindex;
- struct ifnet *netdev = iwdev->netdev;
+ if_t netdev = iwdev->netdev;
/* create an hte and cm_node for this instance */
cm_node = kzalloc(sizeof(*cm_node), GFP_ATOMIC);
@@ -2227,7 +2163,7 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev,
cm_node->listener = listener;
cm_node->cm_id = cm_info->cm_id;
- ether_addr_copy(cm_node->loc_mac, IF_LLADDR(netdev));
+ ether_addr_copy(cm_node->loc_mac, if_getlladdr(netdev));
spin_lock_init(&cm_node->retrans_list_lock);
cm_node->ack_rcvd = false;
diff --git a/sys/dev/irdma/irdma_hw.c b/sys/dev/irdma/irdma_hw.c
index d41b3be061f..ba4b5233d9d 100644
--- a/sys/dev/irdma/irdma_hw.c
+++ b/sys/dev/irdma/irdma_hw.c
@@ -1122,7 +1122,7 @@ irdma_alloc_set_mac(struct irdma_device *iwdev)
&iwdev->mac_ip_table_idx);
if (!status) {
status = irdma_add_local_mac_entry(iwdev->rf,
- (const u8 *)IF_LLADDR(iwdev->netdev),
+ (const u8 *)if_getlladdr(iwdev->netdev),
(u8)iwdev->mac_ip_table_idx);
if (status)
irdma_del_local_mac_entry(iwdev->rf,
@@ -2605,7 +2605,7 @@ irdma_manage_qhash(struct irdma_device *iwdev, struct irdma_cm_info *cminfo,
}
info->ipv4_valid = cminfo->ipv4;
info->user_pri = cminfo->user_pri;
- ether_addr_copy(info->mac_addr, IF_LLADDR(iwdev->netdev));
+ ether_addr_copy(info->mac_addr, if_getlladdr(iwdev->netdev));
info->qp_num = cminfo->qh_qpid;
info->dest_port = cminfo->loc_port;
info->dest_ip[0] = cminfo->loc_addr[0];
diff --git a/sys/dev/irdma/irdma_kcompat.c b/sys/dev/irdma/irdma_kcompat.c
index 730c7e73bf5..d5198dde344 100644
--- a/sys/dev/irdma/irdma_kcompat.c
+++ b/sys/dev/irdma/irdma_kcompat.c
@@ -638,7 +638,8 @@ irdma_fill_ah_info(struct vnet *vnet, struct irdma_ah_info *ah_info,
}
}
-static inline u8 irdma_get_vlan_ndev_prio(struct ifnet *ndev, u8 prio){
+static inline u8 irdma_get_vlan_ndev_prio(if_t ndev, u8 prio)
+{
return prio;
}
@@ -665,7 +666,7 @@ irdma_create_ah_vlan_tag(struct irdma_device *iwdev,
ah_info->vlan_tag = 0;
if (ah_info->vlan_tag < VLAN_N_VID) {
- struct ifnet *ndev = sgid_attr->ndev;
+ if_t ndev = sgid_attr->ndev;
ah_info->insert_vlan_tag = true;
vlan_prio = (u16)irdma_get_vlan_ndev_prio(ndev, rt_tos2priority(ah_info->tc_tos));
@@ -777,7 +778,7 @@ irdma_create_ah(struct ib_ah *ib_ah,
ah_info = &sc_ah->ah_info;
ah_info->ah_idx = ah_id;
ah_info->pd_idx = pd->sc_pd.pd_id;
- ether_addr_copy(ah_info->mac_addr, IF_LLADDR(iwdev->netdev));
+ ether_addr_copy(ah_info->mac_addr, if_getlladdr(iwdev->netdev));
if (attr->ah_flags & IB_AH_GRH) {
ah_info->flow_label = attr->grh.flow_label;
@@ -787,7 +788,7 @@ irdma_create_ah(struct ib_ah *ib_ah,
ether_addr_copy(dmac, attr->dmac);
- irdma_fill_ah_info(iwdev->netdev->if_vnet, ah_info, &sgid_attr, &sgid_addr.saddr, &dgid_addr.saddr,
+ irdma_fill_ah_info(if_getvnet(iwdev->netdev), ah_info, &sgid_attr, &sgid_addr.saddr, &dgid_addr.saddr,
dmac, ah->av.net_type);
err = irdma_create_ah_vlan_tag(iwdev, pd, ah_info, &sgid_attr, dmac);
@@ -946,7 +947,7 @@ irdma_create_ah(struct ib_pd *ibpd,
ah_info->ah_idx = ah_id;
ah_info->pd_idx = pd->sc_pd.pd_id;
- ether_addr_copy(ah_info->mac_addr, IF_LLADDR(iwdev->netdev));
+ ether_addr_copy(ah_info->mac_addr, if_getlladdr(iwdev->netdev));
if (attr->ah_flags & IB_AH_GRH) {
ah_info->flow_label = attr->grh.flow_label;
ah_info->hop_ttl = attr->grh.hop_limit;
@@ -957,7 +958,7 @@ irdma_create_ah(struct ib_pd *ibpd,
ib_resolve_eth_dmac(ibpd->device, attr);
irdma_ether_copy(dmac, attr);
- irdma_fill_ah_info(iwdev->netdev->if_vnet, ah_info, &sgid_attr, &sgid_addr.saddr, &dgid_addr.saddr,
+ irdma_fill_ah_info(if_getvnet(iwdev->netdev), ah_info, &sgid_attr, &sgid_addr.saddr, &dgid_addr.saddr,
dmac, ah->av.net_type);
err = irdma_create_ah_vlan_tag(iwdev, pd, ah_info, &sgid_attr, dmac);
@@ -1733,7 +1734,7 @@ kc_irdma_set_roce_cm_info(struct irdma_qp *iwqp, struct ib_qp_attr *attr,
if (sgid_attr.ndev) {
*vlan_id = rdma_vlan_dev_vlan_id(sgid_attr.ndev);
- ether_addr_copy(iwqp->ctx_info.roce_info->mac_addr, IF_LLADDR(sgid_attr.ndev));
+ ether_addr_copy(iwqp->ctx_info.roce_info->mac_addr, if_getlladdr(sgid_attr.ndev));
}
av->net_type = kc_rdma_gid_attr_network_type(sgid_attr,
@@ -2002,7 +2003,7 @@ irdma_disassociate_ucontext(struct ib_ucontext *context)
#endif
struct ib_device *
-ib_device_get_by_netdev(struct ifnet *netdev, int driver_id)
+ib_device_get_by_netdev(if_t netdev, int driver_id)
{
struct irdma_device *iwdev;
struct irdma_handler *hdl;
@@ -2131,17 +2132,18 @@ irdma_query_port(struct ib_device *ibdev, u8 port,
struct ib_port_attr *props)
{
struct irdma_device *iwdev = to_iwdev(ibdev);
- struct ifnet *netdev = iwdev->netdev;
+ if_t netdev = iwdev->netdev;
/* no need to zero out pros here. done by caller */
props->max_mtu = IB_MTU_4096;
- props->active_mtu = ib_mtu_int_to_enum(netdev->if_mtu);
+ props->active_mtu = ib_mtu_int_to_enum(if_getmtu(netdev));
props->lid = 1;
props->lmc = 0;
props->sm_lid = 0;
props->sm_sl = 0;
- if ((netdev->if_link_state == LINK_STATE_UP) && (netdev->if_drv_flags & IFF_DRV_RUNNING)) {
+ if ((if_getlinkstate(netdev) == LINK_STATE_UP) &&
+ (if_getdrvflags(netdev) & IFF_DRV_RUNNING)) {
props->state = IB_PORT_ACTIVE;
props->phys_state = IB_PORT_PHYS_STATE_LINK_UP;
} else {
@@ -2274,7 +2276,7 @@ irdma_query_gid(struct ib_device *ibdev, u8 port, int index,
struct irdma_device *iwdev = to_iwdev(ibdev);
memset(gid->raw, 0, sizeof(gid->raw));
- ether_addr_copy(gid->raw, IF_LLADDR(iwdev->netdev));
+ ether_addr_copy(gid->raw, if_getlladdr(iwdev->netdev));
return 0;
}
@@ -2349,7 +2351,7 @@ kc_set_rdma_uverbs_cmd_mask(struct irdma_device *iwdev)
int
ib_get_eth_speed(struct ib_device *ibdev, u32 port_num, u8 *speed, u8 *width)
{
- struct ifnet *netdev = ibdev->get_netdev(ibdev, port_num);
+ if_t netdev = ibdev->get_netdev(ibdev, port_num);
u32 netdev_speed;
if (!netdev)
diff --git a/sys/dev/irdma/irdma_main.h b/sys/dev/irdma/irdma_main.h
index 27b0f2c1264..91265f2445b 100644
--- a/sys/dev/irdma/irdma_main.h
+++ b/sys/dev/irdma/irdma_main.h
@@ -363,7 +363,7 @@ struct irdma_pci_f {
struct irdma_device {
struct ib_device ibdev;
struct irdma_pci_f *rf;
- struct ifnet *netdev;
+ if_t netdev;
struct notifier_block nb_netdevice_event;
struct irdma_handler *hdl;
struct workqueue_struct *cleanup_wq;
@@ -580,7 +580,7 @@ void irdma_gen_ae(struct irdma_pci_f *rf, struct irdma_sc_qp *qp,
void irdma_copy_ip_ntohl(u32 *dst, __be32 *src);
void irdma_copy_ip_htonl(__be32 *dst, u32 *src);
u16 irdma_get_vlan_ipv4(u32 *addr);
-struct ifnet *irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac);
+if_t irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac);
struct ib_mr *irdma_reg_phys_mr(struct ib_pd *ib_pd, u64 addr, u64 size,
int acc, u64 *iova_start);
int irdma_upload_qp_context(struct irdma_qp *iwqp, bool freeze, bool raw);
diff --git a/sys/dev/irdma/irdma_verbs.c b/sys/dev/irdma/irdma_verbs.c
index c9aed90b2cb..8aac819cf89 100644
--- a/sys/dev/irdma/irdma_verbs.c
+++ b/sys/dev/irdma/irdma_verbs.c
@@ -56,7 +56,7 @@ irdma_query_device(struct ib_device *ibdev,
memset(props, 0, sizeof(*props));
addrconf_addr_eui48((u8 *)&props->sys_image_guid,
- IF_LLADDR(iwdev->netdev));
+ if_getlladdr(iwdev->netdev));
props->fw_ver = (u64)irdma_fw_major_ver(&rf->sc_dev) << 32 |
irdma_fw_minor_ver(&rf->sc_dev);
props->device_cap_flags = IB_DEVICE_MEM_WINDOW |
@@ -737,7 +737,7 @@ irdma_roce_fill_and_set_qpctx_info(struct irdma_qp *iwqp,
udp_info->src_port = 0xc000;
udp_info->dst_port = ROCE_V2_UDP_DPORT;
roce_info = &iwqp->roce_info;
- ether_addr_copy(roce_info->mac_addr, IF_LLADDR(iwdev->netdev));
+ ether_addr_copy(roce_info->mac_addr, if_getlladdr(iwdev->netdev));
roce_info->rd_en = true;
roce_info->wr_rdresp_en = true;
@@ -770,7 +770,7 @@ irdma_iw_fill_and_set_qpctx_info(struct irdma_qp *iwqp,
struct irdma_iwarp_offload_info *iwarp_info;
iwarp_info = &iwqp->iwarp_info;
- ether_addr_copy(iwarp_info->mac_addr, IF_LLADDR(iwdev->netdev));
+ ether_addr_copy(iwarp_info->mac_addr, if_getlladdr(iwdev->netdev));
iwarp_info->rd_en = true;
iwarp_info->wr_rdresp_en = true;
iwarp_info->bind_en = true;
@@ -3507,7 +3507,7 @@ irdma_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr)
return 0;
}
-static struct ifnet *
+static if_t
irdma_get_netdev(struct ib_device *ibdev, u8 port_num)
{
struct irdma_device *iwdev = to_iwdev(ibdev);
@@ -3627,7 +3627,7 @@ irdma_init_roce_device(struct irdma_device *iwdev)
kc_set_roce_uverbs_cmd_mask(iwdev);
iwdev->ibdev.node_type = RDMA_NODE_IB_CA;
addrconf_addr_eui48((u8 *)&iwdev->ibdev.node_guid,
- IF_LLADDR(iwdev->netdev));
+ if_getlladdr(iwdev->netdev));
irdma_set_device_roce_ops(&iwdev->ibdev);
if (iwdev->rf->rdma_ver == IRDMA_GEN_2)
irdma_set_device_mcast_ops(&iwdev->ibdev);
@@ -3640,11 +3640,11 @@ irdma_init_roce_device(struct irdma_device *iwdev)
static int
irdma_init_iw_device(struct irdma_device *iwdev)
{
- struct ifnet *netdev = iwdev->netdev;
+ if_t netdev = iwdev->netdev;
iwdev->ibdev.node_type = RDMA_NODE_RNIC;
addrconf_addr_eui48((u8 *)&iwdev->ibdev.node_guid,
- IF_LLADDR(netdev));
+ if_getlladdr(netdev));
iwdev->ibdev.iwcm = kzalloc(sizeof(*iwdev->ibdev.iwcm), GFP_KERNEL);
if (!iwdev->ibdev.iwcm)
return -ENOMEM;

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5820393
Default Alt Text
d38960_3.diff (30 KB)

Event Timeline