ibcm_arp.c revision bbd6719318c24a8a2364080d8a139444e9944311
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * CDDL HEADER START
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * The contents of this file are subject to the terms of the
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Common Development and Distribution License (the "License").
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * You may not use this file except in compliance with the License.
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * See the License for the specific language governing permissions
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * and limitations under the License.
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * When distributing Covered Code, include this CDDL HEADER in each
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * If applicable, add the following below this CDDL HEADER, with the
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * fields enclosed by brackets "[]" replaced with your own identifying
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * information: Portions Copyright [yyyy] [name of copyright owner]
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * CDDL HEADER END
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Use is subject to license terms.
015f8fff605f2fbd5fd0072e555576297804d57bhiremath#pragma ident "%Z%%M% %I% %E% SMI"
015f8fff605f2fbd5fd0072e555576297804d57bhiremathextern char cmlog[];
015f8fff605f2fbd5fd0072e555576297804d57bhiremathextern int ibcm_arp_pr_lookup(ibcm_arp_streams_t *ib_s, ibt_ip_addr_t *dst_addr,
015f8fff605f2fbd5fd0072e555576297804d57bhiremath ibt_ip_addr_t *src_addr, uint8_t localroute, uint32_t bound_dev_if,
015f8fff605f2fbd5fd0072e555576297804d57bhiremathextern void ibcm_arp_prwqn_delete(ibcm_arp_prwqn_t *wqnp);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath_NOTE(SCHEME_PROTECTS_DATA("Unshared data", ibt_ip_addr_s))
015f8fff605f2fbd5fd0072e555576297804d57bhiremath_NOTE(SCHEME_PROTECTS_DATA("Unshared data", ibcm_arp_ip_t))
015f8fff605f2fbd5fd0072e555576297804d57bhiremath_NOTE(SCHEME_PROTECTS_DATA("Unshared data", ibcm_arp_ibd_insts_t))
015f8fff605f2fbd5fd0072e555576297804d57bhiremath_NOTE(SCHEME_PROTECTS_DATA("Unshared data", ibcm_arp_prwqn_t))
015f8fff605f2fbd5fd0072e555576297804d57bhiremath_NOTE(SCHEME_PROTECTS_DATA("Unshared data", iocblk))
015f8fff605f2fbd5fd0072e555576297804d57bhiremath_NOTE(SCHEME_PROTECTS_DATA("Unshared data", sockaddr_in))
015f8fff605f2fbd5fd0072e555576297804d57bhiremath_NOTE(SCHEME_PROTECTS_DATA("Unshared data", sockaddr_in6))
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * ibcm_arp_get_ibaddr_cb
015f8fff605f2fbd5fd0072e555576297804d57bhiremath ibcm_arp_streams_t *ib_s = (ibcm_arp_streams_t *)wqnp->arg;
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L4(cmlog, "ibcm_arp_get_ibaddr_cb(ib_s: %p wqnp: %p)",
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L3(cmlog, "ibcm_arp_get_ibaddr_cb: SGID %llX:%llX "
015f8fff605f2fbd5fd0072e555576297804d57bhiremath "DGID: %llX:%llX", wqnp->sgid.gid_prefix, wqnp->sgid.gid_guid,
015f8fff605f2fbd5fd0072e555576297804d57bhiremath /* lock is held by the caller. */
015f8fff605f2fbd5fd0072e555576297804d57bhiremath return (0);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Lower read service procedure (messages coming back from arp/ip).
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Process messages based on queue type.
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L4(cmlog, "ibcm_arp_lrsrv(%p, ibd_s: 0x%p)", q, ib_s);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath return (0);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Lower write service procedure.
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Used when lower streams are flow controlled.
015f8fff605f2fbd5fd0072e555576297804d57bhiremath return (0);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Lower read put procedure. Arp/ip messages come here.
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L4(cmlog, "ibcm_arp_lrput(0x%p, db_type: %d)",
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Turn around
015f8fff605f2fbd5fd0072e555576297804d57bhiremath return (0);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * This could be in interrupt context.
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Some of the ibt calls cannot be called in
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * interrupt context, so
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * put it in the queue and the message will be
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * processed by service proccedure
015f8fff605f2fbd5fd0072e555576297804d57bhiremath return (0);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Streams write queue module info
015f8fff605f2fbd5fd0072e555576297804d57bhiremath 0, /* module ID number */
015f8fff605f2fbd5fd0072e555576297804d57bhiremath 0, /* min packet size */
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Streams lower write queue, for ibcm/ip requests.
015f8fff605f2fbd5fd0072e555576297804d57bhiremath STRUIOT_NONE /* stream uio type is standard uiomove() */
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Streams lower read queue: read reply messages from ibcm/ip.
015f8fff605f2fbd5fd0072e555576297804d57bhiremath STRUIOT_NONE /* stream uio type is standard uiomove() */
015f8fff605f2fbd5fd0072e555576297804d57bhiremathibcm_arp_link_driver(ibcm_arp_streams_t *ib_s, char *path, queue_t **q,
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L4(cmlog, "ibcm_arp_link_driver: Enter: %s", path);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath /* open the driver from inside the kernel */
015f8fff605f2fbd5fd0072e555576297804d57bhiremath error = vn_open(path, UIO_SYSSPACE, FREAD|FWRITE, 0, &vp,
015f8fff605f2fbd5fd0072e555576297804d57bhiremath setq(rq, &ibcm_arp_lrinit, &ibcm_arp_lwinit, NULL, QMTSAFE,
015f8fff605f2fbd5fd0072e555576297804d57bhiremath return (0);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Unlink ip, ibcm, icmp6 drivers
015f8fff605f2fbd5fd0072e555576297804d57bhiremath/* ARGSUSED */
015f8fff605f2fbd5fd0072e555576297804d57bhiremathibcm_arp_unlink_driver(queue_t **q, vnode_t **dev_vp)
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L4(cmlog, "ibcm_arp_unlink_driver: Enter: 0x%p", q);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath setq(rq, &strdata, &stwdata, NULL, QMTSAFE, SQ_CI|SQ_CO, B_TRUE);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if ((rc = VOP_CLOSE(vp, FREAD, 1, (offset_t)0, CRED(), NULL)) != 0) {
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L2(cmlog, "ibcm_arp_unlink_driver: VOP_CLOSE "
015f8fff605f2fbd5fd0072e555576297804d57bhiremath return (0);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L4(cmlog, "ibcm_arp_unlink_drivers(%p)", ib_s);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath (void) ibcm_arp_unlink_driver(&ib_s->arpqueue, &ib_s->arp_vp);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath return (0);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Link ip, ibtl drivers below ibtl
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L4(cmlog, "ibcm_arp_link_drivers(%p)", ib_s);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath if ((rc = ibcm_arp_link_driver(ib_s, "/dev/arp", &ib_s->arpqueue,
015f8fff605f2fbd5fd0072e555576297804d57bhiremath return (0);
015f8fff605f2fbd5fd0072e555576297804d57bhiremathibcm_arp_get_ibaddr(ipaddr_t srcip, ipaddr_t destip, ib_gid_t *sgid,
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L4(cmlog, "ibcm_arp_get_ibaddr(%lX, %lX, %p, %p)",
015f8fff605f2fbd5fd0072e555576297804d57bhiremath ib_s = (ibcm_arp_streams_t *)kmem_zalloc(sizeof (ibcm_arp_streams_t),
015f8fff605f2fbd5fd0072e555576297804d57bhiremath mutex_init(&ib_s->lock, NULL, MUTEX_DEFAULT, NULL);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath if (ret != 0) {
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L3(cmlog, "ibcm_arp_get_ibaddr: SrcIP %lX, DstIP %lX",
015f8fff605f2fbd5fd0072e555576297804d57bhiremath ret = ibcm_arp_pr_lookup(ib_s, &destaddr, &srcaddr, 0, NULL,
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L3(cmlog, "ibcm_arp_get_ibaddr: ibcm_arp_pr_lookup "
015f8fff605f2fbd5fd0072e555576297804d57bhiremath if (ret == 0) {
015f8fff605f2fbd5fd0072e555576297804d57bhiremath if (ret == 0) {
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L4(cmlog, "ibcm_arp_get_ibaddr: SGID: %llX:%llX"
015f8fff605f2fbd5fd0072e555576297804d57bhiremath " DGID: %llX:%llX",
015f8fff605f2fbd5fd0072e555576297804d57bhiremath ib_s->wqnp->sgid.gid_prefix, ib_s->wqnp->sgid.gid_guid,
015f8fff605f2fbd5fd0072e555576297804d57bhiremath ib_s->wqnp->dgid.gid_prefix, ib_s->wqnp->dgid.gid_guid);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Routine to get list of "local" IP-ADDR to GID/P_KEY mapping information.
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Optionally, if "gid" and/or "p_key" info are specified, then retrieve the
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * IP-ADDR info for that attribute only.
015f8fff605f2fbd5fd0072e555576297804d57bhiremathibcm_arp_ibd_gid2mac(ib_gid_t *gid, ib_pkey_t pkey, ibcm_arp_ibd_insts_t *ibdp)
015f8fff605f2fbd5fd0072e555576297804d57bhiremath for (i = 0, ipp = ibdp->ibcm_arp_ip; i < ibdp->ibcm_arp_ibd_cnt;
015f8fff605f2fbd5fd0072e555576297804d57bhiremath if ((ipp->ip_port_gid.gid_prefix == gid->gid_prefix) &&
015f8fff605f2fbd5fd0072e555576297804d57bhiremathibcm_arp_ibd_mac2gid(ibcm_arp_ibd_insts_t *ibdp, ipaddr_t srcip,
015f8fff605f2fbd5fd0072e555576297804d57bhiremath for (i = 0, ipp = ibdp->ibcm_arp_ip; i < ibdp->ibcm_arp_ibd_cnt;
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L4(cmlog, "ibcm_arp_ibd_mac2gid: Is %lX == %lX "
015f8fff605f2fbd5fd0072e555576297804d57bhiremath ipp->ip_port_gid.gid_prefix, ipp->ip_port_gid.gid_guid);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath if (bcmp(&srcip, &ipp->ip_cm_sin.sin_addr, sizeof (in_addr_t))
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L4(cmlog, "ibcm_arp_ibd_mac2gid: Found "
015f8fff605f2fbd5fd0072e555576297804d57bhiremath "GID %llX:%llX", sgid->gid_prefix, sgid->gid_guid);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L3(cmlog, "ibcm_arp_ibd_mac2gid: Matching SRC info "
015f8fff605f2fbd5fd0072e555576297804d57bhiremath "NOT Found");
015f8fff605f2fbd5fd0072e555576297804d57bhiremathibcm_arp_get_ibd_insts_cb(dev_info_t *dip, void *arg)
015f8fff605f2fbd5fd0072e555576297804d57bhiremath ibcm_arp_ibd_insts_t *ibds = (ibcm_arp_ibd_insts_t *)arg;
015f8fff605f2fbd5fd0072e555576297804d57bhiremath (strstr(ddi_get_name_addr(dip), "ipib") != NULL)) {
015f8fff605f2fbd5fd0072e555576297804d57bhiremath if (ibds->ibcm_arp_ibd_cnt >= ibds->ibcm_arp_ibd_alloc) {
015f8fff605f2fbd5fd0072e555576297804d57bhiremath ibds->ibcm_arp_ibd_alloc * sizeof (ibcm_arp_ip_t));
015f8fff605f2fbd5fd0072e555576297804d57bhiremath ibds->ibcm_arp_ibd_alloc * sizeof (ibcm_arp_ip_t));
015f8fff605f2fbd5fd0072e555576297804d57bhiremath if (((hca_guid = ddi_prop_get_int64(DDI_DEV_T_ANY, dip, 0,
015f8fff605f2fbd5fd0072e555576297804d57bhiremath "hca-guid", 0)) == 0) ||
015f8fff605f2fbd5fd0072e555576297804d57bhiremath "port-number", 0)) == 0) ||
015f8fff605f2fbd5fd0072e555576297804d57bhiremath (ibt_get_port_state_byguid(hca_guid, port, &port_gid,
015f8fff605f2fbd5fd0072e555576297804d57bhiremath ddi_walk_devs(ddi_root_node(), ibcm_arp_get_ibd_insts_cb, ibds);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath * Return ibd interfaces and ibd instances.
015f8fff605f2fbd5fd0072e555576297804d57bhiremath if (lookupname("/dev/udp", UIO_SYSSPACE, FOLLOW, NULLVPP, &kvp) == 0) {
015f8fff605f2fbd5fd0072e555576297804d57bhiremath if (t_kopen((file_t *)NULL, kvp->v_rdev, FREAD|FWRITE,
015f8fff605f2fbd5fd0072e555576297804d57bhiremath return (-1);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath /* Get ibd ip's */
015f8fff605f2fbd5fd0072e555576297804d57bhiremath for (k = 0, ipp = ibds->ibcm_arp_ip; k < ibds->ibcm_arp_ibd_cnt;
015f8fff605f2fbd5fd0072e555576297804d57bhiremath (void) bzero((void *)&lif_req, sizeof (struct lifreq));
015f8fff605f2fbd5fd0072e555576297804d57bhiremath (void) snprintf(lif_req.lifr_name, sizeof (lif_req.lifr_name),
015f8fff605f2fbd5fd0072e555576297804d57bhiremath (void) bzero((void *)&iocb, sizeof (struct strioctl));
015f8fff605f2fbd5fd0072e555576297804d57bhiremath sizeof (struct sockaddr_in));
015f8fff605f2fbd5fd0072e555576297804d57bhiremath return (-1);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath return (0);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L4(cmlog, "ibcm_arp_get_ibds(%p)", ibdp);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L3(cmlog, "ibcm_arp_get_ibds: Found %d ibd instances",
015f8fff605f2fbd5fd0072e555576297804d57bhiremath /* Get the IP addresses of active ports. */
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L2(cmlog, "ibcm_arp_get_ibds: failed to get "
015f8fff605f2fbd5fd0072e555576297804d57bhiremath "ibd instance: IBT_SRC_IP_NOT_FOUND");
015f8fff605f2fbd5fd0072e555576297804d57bhiremath_NOTE(SCHEME_PROTECTS_DATA("Unshared data", ibtl_cm_port_list_t))
015f8fff605f2fbd5fd0072e555576297804d57bhiremathibcm_arp_get_srcip_plist(ibt_ip_path_attr_t *ipattr, ibt_path_flags_t flags,
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L4(cmlog, "ibcm_arp_get_srcip_plist(%p, %llX)",
015f8fff605f2fbd5fd0072e555576297804d57bhiremath ibds.ibcm_arp_ibd_alloc * sizeof (ibcm_arp_ip_t), KM_SLEEP);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L2(cmlog, "ibcm_arp_get_srcip_plist: "
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L2(cmlog, "ibcm_arp_get_srcip_plist: "
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L4(cmlog, "ibcm_arp_get_srcip_plist: SGID "
015f8fff605f2fbd5fd0072e555576297804d57bhiremath bcopy(&ipattr->ipa_mtu, &attr.pa_mtu, sizeof (ibt_mtu_req_t));
015f8fff605f2fbd5fd0072e555576297804d57bhiremath bcopy(&ipattr->ipa_srate, &attr.pa_srate, sizeof (ibt_srate_req_t));
015f8fff605f2fbd5fd0072e555576297804d57bhiremath bcopy(&ipattr->ipa_pkt_lt, &attr.pa_pkt_lt, sizeof (ibt_pkt_lt_req_t));
015f8fff605f2fbd5fd0072e555576297804d57bhiremath ret = ibtl_cm_get_active_plist(&attr, flags, port_list_p);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath ipp = ibcm_arp_ibd_gid2mac(&plistp->p_sgid, 0, &ibds);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath "ibcm_arp_get_srcip_plist: GID %llX:%llX",
015f8fff605f2fbd5fd0072e555576297804d57bhiremath "ibcm_arp_get_srcip_plist: SrcIP: "
015f8fff605f2fbd5fd0072e555576297804d57bhiremath kmem_free(ibds.ibcm_arp_ip, ibds.ibcm_arp_ibd_alloc *
015f8fff605f2fbd5fd0072e555576297804d57bhiremath/* Routines for warlock */
015f8fff605f2fbd5fd0072e555576297804d57bhiremath/* ARGSUSED */
015f8fff605f2fbd5fd0072e555576297804d57bhiremath IBTF_DPRINTF_L5(cmlog, "ibcm_arp_dummy_ibaddr_hdl: "
015f8fff605f2fbd5fd0072e555576297804d57bhiremath "dummy_wqn1.func %p %p", dummy_wqn1.func, dummy_wqn2.func);
015f8fff605f2fbd5fd0072e555576297804d57bhiremath return (0);