get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/1182427/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1182427,
    "url": "http://patchwork.ozlabs.org/api/patches/1182427/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20191023182253.1115-8-shiraz.saleem@intel.com/",
    "project": {
        "id": 46,
        "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api",
        "name": "Intel Wired Ethernet development",
        "link_name": "intel-wired-lan",
        "list_id": "intel-wired-lan.osuosl.org",
        "list_email": "intel-wired-lan@osuosl.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20191023182253.1115-8-shiraz.saleem@intel.com>",
    "list_archive_url": null,
    "date": "2019-10-23T18:22:43",
    "name": "[rdma-nxt,07/16] RDMA/irdma: Add connection manager",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "ad96b478f31f6fd679cf7d7954b3a08c6d9000bb",
    "submitter": {
        "id": 69500,
        "url": "http://patchwork.ozlabs.org/api/people/69500/?format=api",
        "name": "Saleem, Shiraz",
        "email": "shiraz.saleem@intel.com"
    },
    "delegate": {
        "id": 68,
        "url": "http://patchwork.ozlabs.org/api/users/68/?format=api",
        "username": "jtkirshe",
        "first_name": "Jeff",
        "last_name": "Kirsher",
        "email": "jeffrey.t.kirsher@intel.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20191023182253.1115-8-shiraz.saleem@intel.com/mbox/",
    "series": [
        {
            "id": 138160,
            "url": "http://patchwork.ozlabs.org/api/series/138160/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=138160",
            "date": "2019-10-23T18:22:36",
            "name": "Add unified Intel Ethernet RDMA driver (irdma)",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/138160/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1182427/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1182427/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@osuosl.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Authentication-Results": [
            "ozlabs.org; spf=pass (sender SPF authorized)\n\tsmtp.mailfrom=osuosl.org (client-ip=140.211.166.138;\n\thelo=whitealder.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=intel.com"
        ],
        "Received": [
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 46z03G1Yqvz9sPL\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 24 Oct 2019 05:56:42 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 8BEA587691;\n\tWed, 23 Oct 2019 18:56:40 +0000 (UTC)",
            "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id ajXUQOGfp2w2; Wed, 23 Oct 2019 18:56:21 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 3BC9C85C45;\n\tWed, 23 Oct 2019 18:56:21 +0000 (UTC)",
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id 2977C1BF48D\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 23 Oct 2019 18:38:34 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 0A37621135\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 23 Oct 2019 18:38:34 +0000 (UTC)",
            "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id EQfaRUdEJvfr for <intel-wired-lan@lists.osuosl.org>;\n\tWed, 23 Oct 2019 18:37:55 +0000 (UTC)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby silver.osuosl.org (Postfix) with ESMTPS id 0D52322926\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 23 Oct 2019 18:37:55 +0000 (UTC)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t23 Oct 2019 11:37:54 -0700",
            "from ssaleem-mobl.amr.corp.intel.com ([10.122.128.45])\n\tby fmsmga002.fm.intel.com with ESMTP; 23 Oct 2019 11:37:53 -0700"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.68,221,1569308400\"; d=\"scan'208\";a=\"228225065\"",
        "From": "Shiraz Saleem <shiraz.saleem@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Wed, 23 Oct 2019 13:22:43 -0500",
        "Message-Id": "<20191023182253.1115-8-shiraz.saleem@intel.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20191023182253.1115-1-shiraz.saleem@intel.com>",
        "References": "<20191023182253.1115-1-shiraz.saleem@intel.com>",
        "MIME-Version": "1.0",
        "X-Mailman-Approved-At": "Wed, 23 Oct 2019 18:56:19 +0000",
        "Subject": "[Intel-wired-lan] [PATCH rdma-nxt 07/16] RDMA/irdma: Add connection\n\tmanager",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>",
        "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>",
        "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>",
        "Cc": "Mustafa Ismail <mustafa.ismail@intel.com>,\n\tShiraz Saleem <shiraz.saleem@intel.com>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"
    },
    "content": "From: Mustafa Ismail <mustafa.ismail@intel.com>\n\nAdd connection management (CM) implementation for\niWARP including accept, reject, connect, create_listen,\ndestroy_listen and CM utility functions\n\nSigned-off-by: Mustafa Ismail <mustafa.ismail@intel.com>\nSigned-off-by: Shiraz Saleem <shiraz.saleem@intel.com>\n---\n drivers/infiniband/hw/irdma/cm.c | 4511 ++++++++++++++++++++++++++++++++++++++\n drivers/infiniband/hw/irdma/cm.h |  415 ++++\n 2 files changed, 4926 insertions(+)\n create mode 100644 drivers/infiniband/hw/irdma/cm.c\n create mode 100644 drivers/infiniband/hw/irdma/cm.h",
    "diff": "diff --git a/drivers/infiniband/hw/irdma/cm.c b/drivers/infiniband/hw/irdma/cm.c\nnew file mode 100644\nindex 0000000..72cfc98\n--- /dev/null\n+++ b/drivers/infiniband/hw/irdma/cm.c\n@@ -0,0 +1,4511 @@\n+// SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB\n+/* Copyright (c) 2019, Intel Corporation. */\n+\n+#include <linux/highmem.h>\n+#include <net/addrconf.h>\n+#include <net/ip6_route.h>\n+#include <net/flow.h>\n+#include <net/secure_seq.h>\n+\n+#include \"main.h\"\n+#include \"trace.h\"\n+\n+static void irdma_rem_ref_cm_node(struct irdma_cm_node *);\n+static void irdma_cm_post_event(struct irdma_cm_event *event);\n+static void irdma_disconnect_worker(struct work_struct *work);\n+\n+/**\n+ * irdma_free_sqbuf - put back puda buffer if refcount is 0\n+ * @vsi: The VSI structure of the device\n+ * @bufp: puda buffer to free\n+ */\n+void irdma_free_sqbuf(struct irdma_sc_vsi *vsi, void *bufp)\n+{\n+\tstruct irdma_puda_buf *buf = bufp;\n+\tstruct irdma_puda_rsrc *ilq = vsi->ilq;\n+\n+\tif (!atomic_dec_return(&buf->refcount))\n+\t\tirdma_puda_ret_bufpool(ilq, buf);\n+}\n+\n+/**\n+ * irdma_derive_hw_ird_setting - Calculate IRD\n+ * @cm_ird: IRD of connection's node\n+ *\n+ * The ird from the connection is rounded to a supported HW\n+ * setting (2,8,32,64,128) and then encoded for ird_size field\n+ * of qp_ctx\n+ */\n+u8 irdma_derive_hw_ird_setting(u16 cm_ird)\n+{\n+\t/* ird_size field is encoded in qp_ctx */\n+\tswitch (cm_ird ? roundup_pow_of_two(cm_ird) : 0) {\n+\tcase IRDMA_HW_IRD_SETTING_128:\n+\t\treturn 4;\n+\tcase IRDMA_HW_IRD_SETTING_64:\n+\t\treturn 3;\n+\tcase IRDMA_HW_IRD_SETTING_32:\n+\tcase IRDMA_HW_IRD_SETTING_16:\n+\t\treturn 2;\n+\tcase IRDMA_HW_IRD_SETTING_8:\n+\tcase IRDMA_HW_IRD_SETTING_4:\n+\t\treturn 1;\n+\tcase IRDMA_HW_IRD_SETTING_2:\n+\tdefault:\n+\t\tbreak;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * irdma_record_ird_ord - Record IRD/ORD passed in\n+ * @cm_node: connection's node\n+ * @conn_ird: connection IRD\n+ * @conn_ord: connection ORD\n+ */\n+static void irdma_record_ird_ord(struct irdma_cm_node *cm_node, u32 conn_ird,\n+\t\t\t\t u32 conn_ord)\n+{\n+\tif (conn_ird > cm_node->dev->hw_attrs.max_hw_ird)\n+\t\tconn_ird = cm_node->dev->hw_attrs.max_hw_ird;\n+\n+\tif (conn_ord > cm_node->dev->hw_attrs.max_hw_ord)\n+\t\tconn_ord = cm_node->dev->hw_attrs.max_hw_ord;\n+\telse if (!conn_ord && cm_node->send_rdma0_op == SEND_RDMA_READ_ZERO)\n+\t\tconn_ord = 1;\n+\tcm_node->ird_size = conn_ird;\n+\tcm_node->ord_size = conn_ord;\n+}\n+\n+/**\n+ * irdma_copy_ip_ntohl - copy IP address from  network to host\n+ * @dst: IP address in host order\n+ * @src: IP address in network order (big endian)\n+ */\n+void irdma_copy_ip_ntohl(u32 *dst, __be32 *src)\n+{\n+\t*dst++ = ntohl(*src++);\n+\t*dst++ = ntohl(*src++);\n+\t*dst++ = ntohl(*src++);\n+\t*dst = ntohl(*src);\n+}\n+\n+/**\n+ * irdma_copy_ip_htonl - copy IP address from host to network order\n+ * @dst: IP address in network order (big endian)\n+ * @src: IP address in host order\n+ */\n+void irdma_copy_ip_htonl(__be32 *dst, u32 *src)\n+{\n+\t*dst++ = htonl(*src++);\n+\t*dst++ = htonl(*src++);\n+\t*dst++ = htonl(*src++);\n+\t*dst = htonl(*src);\n+}\n+\n+/**\n+ * irdma_get_addr_info\n+ * @cm_node: contains ip/tcp info\n+ * @cm_info: to get a copy of the cm_node ip/tcp info\n+ */\n+static void irdma_get_addr_info(struct irdma_cm_node *cm_node,\n+\t\t\t\tstruct irdma_cm_info *cm_info)\n+{\n+\tmemset(cm_info, 0, sizeof(*cm_info));\n+\tcm_info->ipv4 = cm_node->ipv4;\n+\tcm_info->vlan_id = cm_node->vlan_id;\n+\tmemcpy(cm_info->loc_addr, cm_node->loc_addr, sizeof(cm_info->loc_addr));\n+\tmemcpy(cm_info->rem_addr, cm_node->rem_addr, sizeof(cm_info->rem_addr));\n+\tcm_info->loc_port = cm_node->loc_port;\n+\tcm_info->rem_port = cm_node->rem_port;\n+}\n+\n+/**\n+ * irdma_fill_sockaddr4 - fill in addr info for IPv4 connection\n+ * @cm_node: connection's node\n+ * @event: upper layer's cm event\n+ */\n+static inline void irdma_fill_sockaddr4(struct irdma_cm_node *cm_node,\n+\t\t\t\t\tstruct iw_cm_event *event)\n+{\n+\tstruct sockaddr_in *laddr = (struct sockaddr_in *)&event->local_addr;\n+\tstruct sockaddr_in *raddr = (struct sockaddr_in *)&event->remote_addr;\n+\n+\tladdr->sin_family = AF_INET;\n+\traddr->sin_family = AF_INET;\n+\n+\tladdr->sin_port = htons(cm_node->loc_port);\n+\traddr->sin_port = htons(cm_node->rem_port);\n+\n+\tladdr->sin_addr.s_addr = htonl(cm_node->loc_addr[0]);\n+\traddr->sin_addr.s_addr = htonl(cm_node->rem_addr[0]);\n+}\n+\n+/**\n+ * irdma_fill_sockaddr6 - fill in addr info for IPv6 connection\n+ * @cm_node: connection's node\n+ * @event: upper layer's cm event\n+ */\n+static inline void irdma_fill_sockaddr6(struct irdma_cm_node *cm_node,\n+\t\t\t\t\tstruct iw_cm_event *event)\n+{\n+\tstruct sockaddr_in6 *laddr6 = (struct sockaddr_in6 *)&event->local_addr;\n+\tstruct sockaddr_in6 *raddr6 = (struct sockaddr_in6 *)&event->remote_addr;\n+\n+\tladdr6->sin6_family = AF_INET6;\n+\traddr6->sin6_family = AF_INET6;\n+\n+\tladdr6->sin6_port = htons(cm_node->loc_port);\n+\traddr6->sin6_port = htons(cm_node->rem_port);\n+\n+\tirdma_copy_ip_htonl(laddr6->sin6_addr.in6_u.u6_addr32,\n+\t\t\t    cm_node->loc_addr);\n+\tirdma_copy_ip_htonl(raddr6->sin6_addr.in6_u.u6_addr32,\n+\t\t\t    cm_node->rem_addr);\n+}\n+\n+/**\n+ * irdma_get_cmevent_info - for cm event upcall\n+ * @cm_node: connection's node\n+ * @cm_id: upper layers cm struct for the event\n+ * @event: upper layer's cm event\n+ */\n+static inline void irdma_get_cmevent_info(struct irdma_cm_node *cm_node,\n+\t\t\t\t\t  struct iw_cm_id *cm_id,\n+\t\t\t\t\t  struct iw_cm_event *event)\n+{\n+\tmemcpy(&event->local_addr, &cm_id->m_local_addr,\n+\t       sizeof(event->local_addr));\n+\tmemcpy(&event->remote_addr, &cm_id->m_remote_addr,\n+\t       sizeof(event->remote_addr));\n+\tif (cm_node) {\n+\t\tevent->private_data = (void *)cm_node->pdata_buf;\n+\t\tevent->private_data_len = (u8)cm_node->pdata.size;\n+\t\tevent->ird = cm_node->ird_size;\n+\t\tevent->ord = cm_node->ord_size;\n+\t}\n+}\n+\n+/**\n+ * irdma_send_cm_event - upcall cm's event handler\n+ * @cm_node: connection's node\n+ * @cm_id: upper layer's cm info struct\n+ * @type: Event type to indicate\n+ * @status: status for the event type\n+ */\n+static int irdma_send_cm_event(struct irdma_cm_node *cm_node,\n+\t\t\t       struct iw_cm_id *cm_id,\n+\t\t\t       enum iw_cm_event_type type, int status)\n+{\n+\tstruct iw_cm_event event = {};\n+\n+\tevent.event = type;\n+\tevent.status = status;\n+\tswitch (type) {\n+\tcase IW_CM_EVENT_CONNECT_REQUEST:\n+\t\ttrace_irdma_send_cm_event(cm_node, cm_id, type, status,\n+\t\t\t\t\t  __builtin_return_address(0));\n+\t\tif (cm_node->ipv4)\n+\t\t\tirdma_fill_sockaddr4(cm_node, &event);\n+\t\telse\n+\t\t\tirdma_fill_sockaddr6(cm_node, &event);\n+\t\tevent.provider_data = cm_node;\n+\t\tevent.private_data = cm_node->pdata_buf;\n+\t\tevent.private_data_len = (u8)cm_node->pdata.size;\n+\t\tevent.ird = cm_node->ird_size;\n+\t\tbreak;\n+\tcase IW_CM_EVENT_CONNECT_REPLY:\n+\t\ttrace_irdma_send_cm_event(cm_node, cm_id, type, status,\n+\t\t\t\t\t  __builtin_return_address(0));\n+\t\tirdma_get_cmevent_info(cm_node, cm_id, &event);\n+\t\tbreak;\n+\tcase IW_CM_EVENT_ESTABLISHED:\n+\t\ttrace_irdma_send_cm_event(cm_node, cm_id, type, status,\n+\t\t\t\t\t  __builtin_return_address(0));\n+\t\tevent.ird = cm_node->ird_size;\n+\t\tevent.ord = cm_node->ord_size;\n+\t\tbreak;\n+\tcase IW_CM_EVENT_DISCONNECT:\n+\t\ttrace_irdma_send_cm_event_no_node(cm_id, type, status,\n+\t\t\t\t\t\t  __builtin_return_address(0));\n+\t\tbreak;\n+\tcase IW_CM_EVENT_CLOSE:\n+\t\ttrace_irdma_send_cm_event_no_node(cm_id, type, status,\n+\t\t\t\t\t\t  __builtin_return_address(0));\n+\t\tbreak;\n+\tdefault:\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t  \"CM: Unsupported event type received type = %d\\n\",\n+\t\t\t  type);\n+\t\treturn -1;\n+\t}\n+\n+\treturn cm_id->event_handler(cm_id, &event);\n+}\n+\n+/**\n+ * irdma_create_event - create cm event\n+ * @cm_node: connection's node\n+ * @type: Event type to generate\n+ */\n+static struct irdma_cm_event *irdma_create_event(struct irdma_cm_node *cm_node,\n+\t\t\t\t\t\t enum irdma_cm_event_type type)\n+{\n+\tstruct irdma_cm_event *event;\n+\n+\tif (!cm_node->cm_id)\n+\t\treturn NULL;\n+\n+\tevent = kzalloc(sizeof(*event), GFP_ATOMIC);\n+\n+\tif (!event)\n+\t\treturn NULL;\n+\n+\tevent->type = type;\n+\tevent->cm_node = cm_node;\n+\tmemcpy(event->cm_info.rem_addr, cm_node->rem_addr,\n+\t       sizeof(event->cm_info.rem_addr));\n+\tmemcpy(event->cm_info.loc_addr, cm_node->loc_addr,\n+\t       sizeof(event->cm_info.loc_addr));\n+\tevent->cm_info.rem_port = cm_node->rem_port;\n+\tevent->cm_info.loc_port = cm_node->loc_port;\n+\tevent->cm_info.cm_id = cm_node->cm_id;\n+\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t  \"CM: node=%p event=%p type=%u dst=%pI4 src=%pI4\\n\", cm_node,\n+\t\t  event, type, event->cm_info.loc_addr,\n+\t\t  event->cm_info.rem_addr);\n+\ttrace_irdma_create_event(cm_node, type, __builtin_return_address(0));\n+\tirdma_cm_post_event(event);\n+\n+\treturn event;\n+}\n+\n+/**\n+ * irdma_free_retrans_entry - free send entry\n+ * @cm_node: connection's node\n+ */\n+static void irdma_free_retrans_entry(struct irdma_cm_node *cm_node)\n+{\n+\tstruct irdma_device *iwdev = cm_node->iwdev;\n+\tstruct irdma_timer_entry *send_entry;\n+\n+\tsend_entry = cm_node->send_entry;\n+\tif (!send_entry)\n+\t\treturn;\n+\n+\tcm_node->send_entry = NULL;\n+\tirdma_free_sqbuf(&iwdev->vsi, send_entry->sqbuf);\n+\tkfree(send_entry);\n+\tatomic_dec(&cm_node->ref_count);\n+}\n+\n+/**\n+ * irdma_cleanup_retrans_entry - free send entry with lock\n+ * @cm_node: connection's node\n+ */\n+static void irdma_cleanup_retrans_entry(struct irdma_cm_node *cm_node)\n+{\n+\tunsigned long flags;\n+\n+\tspin_lock_irqsave(&cm_node->retrans_list_lock, flags);\n+\tirdma_free_retrans_entry(cm_node);\n+\tspin_unlock_irqrestore(&cm_node->retrans_list_lock, flags);\n+}\n+\n+/**\n+ * irdma_form_ah_cm_frame - get a free packet and build frame with address handle\n+ * @cm_node: connection's node ionfo to use in frame\n+ * @options: pointer to options info\n+ * @hdr: pointer mpa header\n+ * @pdata: pointer to private data\n+ * @flags:  indicates FIN or ACK\n+ */\n+static struct irdma_puda_buf *irdma_form_ah_cm_frame(struct irdma_cm_node *cm_node,\n+\t\t\t\t\t\t     struct irdma_kmem_info *options,\n+\t\t\t\t\t\t     struct irdma_kmem_info *hdr,\n+\t\t\t\t\t\t     struct irdma_kmem_info *pdata,\n+\t\t\t\t\t\t     u8 flags)\n+{\n+\tstruct irdma_puda_buf *sqbuf;\n+\tstruct irdma_sc_vsi *vsi = &cm_node->iwdev->vsi;\n+\tu8 *buf;\n+\tstruct tcphdr *tcph;\n+\tu16 pktsize;\n+\tu32 opts_len = 0;\n+\tu32 pd_len = 0;\n+\tu32 hdr_len = 0;\n+\n+\tif (!cm_node->ah || !cm_node->ah->ah_info.ah_valid) {\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev), \"CM: AH invalid\\n\");\n+\t\treturn NULL;\n+\t}\n+\n+\tsqbuf = irdma_puda_get_bufpool(vsi->ilq);\n+\tif (!sqbuf) {\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev), \"CM: SQ buf NULL\\n\");\n+\t\treturn NULL;\n+\t}\n+\n+\tsqbuf->ah_id = cm_node->ah->ah_info.ah_idx;\n+\tbuf = sqbuf->mem.va;\n+\tif (options)\n+\t\topts_len = (u32)options->size;\n+\n+\tif (hdr)\n+\t\thdr_len = hdr->size;\n+\n+\tif (pdata)\n+\t\tpd_len = pdata->size;\n+\n+\tpktsize = sizeof(*tcph) + opts_len + hdr_len + pd_len;\n+\n+\tmemset(buf, 0, pktsize);\n+\n+\tsqbuf->totallen = pktsize;\n+\tsqbuf->tcphlen = sizeof(*tcph) + opts_len;\n+\tsqbuf->scratch = (void *)cm_node;\n+\n+\ttcph = (struct tcphdr *)buf;\n+\tbuf += sizeof(*tcph);\n+\n+\ttcph->source = htons(cm_node->loc_port);\n+\ttcph->dest = htons(cm_node->rem_port);\n+\ttcph->seq = htonl(cm_node->tcp_cntxt.loc_seq_num);\n+\n+\tif (flags & SET_ACK) {\n+\t\tcm_node->tcp_cntxt.loc_ack_num = cm_node->tcp_cntxt.rcv_nxt;\n+\t\ttcph->ack_seq = htonl(cm_node->tcp_cntxt.loc_ack_num);\n+\t\ttcph->ack = 1;\n+\t} else {\n+\t\ttcph->ack_seq = 0;\n+\t}\n+\n+\tif (flags & SET_SYN) {\n+\t\tcm_node->tcp_cntxt.loc_seq_num++;\n+\t\ttcph->syn = 1;\n+\t} else {\n+\t\tcm_node->tcp_cntxt.loc_seq_num += hdr_len + pd_len;\n+\t}\n+\n+\tif (flags & SET_FIN) {\n+\t\tcm_node->tcp_cntxt.loc_seq_num++;\n+\t\ttcph->fin = 1;\n+\t}\n+\n+\tif (flags & SET_RST)\n+\t\ttcph->rst = 1;\n+\n+\ttcph->doff = (u16)((sizeof(*tcph) + opts_len + 3) >> 2);\n+\tsqbuf->tcphlen = tcph->doff << 2;\n+\ttcph->window = htons(cm_node->tcp_cntxt.rcv_wnd);\n+\ttcph->urg_ptr = 0;\n+\n+\tif (opts_len) {\n+\t\tmemcpy(buf, options->addr, opts_len);\n+\t\tbuf += opts_len;\n+\t}\n+\n+\tif (hdr_len) {\n+\t\tmemcpy(buf, hdr->addr, hdr_len);\n+\t\tbuf += hdr_len;\n+\t}\n+\n+\tif (pdata && pdata->addr)\n+\t\tmemcpy(buf, pdata->addr, pdata->size);\n+\n+\tatomic_set(&sqbuf->refcount, 1);\n+\n+\tirdma_debug_buf(vsi->dev, IRDMA_DEBUG_ILQ, \"TRANSMIT ILQ BUFFER\",\n+\t\t\tsqbuf->mem.va, sqbuf->totallen);\n+\n+\treturn sqbuf;\n+}\n+\n+/**\n+ * irdma_form_uda_cm_frame - get a free packet and build frame full tcpip packet\n+ * @cm_node: connection's node ionfo to use in frame\n+ * @options: pointer to options info\n+ * @hdr: pointer mpa header\n+ * @pdata: pointer to private data\n+ * @flags:  indicates FIN or ACK\n+ */\n+static struct irdma_puda_buf *irdma_form_uda_cm_frame(struct irdma_cm_node *cm_node,\n+\t\t\t\t\t\t      struct irdma_kmem_info *options,\n+\t\t\t\t\t\t      struct irdma_kmem_info *hdr,\n+\t\t\t\t\t\t      struct irdma_kmem_info *pdata,\n+\t\t\t\t\t\t      u8 flags)\n+{\n+\tstruct irdma_puda_buf *sqbuf;\n+\tstruct irdma_sc_vsi *vsi = &cm_node->iwdev->vsi;\n+\tu8 *buf;\n+\n+\tstruct tcphdr *tcph;\n+\tstruct iphdr *iph;\n+\tstruct ipv6hdr *ip6h;\n+\tstruct ethhdr *ethh;\n+\tu16 pktsize;\n+\tu16 eth_hlen = ETH_HLEN;\n+\tu32 opts_len = 0;\n+\tu32 pd_len = 0;\n+\tu32 hdr_len = 0;\n+\n+\tu16 vtag;\n+\n+\tsqbuf = irdma_puda_get_bufpool(vsi->ilq);\n+\tif (!sqbuf)\n+\t\treturn NULL;\n+\n+\tbuf = sqbuf->mem.va;\n+\n+\tif (options)\n+\t\topts_len = (u32)options->size;\n+\n+\tif (hdr)\n+\t\thdr_len = hdr->size;\n+\n+\tif (pdata)\n+\t\tpd_len = pdata->size;\n+\n+\tif (cm_node->vlan_id < VLAN_N_VID)\n+\t\teth_hlen += 4;\n+\n+\tif (cm_node->ipv4)\n+\t\tpktsize = sizeof(*iph) + sizeof(*tcph);\n+\telse\n+\t\tpktsize = sizeof(*ip6h) + sizeof(*tcph);\n+\tpktsize += opts_len + hdr_len + pd_len;\n+\n+\tmemset(buf, 0, eth_hlen + pktsize);\n+\n+\tsqbuf->totallen = pktsize + eth_hlen;\n+\tsqbuf->maclen = eth_hlen;\n+\tsqbuf->tcphlen = sizeof(*tcph) + opts_len;\n+\tsqbuf->scratch = (void *)cm_node;\n+\n+\tethh = (struct ethhdr *)buf;\n+\tbuf += eth_hlen;\n+\n+\tif (cm_node->do_lpb)\n+\t\tsqbuf->do_lpb = true;\n+\n+\tif (cm_node->ipv4) {\n+\t\tsqbuf->ipv4 = true;\n+\n+\t\tiph = (struct iphdr *)buf;\n+\t\tbuf += sizeof(*iph);\n+\t\ttcph = (struct tcphdr *)buf;\n+\t\tbuf += sizeof(*tcph);\n+\n+\t\tether_addr_copy(ethh->h_dest, cm_node->rem_mac);\n+\t\tether_addr_copy(ethh->h_source, cm_node->loc_mac);\n+\t\tif (cm_node->vlan_id < VLAN_N_VID) {\n+\t\t\t((struct vlan_ethhdr *)ethh)->h_vlan_proto =\n+\t\t\t\thtons(ETH_P_8021Q);\n+\t\t\tvtag = (cm_node->user_pri << VLAN_PRIO_SHIFT) |\n+\t\t\t       cm_node->vlan_id;\n+\t\t\t((struct vlan_ethhdr *)ethh)->h_vlan_TCI = htons(vtag);\n+\n+\t\t\t((struct vlan_ethhdr *)ethh)->h_vlan_encapsulated_proto =\n+\t\t\t\thtons(ETH_P_IP);\n+\t\t} else {\n+\t\t\tethh->h_proto = htons(ETH_P_IP);\n+\t\t}\n+\n+\t\tiph->version = IPVERSION;\n+\t\tiph->ihl = 5; /* 5 * 4Byte words, IP headr len */\n+\t\tiph->tos = cm_node->tos;\n+\t\tiph->tot_len = htons(pktsize);\n+\t\tiph->id = htons(++cm_node->tcp_cntxt.loc_id);\n+\n+\t\tiph->frag_off = htons(0x4000);\n+\t\tiph->ttl = 0x40;\n+\t\tiph->protocol = IPPROTO_TCP;\n+\t\tiph->saddr = htonl(cm_node->loc_addr[0]);\n+\t\tiph->daddr = htonl(cm_node->rem_addr[0]);\n+\t} else {\n+\t\tsqbuf->ipv4 = false;\n+\t\tip6h = (struct ipv6hdr *)buf;\n+\t\tbuf += sizeof(*ip6h);\n+\t\ttcph = (struct tcphdr *)buf;\n+\t\tbuf += sizeof(*tcph);\n+\n+\t\tether_addr_copy(ethh->h_dest, cm_node->rem_mac);\n+\t\tether_addr_copy(ethh->h_source, cm_node->loc_mac);\n+\t\tif (cm_node->vlan_id < VLAN_N_VID) {\n+\t\t\t((struct vlan_ethhdr *)ethh)->h_vlan_proto =\n+\t\t\t\thtons(ETH_P_8021Q);\n+\t\t\tvtag = (cm_node->user_pri << VLAN_PRIO_SHIFT) |\n+\t\t\t       cm_node->vlan_id;\n+\t\t\t((struct vlan_ethhdr *)ethh)->h_vlan_TCI = htons(vtag);\n+\t\t\t((struct vlan_ethhdr *)ethh)->h_vlan_encapsulated_proto =\n+\t\t\t\thtons(ETH_P_IPV6);\n+\t\t} else {\n+\t\t\tethh->h_proto = htons(ETH_P_IPV6);\n+\t\t}\n+\t\tip6h->version = 6;\n+\t\tip6h->priority = cm_node->tos >> 4;\n+\t\tip6h->flow_lbl[0] = cm_node->tos << 4;\n+\t\tip6h->flow_lbl[1] = 0;\n+\t\tip6h->flow_lbl[2] = 0;\n+\t\tip6h->payload_len = htons(pktsize - sizeof(*ip6h));\n+\t\tip6h->nexthdr = 6;\n+\t\tip6h->hop_limit = 128;\n+\t\tirdma_copy_ip_htonl(ip6h->saddr.in6_u.u6_addr32,\n+\t\t\t\t    cm_node->loc_addr);\n+\t\tirdma_copy_ip_htonl(ip6h->daddr.in6_u.u6_addr32,\n+\t\t\t\t    cm_node->rem_addr);\n+\t}\n+\n+\ttcph->source = htons(cm_node->loc_port);\n+\ttcph->dest = htons(cm_node->rem_port);\n+\ttcph->seq = htonl(cm_node->tcp_cntxt.loc_seq_num);\n+\n+\tif (flags & SET_ACK) {\n+\t\tcm_node->tcp_cntxt.loc_ack_num = cm_node->tcp_cntxt.rcv_nxt;\n+\t\ttcph->ack_seq = htonl(cm_node->tcp_cntxt.loc_ack_num);\n+\t\ttcph->ack = 1;\n+\t} else {\n+\t\ttcph->ack_seq = 0;\n+\t}\n+\n+\tif (flags & SET_SYN) {\n+\t\tcm_node->tcp_cntxt.loc_seq_num++;\n+\t\ttcph->syn = 1;\n+\t} else {\n+\t\tcm_node->tcp_cntxt.loc_seq_num += hdr_len + pd_len;\n+\t}\n+\n+\tif (flags & SET_FIN) {\n+\t\tcm_node->tcp_cntxt.loc_seq_num++;\n+\t\ttcph->fin = 1;\n+\t}\n+\n+\tif (flags & SET_RST)\n+\t\ttcph->rst = 1;\n+\n+\ttcph->doff = (u16)((sizeof(*tcph) + opts_len + 3) >> 2);\n+\tsqbuf->tcphlen = tcph->doff << 2;\n+\ttcph->window = htons(cm_node->tcp_cntxt.rcv_wnd);\n+\ttcph->urg_ptr = 0;\n+\n+\tif (opts_len) {\n+\t\tmemcpy(buf, options->addr, opts_len);\n+\t\tbuf += opts_len;\n+\t}\n+\n+\tif (hdr_len) {\n+\t\tmemcpy(buf, hdr->addr, hdr_len);\n+\t\tbuf += hdr_len;\n+\t}\n+\n+\tif (pdata && pdata->addr)\n+\t\tmemcpy(buf, pdata->addr, pdata->size);\n+\n+\tatomic_set(&sqbuf->refcount, 1);\n+\n+\tirdma_debug_buf(vsi->dev, IRDMA_DEBUG_ILQ, \"TRANSMIT ILQ BUFFER\",\n+\t\t\tsqbuf->mem.va, sqbuf->totallen);\n+\n+\treturn sqbuf;\n+}\n+\n+/**\n+ * irdma_send_reset - Send RST packet\n+ * @cm_node: connection's node\n+ */\n+int irdma_send_reset(struct irdma_cm_node *cm_node)\n+{\n+\tstruct irdma_puda_buf *sqbuf;\n+\tint flags = SET_RST | SET_ACK;\n+\n+\ttrace_irdma_send_reset(cm_node, 0, __builtin_return_address(0));\n+\tsqbuf = cm_node->cm_core->form_cm_frame(cm_node, NULL, NULL, NULL,\n+\t\t\t\t\t\tflags);\n+\tif (!sqbuf)\n+\t\treturn -1;\n+\n+\treturn irdma_schedule_cm_timer(cm_node, sqbuf, IRDMA_TIMER_TYPE_SEND, 0,\n+\t\t\t\t       1);\n+}\n+\n+/**\n+ * irdma_active_open_err - send event for active side cm error\n+ * @cm_node: connection's node\n+ * @reset: Flag to send reset or not\n+ */\n+static void irdma_active_open_err(struct irdma_cm_node *cm_node, bool reset)\n+{\n+\ttrace_irdma_active_open_err(cm_node, reset,\n+\t\t\t\t    __builtin_return_address(0));\n+\tirdma_cleanup_retrans_entry(cm_node);\n+\tcm_node->cm_core->stats_connect_errs++;\n+\tif (reset) {\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t  \"CM: cm_node=%p state=%d\\n\", cm_node,\n+\t\t\t  cm_node->state);\n+\t\tatomic_inc(&cm_node->ref_count);\n+\t\tirdma_send_reset(cm_node);\n+\t}\n+\n+\tcm_node->state = IRDMA_CM_STATE_CLOSED;\n+\tirdma_create_event(cm_node, IRDMA_CM_EVENT_ABORTED);\n+}\n+\n+/**\n+ * irdma_passive_open_err - handle passive side cm error\n+ * @cm_node: connection's node\n+ * @reset: send reset or just free cm_node\n+ */\n+static void irdma_passive_open_err(struct irdma_cm_node *cm_node, bool reset)\n+{\n+\tirdma_cleanup_retrans_entry(cm_node);\n+\tcm_node->cm_core->stats_passive_errs++;\n+\tcm_node->state = IRDMA_CM_STATE_CLOSED;\n+\tibdev_dbg(to_ibdev(cm_node->iwdev), \"CM: cm_node=%p state =%d\\n\",\n+\t\t  cm_node, cm_node->state);\n+\ttrace_irdma_passive_open_err(cm_node, reset,\n+\t\t\t\t     __builtin_return_address(0));\n+\tif (reset)\n+\t\tirdma_send_reset(cm_node);\n+\telse\n+\t\tirdma_rem_ref_cm_node(cm_node);\n+}\n+\n+/**\n+ * irdma_event_connect_error - to create connect error event\n+ * @event: cm information for connect event\n+ */\n+static void irdma_event_connect_error(struct irdma_cm_event *event)\n+{\n+\tstruct irdma_qp *iwqp;\n+\tstruct iw_cm_id *cm_id;\n+\n+\tcm_id = event->cm_node->cm_id;\n+\tif (!cm_id)\n+\t\treturn;\n+\n+\tiwqp = cm_id->provider_data;\n+\n+\tif (!iwqp || !iwqp->iwdev)\n+\t\treturn;\n+\n+\tiwqp->cm_id = NULL;\n+\tcm_id->provider_data = NULL;\n+\tirdma_send_cm_event(event->cm_node, cm_id, IW_CM_EVENT_CONNECT_REPLY,\n+\t\t\t    -ECONNRESET);\n+\tcm_id->rem_ref(cm_id);\n+\tirdma_rem_ref_cm_node(event->cm_node);\n+}\n+\n+/**\n+ * irdma_process_options - process options from TCP header\n+ * @cm_node: connection's node\n+ * @optionsloc: point to start of options\n+ * @optionsize: size of all options\n+ * @syn_pkt: flag if syn packet\n+ */\n+static int irdma_process_options(struct irdma_cm_node *cm_node, u8 *optionsloc,\n+\t\t\t\t u32 optionsize, u32 syn_pkt)\n+{\n+\tu32 tmp;\n+\tu32 offset = 0;\n+\tunion all_known_options *all_options;\n+\tchar got_mss_option = 0;\n+\n+\twhile (offset < optionsize) {\n+\t\tall_options = (union all_known_options *)(optionsloc + offset);\n+\t\tswitch (all_options->base.optionnum) {\n+\t\tcase OPTION_NUM_EOL:\n+\t\t\toffset = optionsize;\n+\t\t\tbreak;\n+\t\tcase OPTION_NUM_NONE:\n+\t\t\toffset += 1;\n+\t\t\tcontinue;\n+\t\tcase OPTION_NUM_MSS:\n+\t\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t\t  \"CM: MSS Length: %d Offset: %d Size: %d\\n\",\n+\t\t\t\t  all_options->mss.len, offset, optionsize);\n+\t\t\tgot_mss_option = 1;\n+\t\t\tif (all_options->mss.len != 4)\n+\t\t\t\treturn -EINVAL;\n+\t\t\ttmp = ntohs(all_options->mss.mss);\n+\t\t\tif ((cm_node->ipv4 &&\n+\t\t\t     (tmp + IRDMA_MTU_TO_MSS_IPV4) < IRDMA_MIN_MTU_IPV4) ||\n+\t\t\t    (!cm_node->ipv4 &&\n+\t\t\t     (tmp + IRDMA_MTU_TO_MSS_IPV6) < IRDMA_MIN_MTU_IPV6))\n+\t\t\t\treturn -EINVAL;\n+\t\t\tif (tmp < cm_node->tcp_cntxt.mss)\n+\t\t\t\tcm_node->tcp_cntxt.mss = tmp;\n+\t\t\tbreak;\n+\t\tcase OPTION_NUM_WINDOW_SCALE:\n+\t\t\tcm_node->tcp_cntxt.snd_wscale =\n+\t\t\t\tall_options->windowscale.shiftcount;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t\t  \"CM: Unsupported TCP Option: %x\\n\",\n+\t\t\t\t  all_options->base.optionnum);\n+\t\t\tbreak;\n+\t\t}\n+\t\toffset += all_options->base.len;\n+\t}\n+\tif (!got_mss_option && syn_pkt)\n+\t\tcm_node->tcp_cntxt.mss = IRDMA_CM_DEFAULT_MSS;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * irdma_handle_tcp_options - setup TCP context info after parsing TCP options\n+ * @cm_node: connection's node\n+ * @tcph: pointer tcp header\n+ * @optionsize: size of options rcvd\n+ * @passive: active or passive flag\n+ */\n+static int irdma_handle_tcp_options(struct irdma_cm_node *cm_node,\n+\t\t\t\t    struct tcphdr *tcph, int optionsize,\n+\t\t\t\t    int passive)\n+{\n+\tu8 *optionsloc = (u8 *)&tcph[1];\n+\n+\tif (optionsize) {\n+\t\tif (irdma_process_options(cm_node, optionsloc, optionsize,\n+\t\t\t\t\t  (u32)tcph->syn)) {\n+\t\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t\t  \"CM: Node %p, Sending Reset\\n\", cm_node);\n+\t\t\tif (passive)\n+\t\t\t\tirdma_passive_open_err(cm_node, true);\n+\t\t\telse\n+\t\t\t\tirdma_active_open_err(cm_node, true);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\tcm_node->tcp_cntxt.snd_wnd = ntohs(tcph->window)\n+\t\t\t\t     << cm_node->tcp_cntxt.snd_wscale;\n+\n+\tif (cm_node->tcp_cntxt.snd_wnd > cm_node->tcp_cntxt.max_snd_wnd)\n+\t\tcm_node->tcp_cntxt.max_snd_wnd = cm_node->tcp_cntxt.snd_wnd;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * irdma_build_mpa_v1 - build a MPA V1 frame\n+ * @cm_node: connection's node\n+ * @start_addr: address where to build frame\n+ * @mpa_key: to do read0 or write0\n+ */\n+static void irdma_build_mpa_v1(struct irdma_cm_node *cm_node, void *start_addr,\n+\t\t\t       u8 mpa_key)\n+{\n+\tstruct ietf_mpa_v1 *mpa_frame = start_addr;\n+\n+\tswitch (mpa_key) {\n+\tcase MPA_KEY_REQUEST:\n+\t\tmemcpy(mpa_frame->key, IEFT_MPA_KEY_REQ, IETF_MPA_KEY_SIZE);\n+\t\tbreak;\n+\tcase MPA_KEY_REPLY:\n+\t\tmemcpy(mpa_frame->key, IEFT_MPA_KEY_REP, IETF_MPA_KEY_SIZE);\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+\tmpa_frame->flags = IETF_MPA_FLAGS_CRC;\n+\tmpa_frame->rev = cm_node->mpa_frame_rev;\n+\tmpa_frame->priv_data_len = htons(cm_node->pdata.size);\n+}\n+\n+/**\n+ * irdma_build_mpa_v2 - build a MPA V2 frame\n+ * @cm_node: connection's node\n+ * @start_addr: buffer start address\n+ * @mpa_key: to do read0 or write0\n+ */\n+static void irdma_build_mpa_v2(struct irdma_cm_node *cm_node, void *start_addr,\n+\t\t\t       u8 mpa_key)\n+{\n+\tstruct ietf_mpa_v2 *mpa_frame = start_addr;\n+\tstruct ietf_rtr_msg *rtr_msg = &mpa_frame->rtr_msg;\n+\tu16 ctrl_ird, ctrl_ord;\n+\n+\t/* initialize the upper 5 bytes of the frame */\n+\tirdma_build_mpa_v1(cm_node, start_addr, mpa_key);\n+\tmpa_frame->flags |= IETF_MPA_V2_FLAG;\n+\tmpa_frame->priv_data_len = cpu_to_be16(be16_to_cpu(mpa_frame->priv_data_len) +\n+\t\t\t\t\t       IETF_RTR_MSG_SIZE);\n+\n+\t/* initialize RTR msg */\n+\tif (cm_node->mpav2_ird_ord == IETF_NO_IRD_ORD) {\n+\t\tctrl_ird = IETF_NO_IRD_ORD;\n+\t\tctrl_ord = IETF_NO_IRD_ORD;\n+\t} else {\n+\t\tctrl_ird = (cm_node->ird_size > IETF_NO_IRD_ORD) ?\n+\t\t\t\t   IETF_NO_IRD_ORD :\n+\t\t\t\t   cm_node->ird_size;\n+\t\tctrl_ord = (cm_node->ord_size > IETF_NO_IRD_ORD) ?\n+\t\t\t\t   IETF_NO_IRD_ORD :\n+\t\t\t\t   cm_node->ord_size;\n+\t}\n+\tctrl_ird |= IETF_PEER_TO_PEER;\n+\n+\tswitch (mpa_key) {\n+\tcase MPA_KEY_REQUEST:\n+\t\tctrl_ord |= IETF_RDMA0_WRITE;\n+\t\tctrl_ord |= IETF_RDMA0_READ;\n+\t\tbreak;\n+\tcase MPA_KEY_REPLY:\n+\t\tswitch (cm_node->send_rdma0_op) {\n+\t\tcase SEND_RDMA_WRITE_ZERO:\n+\t\t\tctrl_ord |= IETF_RDMA0_WRITE;\n+\t\t\tbreak;\n+\t\tcase SEND_RDMA_READ_ZERO:\n+\t\t\tctrl_ord |= IETF_RDMA0_READ;\n+\t\t\tbreak;\n+\t\t}\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+\trtr_msg->ctrl_ird = htons(ctrl_ird);\n+\trtr_msg->ctrl_ord = htons(ctrl_ord);\n+}\n+\n+/**\n+ * irdma_cm_build_mpa_frame - build mpa frame for mpa version 1 or version 2\n+ * @cm_node: connection's node\n+ * @mpa: mpa: data buffer\n+ * @mpa_key: to do read0 or write0\n+ */\n+static int irdma_cm_build_mpa_frame(struct irdma_cm_node *cm_node,\n+\t\t\t\t    struct irdma_kmem_info *mpa, u8 mpa_key)\n+{\n+\tint hdr_len = 0;\n+\n+\tswitch (cm_node->mpa_frame_rev) {\n+\tcase IETF_MPA_V1:\n+\t\thdr_len = sizeof(struct ietf_mpa_v1);\n+\t\tirdma_build_mpa_v1(cm_node, mpa->addr, mpa_key);\n+\t\tbreak;\n+\tcase IETF_MPA_V2:\n+\t\thdr_len = sizeof(struct ietf_mpa_v2);\n+\t\tirdma_build_mpa_v2(cm_node, mpa->addr, mpa_key);\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+\n+\treturn hdr_len;\n+}\n+\n+/**\n+ * irdma_send_mpa_request - active node send mpa request to passive node\n+ * @cm_node: connection's node\n+ */\n+static int irdma_send_mpa_request(struct irdma_cm_node *cm_node)\n+{\n+\tstruct irdma_puda_buf *sqbuf;\n+\n+\tif (!cm_node) {\n+\t\tpr_err(\"cm_node == NULL\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tcm_node->mpa_hdr.addr = &cm_node->mpa_frame;\n+\tcm_node->mpa_hdr.size = irdma_cm_build_mpa_frame(cm_node,\n+\t\t\t\t\t\t\t &cm_node->mpa_hdr,\n+\t\t\t\t\t\t\t MPA_KEY_REQUEST);\n+\tif (!cm_node->mpa_hdr.size) {\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev), \"CM: mpa size = %d\\n\",\n+\t\t\t  cm_node->mpa_hdr.size);\n+\t\treturn -1;\n+\t}\n+\n+\tsqbuf = cm_node->cm_core->form_cm_frame(cm_node, NULL,\n+\t\t\t\t\t\t&cm_node->mpa_hdr,\n+\t\t\t\t\t\t&cm_node->pdata, SET_ACK);\n+\tif (!sqbuf)\n+\t\treturn -1;\n+\n+\treturn irdma_schedule_cm_timer(cm_node, sqbuf, IRDMA_TIMER_TYPE_SEND, 1,\n+\t\t\t\t       0);\n+}\n+\n+/**\n+ * irdma_send_mpa_reject -\n+ * @cm_node: connection's node\n+ * @pdata: reject data for connection\n+ * @plen: length of reject data\n+ */\n+static int irdma_send_mpa_reject(struct irdma_cm_node *cm_node,\n+\t\t\t\t const void *pdata, u8 plen)\n+{\n+\tstruct irdma_puda_buf *sqbuf;\n+\tstruct irdma_kmem_info priv_info;\n+\n+\tcm_node->mpa_hdr.addr = &cm_node->mpa_frame;\n+\tcm_node->mpa_hdr.size = irdma_cm_build_mpa_frame(cm_node,\n+\t\t\t\t\t\t\t &cm_node->mpa_hdr,\n+\t\t\t\t\t\t\t MPA_KEY_REPLY);\n+\n+\tcm_node->mpa_frame.flags |= IETF_MPA_FLAGS_REJECT;\n+\tpriv_info.addr = (void *)pdata;\n+\tpriv_info.size = plen;\n+\n+\tsqbuf = cm_node->cm_core->form_cm_frame(cm_node, NULL,\n+\t\t\t\t\t\t&cm_node->mpa_hdr, &priv_info,\n+\t\t\t\t\t\tSET_ACK | SET_FIN);\n+\tif (!sqbuf)\n+\t\treturn -ENOMEM;\n+\n+\tcm_node->state = IRDMA_CM_STATE_FIN_WAIT1;\n+\n+\treturn irdma_schedule_cm_timer(cm_node, sqbuf, IRDMA_TIMER_TYPE_SEND, 1,\n+\t\t\t\t       0);\n+}\n+\n+/**\n+ * irdma_mpav2_negotiate_ird_ord - negotiate MPAv2 IRD/ORD\n+ * @cm_node: connection's node\n+ * @buf: Data pointer\n+ */\n+static int irdma_negotiate_mpa_v2_ird_ord(struct irdma_cm_node *cm_node,\n+\t\t\t\t\t  u8 *buf)\n+{\n+\tstruct ietf_mpa_v2 *mpa_v2_frame;\n+\tstruct ietf_rtr_msg *rtr_msg;\n+\tu16 ird_size;\n+\tu16 ord_size;\n+\tu16 ctrl_ord;\n+\tu16 ctrl_ird;\n+\n+\tmpa_v2_frame = (struct ietf_mpa_v2 *)buf;\n+\trtr_msg = &mpa_v2_frame->rtr_msg;\n+\n+\t/* parse rtr message */\n+\tctrl_ord = ntohs(rtr_msg->ctrl_ord);\n+\tctrl_ird = ntohs(rtr_msg->ctrl_ird);\n+\tird_size = ctrl_ird & IETF_NO_IRD_ORD;\n+\tord_size = ctrl_ord & IETF_NO_IRD_ORD;\n+\n+\tif (!(ctrl_ird & IETF_PEER_TO_PEER))\n+\t\treturn -1;\n+\n+\tif (ird_size == IETF_NO_IRD_ORD || ord_size == IETF_NO_IRD_ORD) {\n+\t\tcm_node->mpav2_ird_ord = IETF_NO_IRD_ORD;\n+\t\tgoto negotiate_done;\n+\t}\n+\n+\tif (cm_node->state != IRDMA_CM_STATE_MPAREQ_SENT) {\n+\t\t/* responder */\n+\t\tif (!ord_size && (ctrl_ord & IETF_RDMA0_READ))\n+\t\t\tcm_node->ird_size = 1;\n+\t\tif (cm_node->ord_size > ird_size)\n+\t\t\tcm_node->ord_size = ird_size;\n+\t} else {\n+\t\t/* initiator */\n+\t\tif (!ird_size && (ctrl_ord & IETF_RDMA0_READ))\n+\t\t\t/* Remote peer doesn't support RDMA0_READ */\n+\t\t\treturn -1;\n+\n+\t\tif (cm_node->ord_size > ird_size)\n+\t\t\tcm_node->ord_size = ird_size;\n+\n+\t\tif (cm_node->ird_size < ord_size)\n+\t\t/* no resources available */\n+\t\t\treturn -1;\n+\t}\n+\n+negotiate_done:\n+\tif (ctrl_ord & IETF_RDMA0_READ)\n+\t\tcm_node->send_rdma0_op = SEND_RDMA_READ_ZERO;\n+\telse if (ctrl_ord & IETF_RDMA0_WRITE)\n+\t\tcm_node->send_rdma0_op = SEND_RDMA_WRITE_ZERO;\n+\telse\n+\t\t/* Not supported RDMA0 operation */\n+\t\treturn -1;\n+\n+\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t  \"CM: MPAV2 Negotiated ORD: %d, IRD: %d\\n\",\n+\t\t  cm_node->ord_size, cm_node->ird_size);\n+\ttrace_irdma_negotiate_mpa_v2(cm_node);\n+\treturn 0;\n+}\n+\n+/**\n+ * recv_mpa - process an IETF MPA frame\n+ * @cm_node: connection's node\n+ * @buf: Data pointer\n+ * @type: to return accept or reject\n+ * @len: Len of mpa buffer\n+ */\n+static int irdma_parse_mpa(struct irdma_cm_node *cm_node, u8 *buf, u32 *type,\n+\t\t\t   u32 len)\n+{\n+\tstruct ietf_mpa_v1 *mpa_frame;\n+\tint mpa_hdr_len;\n+\tint priv_data_len;\n+\n+\t*type = IRDMA_MPA_REQUEST_ACCEPT;\n+\n+\tif (len < sizeof(struct ietf_mpa_v1)) {\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t  \"CM: ietf buffer small (%x)\\n\", len);\n+\t\treturn -1;\n+\t}\n+\n+\tmpa_frame = (struct ietf_mpa_v1 *)buf;\n+\tmpa_hdr_len = sizeof(struct ietf_mpa_v1);\n+\tpriv_data_len = ntohs(mpa_frame->priv_data_len);\n+\n+\tif (priv_data_len > IETF_MAX_PRIV_DATA_LEN) {\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev), \"CM: large pri_data %d\\n\",\n+\t\t\t  priv_data_len);\n+\t\treturn -1;\n+\t}\n+\n+\tif (mpa_frame->rev != IETF_MPA_V1 && mpa_frame->rev != IETF_MPA_V2) {\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t  \"CM: unsupported mpa rev = %d\\n\", mpa_frame->rev);\n+\t\treturn -1;\n+\t}\n+\n+\tif (mpa_frame->rev > cm_node->mpa_frame_rev) {\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev), \"CM: rev %d\\n\",\n+\t\t\t  mpa_frame->rev);\n+\t\treturn -1;\n+\t}\n+\n+\tcm_node->mpa_frame_rev = mpa_frame->rev;\n+\tif (cm_node->state != IRDMA_CM_STATE_MPAREQ_SENT) {\n+\t\tif (memcmp(mpa_frame->key, IEFT_MPA_KEY_REQ,\n+\t\t\t   IETF_MPA_KEY_SIZE)) {\n+\t\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t\t  \"CM: Unexpected MPA Key received\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t} else {\n+\t\tif (memcmp(mpa_frame->key, IEFT_MPA_KEY_REP,\n+\t\t\t   IETF_MPA_KEY_SIZE)) {\n+\t\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t\t  \"CM: Unexpected MPA Key received\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\tif (priv_data_len + mpa_hdr_len > len) {\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t  \"CM: ietf buffer len(%x + %x != %x)\\n\",\n+\t\t\t  priv_data_len, mpa_hdr_len, len);\n+\t\treturn -1;\n+\t}\n+\n+\tif (len > IRDMA_MAX_CM_BUF) {\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t  \"CM: ietf buffer large len = %d\\n\", len);\n+\t\treturn -1;\n+\t}\n+\n+\tswitch (mpa_frame->rev) {\n+\tcase IETF_MPA_V2:\n+\t\tmpa_hdr_len += IETF_RTR_MSG_SIZE;\n+\t\tif (irdma_negotiate_mpa_v2_ird_ord(cm_node, buf))\n+\t\t\treturn -1;\n+\t\tbreak;\n+\tcase IETF_MPA_V1:\n+\tdefault:\n+\t\tbreak;\n+\t}\n+\n+\tmemcpy(cm_node->pdata_buf, buf + mpa_hdr_len, priv_data_len);\n+\tcm_node->pdata.size = priv_data_len;\n+\n+\tif (mpa_frame->flags & IETF_MPA_FLAGS_REJECT)\n+\t\t*type = IRDMA_MPA_REQUEST_REJECT;\n+\n+\tif (mpa_frame->flags & IETF_MPA_FLAGS_MARKERS)\n+\t\tcm_node->snd_mark_en = true;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * irdma_schedule_cm_timer\n+ * @cm_node: connection's node\n+ * @sqbuf: buffer to send\n+ * @type: if it is send or close\n+ * @send_retrans: if rexmits to be done\n+ * @close_when_complete: is cm_node to be removed\n+ *\n+ * note - cm_node needs to be protected before calling this. Encase in:\n+ *\t\tirdma_rem_ref_cm_node(cm_core, cm_node);\n+ *\t\tirdma_schedule_cm_timer(...)\n+ *\t\tatomic_inc(&cm_node->ref_count);\n+ */\n+int irdma_schedule_cm_timer(struct irdma_cm_node *cm_node,\n+\t\t\t    struct irdma_puda_buf *sqbuf,\n+\t\t\t    enum irdma_timer_type type, int send_retrans,\n+\t\t\t    int close_when_complete)\n+{\n+\tstruct irdma_sc_vsi *vsi = &cm_node->iwdev->vsi;\n+\tstruct irdma_cm_core *cm_core = cm_node->cm_core;\n+\tstruct irdma_timer_entry *new_send;\n+\tu32 was_timer_set;\n+\tunsigned long flags;\n+\n+\tnew_send = kzalloc(sizeof(*new_send), GFP_ATOMIC);\n+\tif (!new_send) {\n+\t\tif (type != IRDMA_TIMER_TYPE_CLOSE)\n+\t\t\tirdma_free_sqbuf(vsi, (void *)sqbuf);\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tnew_send->retrycount = IRDMA_DEFAULT_RETRYS;\n+\tnew_send->retranscount = IRDMA_DEFAULT_RETRANS;\n+\tnew_send->sqbuf = sqbuf;\n+\tnew_send->timetosend = jiffies;\n+\tnew_send->type = type;\n+\tnew_send->send_retrans = send_retrans;\n+\tnew_send->close_when_complete = close_when_complete;\n+\n+\tif (type == IRDMA_TIMER_TYPE_CLOSE) {\n+\t\tnew_send->timetosend += (HZ / 10);\n+\t\tif (cm_node->close_entry) {\n+\t\t\tkfree(new_send);\n+\t\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t\t  \"CM: already close entry\\n\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tcm_node->close_entry = new_send;\n+\t} else { /* type == IRDMA_TIMER_TYPE_SEND */\n+\t\tspin_lock_irqsave(&cm_node->retrans_list_lock, flags);\n+\t\tcm_node->send_entry = new_send;\n+\t\tatomic_inc(&cm_node->ref_count);\n+\t\tspin_unlock_irqrestore(&cm_node->retrans_list_lock, flags);\n+\t\tnew_send->timetosend = jiffies + IRDMA_RETRY_TIMEOUT;\n+\n+\t\tatomic_inc(&sqbuf->refcount);\n+\t\tirdma_puda_send_buf(vsi->ilq, sqbuf);\n+\t\tif (!send_retrans) {\n+\t\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\t\tif (close_when_complete)\n+\t\t\t\tirdma_rem_ref_cm_node(cm_node);\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\n+\tspin_lock_irqsave(&cm_core->ht_lock, flags);\n+\twas_timer_set = timer_pending(&cm_core->tcp_timer);\n+\n+\tif (!was_timer_set) {\n+\t\tcm_core->tcp_timer.expires = new_send->timetosend;\n+\t\tadd_timer(&cm_core->tcp_timer);\n+\t}\n+\tspin_unlock_irqrestore(&cm_core->ht_lock, flags);\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * irdma_retrans_expired - Could not rexmit the packet\n+ * @cm_node: connection's node\n+ */\n+static void irdma_retrans_expired(struct irdma_cm_node *cm_node)\n+{\n+\tstruct iw_cm_id *cm_id = cm_node->cm_id;\n+\tenum irdma_cm_node_state state = cm_node->state;\n+\n+\tcm_node->state = IRDMA_CM_STATE_CLOSED;\n+\tswitch (state) {\n+\tcase IRDMA_CM_STATE_SYN_RCVD:\n+\tcase IRDMA_CM_STATE_CLOSING:\n+\t\tirdma_rem_ref_cm_node(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_FIN_WAIT1:\n+\tcase IRDMA_CM_STATE_LAST_ACK:\n+\t\tif (cm_node->cm_id)\n+\t\t\tcm_id->rem_ref(cm_id);\n+\t\tirdma_send_reset(cm_node);\n+\t\tbreak;\n+\tdefault:\n+\t\tatomic_inc(&cm_node->ref_count);\n+\t\tirdma_send_reset(cm_node);\n+\t\tirdma_create_event(cm_node, IRDMA_CM_EVENT_ABORTED);\n+\t\tbreak;\n+\t}\n+}\n+\n+/**\n+ * irdma_handle_close_entry - for handling retry/timeouts\n+ * @cm_node: connection's node\n+ * @rem_node: flag for remove cm_node\n+ */\n+static void irdma_handle_close_entry(struct irdma_cm_node *cm_node,\n+\t\t\t\t     u32 rem_node)\n+{\n+\tstruct irdma_timer_entry *close_entry = cm_node->close_entry;\n+\tstruct iw_cm_id *cm_id = cm_node->cm_id;\n+\tstruct irdma_qp *iwqp;\n+\tunsigned long flags;\n+\n+\tif (!close_entry)\n+\t\treturn;\n+\tiwqp = (struct irdma_qp *)close_entry->sqbuf;\n+\tif (iwqp) {\n+\t\tspin_lock_irqsave(&iwqp->lock, flags);\n+\t\tif (iwqp->cm_id) {\n+\t\t\tiwqp->hw_tcp_state = IRDMA_TCP_STATE_CLOSED;\n+\t\t\tiwqp->hw_iwarp_state = IRDMA_QP_STATE_ERROR;\n+\t\t\tiwqp->last_aeq = IRDMA_AE_RESET_SENT;\n+\t\t\tiwqp->ibqp_state = IB_QPS_ERR;\n+\t\t\tspin_unlock_irqrestore(&iwqp->lock, flags);\n+\t\t\tirdma_cm_disconn(iwqp);\n+\t\t} else {\n+\t\t\tspin_unlock_irqrestore(&iwqp->lock, flags);\n+\t\t}\n+\t} else if (rem_node) {\n+\t\t/* TIME_WAIT state */\n+\t\tirdma_rem_ref_cm_node(cm_node);\n+\t}\n+\tif (cm_id)\n+\t\tcm_id->rem_ref(cm_id);\n+\tkfree(close_entry);\n+\tcm_node->close_entry = NULL;\n+}\n+\n+/**\n+ * irdma_build_timer_list - Add cm_nodes to timer list\n+ * @timer_list: ptr to timer list\n+ * @hte: ptr to accelerated or non-accelerated list\n+ */\n+static void irdma_build_timer_list(struct list_head *timer_list,\n+\t\t\t\t   struct list_head *hte)\n+{\n+\tstruct irdma_cm_node *cm_node;\n+\tstruct list_head *list_core_temp, *list_node;\n+\n+\tlist_for_each_safe (list_node, list_core_temp, hte) {\n+\t\tcm_node = container_of(list_node, struct irdma_cm_node, list);\n+\t\tif (cm_node->close_entry || cm_node->send_entry) {\n+\t\t\tatomic_inc(&cm_node->ref_count);\n+\t\t\tlist_add(&cm_node->timer_entry, timer_list);\n+\t\t}\n+\t}\n+}\n+\n+/**\n+ * irdma_cm_timer_tick - system's timer expired callback\n+ * @t: Pointer to timer_list\n+ */\n+static void irdma_cm_timer_tick(struct timer_list *t)\n+{\n+\tunsigned long nexttimeout = jiffies + IRDMA_LONG_TIME;\n+\tstruct irdma_cm_node *cm_node;\n+\tstruct irdma_timer_entry *send_entry, *close_entry;\n+\tstruct list_head *list_core_temp;\n+\tstruct list_head *list_node;\n+\tstruct irdma_cm_core *cm_core = from_timer(cm_core, t, tcp_timer);\n+\tstruct irdma_sc_vsi *vsi;\n+\tu32 settimer = 0;\n+\tunsigned long timetosend;\n+\tunsigned long flags;\n+\tstruct list_head timer_list;\n+\n+\tINIT_LIST_HEAD(&timer_list);\n+\n+\tspin_lock_irqsave(&cm_core->ht_lock, flags);\n+\tirdma_build_timer_list(&timer_list, &cm_core->non_accelerated_list);\n+\tirdma_build_timer_list(&timer_list, &cm_core->accelerated_list);\n+\tspin_unlock_irqrestore(&cm_core->ht_lock, flags);\n+\n+\tlist_for_each_safe (list_node, list_core_temp, &timer_list) {\n+\t\tcm_node = container_of(list_node, struct irdma_cm_node,\n+\t\t\t\t       timer_entry);\n+\t\tclose_entry = cm_node->close_entry;\n+\n+\t\tif (close_entry) {\n+\t\t\tif (time_after(close_entry->timetosend, jiffies)) {\n+\t\t\t\tif (nexttimeout > close_entry->timetosend ||\n+\t\t\t\t    !settimer) {\n+\t\t\t\t\tnexttimeout = close_entry->timetosend;\n+\t\t\t\t\tsettimer = 1;\n+\t\t\t\t}\n+\t\t\t} else {\n+\t\t\t\tirdma_handle_close_entry(cm_node, 1);\n+\t\t\t}\n+\t\t}\n+\n+\t\tspin_lock_irqsave(&cm_node->retrans_list_lock, flags);\n+\n+\t\tsend_entry = cm_node->send_entry;\n+\t\tif (!send_entry)\n+\t\t\tgoto done;\n+\t\tif (time_after(send_entry->timetosend, jiffies)) {\n+\t\t\tif (cm_node->state != IRDMA_CM_STATE_OFFLOADED) {\n+\t\t\t\tif (nexttimeout > send_entry->timetosend ||\n+\t\t\t\t    !settimer) {\n+\t\t\t\t\tnexttimeout = send_entry->timetosend;\n+\t\t\t\t\tsettimer = 1;\n+\t\t\t\t}\n+\t\t\t} else {\n+\t\t\t\tirdma_free_retrans_entry(cm_node);\n+\t\t\t}\n+\t\t\tgoto done;\n+\t\t}\n+\n+\t\tif (cm_node->state == IRDMA_CM_STATE_OFFLOADED ||\n+\t\t    cm_node->state == IRDMA_CM_STATE_CLOSED) {\n+\t\t\tirdma_free_retrans_entry(cm_node);\n+\t\t\tgoto done;\n+\t\t}\n+\n+\t\tif (!send_entry->retranscount || !send_entry->retrycount) {\n+\t\t\tirdma_free_retrans_entry(cm_node);\n+\n+\t\t\tspin_unlock_irqrestore(&cm_node->retrans_list_lock,\n+\t\t\t\t\t       flags);\n+\t\t\tirdma_retrans_expired(cm_node);\n+\t\t\tcm_node->state = IRDMA_CM_STATE_CLOSED;\n+\t\t\tspin_lock_irqsave(&cm_node->retrans_list_lock, flags);\n+\t\t\tgoto done;\n+\t\t}\n+\t\tspin_unlock_irqrestore(&cm_node->retrans_list_lock, flags);\n+\n+\t\tvsi = &cm_node->iwdev->vsi;\n+\t\tif (!cm_node->ack_rcvd) {\n+\t\t\tatomic_inc(&send_entry->sqbuf->refcount);\n+\t\t\tirdma_puda_send_buf(vsi->ilq, send_entry->sqbuf);\n+\t\t\tcm_node->cm_core->stats_pkt_retrans++;\n+\t\t}\n+\n+\t\tspin_lock_irqsave(&cm_node->retrans_list_lock, flags);\n+\t\tif (send_entry->send_retrans) {\n+\t\t\tsend_entry->retranscount--;\n+\t\t\ttimetosend = (IRDMA_RETRY_TIMEOUT <<\n+\t\t\t\t      (IRDMA_DEFAULT_RETRANS -\n+\t\t\t\t       send_entry->retranscount));\n+\n+\t\t\tsend_entry->timetosend = jiffies +\n+\t\t\t    min(timetosend, IRDMA_MAX_TIMEOUT);\n+\t\t\tif (nexttimeout > send_entry->timetosend || !settimer) {\n+\t\t\t\tnexttimeout = send_entry->timetosend;\n+\t\t\t\tsettimer = 1;\n+\t\t\t}\n+\t\t} else {\n+\t\t\tint close_when_complete;\n+\n+\t\t\tclose_when_complete = send_entry->close_when_complete;\n+\t\t\tirdma_free_retrans_entry(cm_node);\n+\t\t\tif (close_when_complete)\n+\t\t\t\tirdma_rem_ref_cm_node(cm_node);\n+\t\t}\n+done:\n+\t\tspin_unlock_irqrestore(&cm_node->retrans_list_lock, flags);\n+\t\tirdma_rem_ref_cm_node(cm_node);\n+\t}\n+\n+\tif (settimer) {\n+\t\tspin_lock_irqsave(&cm_core->ht_lock, flags);\n+\t\tif (!timer_pending(&cm_core->tcp_timer)) {\n+\t\t\tcm_core->tcp_timer.expires = nexttimeout;\n+\t\t\tadd_timer(&cm_core->tcp_timer);\n+\t\t}\n+\t\tspin_unlock_irqrestore(&cm_core->ht_lock, flags);\n+\t}\n+}\n+\n+/**\n+ * irdma_send_syn - send SYN packet\n+ * @cm_node: connection's node\n+ * @sendack: flag to set ACK bit or not\n+ */\n+int irdma_send_syn(struct irdma_cm_node *cm_node, u32 sendack)\n+{\n+\tstruct irdma_puda_buf *sqbuf;\n+\tint flags = SET_SYN;\n+\tchar optionsbuf[sizeof(struct option_mss) +\n+\t\t\tsizeof(struct option_windowscale) +\n+\t\t\tsizeof(struct option_base) + TCP_OPTIONS_PADDING];\n+\tstruct irdma_kmem_info opts;\n+\tint optionssize = 0;\n+\t/* Sending MSS option */\n+\tunion all_known_options *options;\n+\n+\topts.addr = optionsbuf;\n+\tif (!cm_node)\n+\t\treturn -EINVAL;\n+\n+\toptions = (union all_known_options *)&optionsbuf[optionssize];\n+\toptions->mss.optionnum = OPTION_NUM_MSS;\n+\toptions->mss.len = sizeof(struct option_mss);\n+\toptions->mss.mss = htons(cm_node->tcp_cntxt.mss);\n+\toptionssize += sizeof(struct option_mss);\n+\n+\toptions = (union all_known_options *)&optionsbuf[optionssize];\n+\toptions->windowscale.optionnum = OPTION_NUM_WINDOW_SCALE;\n+\toptions->windowscale.len = sizeof(struct option_windowscale);\n+\toptions->windowscale.shiftcount = cm_node->tcp_cntxt.rcv_wscale;\n+\toptionssize += sizeof(struct option_windowscale);\n+\toptions = (union all_known_options *)&optionsbuf[optionssize];\n+\toptions->eol = OPTION_NUM_EOL;\n+\toptionssize += 1;\n+\n+\tif (sendack)\n+\t\tflags |= SET_ACK;\n+\n+\topts.size = optionssize;\n+\n+\tsqbuf = cm_node->cm_core->form_cm_frame(cm_node, &opts, NULL, NULL,\n+\t\t\t\t\t\tflags);\n+\tif (!sqbuf)\n+\t\treturn -ENOMEM;\n+\n+\treturn irdma_schedule_cm_timer(cm_node, sqbuf, IRDMA_TIMER_TYPE_SEND, 1,\n+\t\t\t\t       0);\n+}\n+\n+/**\n+ * irdma_send_ack - Send ACK packet\n+ * @cm_node: connection's node\n+ */\n+void irdma_send_ack(struct irdma_cm_node *cm_node)\n+{\n+\tstruct irdma_puda_buf *sqbuf;\n+\tstruct irdma_sc_vsi *vsi = &cm_node->iwdev->vsi;\n+\n+\tsqbuf = cm_node->cm_core->form_cm_frame(cm_node, NULL, NULL, NULL,\n+\t\t\t\t\t\tSET_ACK);\n+\tif (sqbuf)\n+\t\tirdma_puda_send_buf(vsi->ilq, sqbuf);\n+}\n+\n+/**\n+ * irdma_send_fin - Send FIN pkt\n+ * @cm_node: connection's node\n+ */\n+static int irdma_send_fin(struct irdma_cm_node *cm_node)\n+{\n+\tstruct irdma_puda_buf *sqbuf;\n+\n+\tsqbuf = cm_node->cm_core->form_cm_frame(cm_node, NULL, NULL, NULL,\n+\t\t\t\t\t\tSET_ACK | SET_FIN);\n+\tif (!sqbuf)\n+\t\treturn -1;\n+\n+\treturn irdma_schedule_cm_timer(cm_node, sqbuf, IRDMA_TIMER_TYPE_SEND, 1,\n+\t\t\t\t       0);\n+}\n+\n+/**\n+ * irdma_find_node - find a cm node that matches the reference\n+ * cm node\n+ * @cm_core: cm's core\n+ * @rem_port: remote tcp port num\n+ * @rem_addr: remote ip addr\n+ * @loc_port: local tcp port num\n+ * @loc_addr: loc ip addr\n+ * @add_refcnt: flag to increment refcount of cm_node\n+ * @accelerated_list: flag for accelerated vs non-accelerated list to search\n+ */\n+struct irdma_cm_node *irdma_find_node(struct irdma_cm_core *cm_core,\n+\t\t\t\t      u16 rem_port, u32 *rem_addr, u16 loc_port,\n+\t\t\t\t      u32 *loc_addr, bool add_refcnt,\n+\t\t\t\t      bool accelerated_list)\n+{\n+\tstruct list_head *hte;\n+\tstruct irdma_cm_node *cm_node;\n+\tunsigned long flags;\n+\n+\thte = accelerated_list ? &cm_core->accelerated_list :\n+\t\t\t\t &cm_core->non_accelerated_list;\n+\n+\tspin_lock_irqsave(&cm_core->ht_lock, flags);\n+\tlist_for_each_entry (cm_node, hte, list) {\n+\t\tif (!memcmp(cm_node->loc_addr, loc_addr, sizeof(cm_node->loc_addr)) &&\n+\t\t    cm_node->loc_port == loc_port &&\n+\t\t    !memcmp(cm_node->rem_addr, rem_addr, sizeof(cm_node->rem_addr)) &&\n+\t\t    cm_node->rem_port == rem_port) {\n+\t\t\tif (add_refcnt)\n+\t\t\t\tatomic_inc(&cm_node->ref_count);\n+\t\t\tspin_unlock_irqrestore(&cm_core->ht_lock, flags);\n+\t\t\ttrace_irdma_find_node(cm_node, 0, NULL);\n+\t\t\treturn cm_node;\n+\t\t}\n+\t}\n+\tspin_unlock_irqrestore(&cm_core->ht_lock, flags);\n+\n+\t/* no owner node */\n+\treturn NULL;\n+}\n+\n+/**\n+ * irdma_find_listener - find a cm node listening on this addr-port pair\n+ * @cm_core: cm's core\n+ * @dst_addr: listener ip addr\n+ * @dst_port: listener tcp port num\n+ * @vlan_id: virtual LAN ID\n+ * @listener_state: state to match with listen node's\n+ */\n+static struct irdma_cm_listener *\n+irdma_find_listener(struct irdma_cm_core *cm_core, u32 *dst_addr, u16 dst_port,\n+\t\t    u16 vlan_id, enum irdma_cm_listener_state listener_state)\n+{\n+\tstruct irdma_cm_listener *listen_node;\n+\tstatic const u32 ip_zero[4] = { 0, 0, 0, 0 };\n+\tu32 listen_addr[4];\n+\tu16 listen_port;\n+\tunsigned long flags;\n+\n+\t/* walk list and find cm_node associated with this session ID */\n+\tspin_lock_irqsave(&cm_core->listen_list_lock, flags);\n+\tlist_for_each_entry (listen_node, &cm_core->listen_nodes, list) {\n+\t\tmemcpy(listen_addr, listen_node->loc_addr, sizeof(listen_addr));\n+\t\tlisten_port = listen_node->loc_port;\n+\t\t/* compare node pair, return node handle if a match */\n+\t\tif ((!memcmp(listen_addr, dst_addr, sizeof(listen_addr)) ||\n+\t\t     !memcmp(listen_addr, ip_zero, sizeof(listen_addr))) &&\n+\t\t    listen_port == dst_port &&\n+\t\t    vlan_id == listen_node->vlan_id &&\n+\t\t    (listener_state & listen_node->listener_state)) {\n+\t\t\tatomic_inc(&listen_node->ref_count);\n+\t\t\tspin_unlock_irqrestore(&cm_core->listen_list_lock,\n+\t\t\t\t\t       flags);\n+\t\t\ttrace_irdma_find_listener(listen_node);\n+\t\t\treturn listen_node;\n+\t\t}\n+\t}\n+\tspin_unlock_irqrestore(&cm_core->listen_list_lock, flags);\n+\n+\treturn NULL;\n+}\n+\n+/**\n+ * irdma_add_hte_node - add a cm node to the hash table\n+ * @cm_core: cm's core\n+ * @cm_node: connection's node\n+ */\n+static void irdma_add_hte_node(struct irdma_cm_core *cm_core,\n+\t\t\t       struct irdma_cm_node *cm_node)\n+{\n+\tunsigned long flags;\n+\n+\tif (!cm_node || !cm_core)\n+\t\treturn;\n+\n+\tspin_lock_irqsave(&cm_core->ht_lock, flags);\n+\tlist_add_tail(&cm_node->list, &cm_core->non_accelerated_list);\n+\tspin_unlock_irqrestore(&cm_core->ht_lock, flags);\n+}\n+\n+/**\n+ * irdma_find_port - find port that matches reference port\n+ * @hte: ptr to accelerated or non-accelerated list\n+ * @port: port number\n+ */\n+static bool irdma_find_port(struct list_head *hte, u16 port)\n+{\n+\tstruct irdma_cm_node *cm_node;\n+\n+\tlist_for_each_entry (cm_node, hte, list) {\n+\t\tif (cm_node->loc_port == port)\n+\t\t\treturn true;\n+\t}\n+\n+\treturn false;\n+}\n+\n+/**\n+ * irdma_port_in_use - determine if port is in use\n+ * @cm_core: cm's core\n+ * @port: port number\n+ */\n+bool irdma_port_in_use(struct irdma_cm_core *cm_core, u16 port)\n+{\n+\tstruct irdma_cm_listener *listen_node;\n+\tunsigned long flags;\n+\n+\tspin_lock_irqsave(&cm_core->ht_lock, flags);\n+\tif (irdma_find_port(&cm_core->accelerated_list, port) ||\n+\t    irdma_find_port(&cm_core->non_accelerated_list, port)) {\n+\t\tspin_unlock_irqrestore(&cm_core->ht_lock, flags);\n+\t\treturn true;\n+\t}\n+\tspin_unlock_irqrestore(&cm_core->ht_lock, flags);\n+\n+\tspin_lock_irqsave(&cm_core->listen_list_lock, flags);\n+\tlist_for_each_entry (listen_node, &cm_core->listen_nodes, list) {\n+\t\tif (listen_node->loc_port == port) {\n+\t\t\tspin_unlock_irqrestore(&cm_core->listen_list_lock, flags);\n+\t\t\treturn true;\n+\t\t}\n+\t}\n+\tspin_unlock_irqrestore(&cm_core->listen_list_lock, flags);\n+\n+\treturn false;\n+}\n+\n+/**\n+ * irdma_del_multiple_qhash - Remove qhash and child listens\n+ * @iwdev: iWarp device\n+ * @cm_info: CM info for parent listen node\n+ * @cm_parent_listen_node: The parent listen node\n+ */\n+static enum irdma_status_code\n+irdma_del_multiple_qhash(struct irdma_device *iwdev,\n+\t\t\t struct irdma_cm_info *cm_info,\n+\t\t\t struct irdma_cm_listener *cm_parent_listen_node)\n+{\n+\tstruct irdma_cm_listener *child_listen_node;\n+\tenum irdma_status_code ret = IRDMA_ERR_CFG;\n+\tstruct list_head *pos, *tpos;\n+\tunsigned long flags;\n+\n+\tspin_lock_irqsave(&iwdev->cm_core.listen_list_lock, flags);\n+\tlist_for_each_safe (pos, tpos,\n+\t\t\t    &cm_parent_listen_node->child_listen_list) {\n+\t\tchild_listen_node = list_entry(pos, struct irdma_cm_listener,\n+\t\t\t\t\t       child_listen_list);\n+\t\tif (child_listen_node->ipv4)\n+\t\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t\t  \"CM: removing child listen for IP=%pI4, port=%d, vlan=%d\\n\",\n+\t\t\t\t  child_listen_node->loc_addr,\n+\t\t\t\t  child_listen_node->loc_port,\n+\t\t\t\t  child_listen_node->vlan_id);\n+\t\telse\n+\t\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t\t  \"CM: removing child listen for IP=%pI6, port=%d, vlan=%d\\n\",\n+\t\t\t\t  child_listen_node->loc_addr,\n+\t\t\t\t  child_listen_node->loc_port,\n+\t\t\t\t  child_listen_node->vlan_id);\n+\t\ttrace_irdma_del_multiple_qhash(child_listen_node);\n+\t\tlist_del(pos);\n+\t\tmemcpy(cm_info->loc_addr, child_listen_node->loc_addr,\n+\t\t       sizeof(cm_info->loc_addr));\n+\t\tcm_info->vlan_id = child_listen_node->vlan_id;\n+\t\tif (child_listen_node->qhash_set) {\n+\t\t\tret = irdma_manage_qhash(iwdev, cm_info,\n+\t\t\t\t\t\t IRDMA_QHASH_TYPE_TCP_SYN,\n+\t\t\t\t\t\t IRDMA_QHASH_MANAGE_TYPE_DELETE,\n+\t\t\t\t\t\t NULL, false);\n+\t\t\tchild_listen_node->qhash_set = false;\n+\t\t} else {\n+\t\t\tret = 0;\n+\t\t}\n+\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t  \"CM: Child listen node freed = %p\\n\",\n+\t\t\t  child_listen_node);\n+\t\tkfree(child_listen_node);\n+\t\tcm_parent_listen_node->cm_core->stats_listen_nodes_destroyed++;\n+\t}\n+\tspin_unlock_irqrestore(&iwdev->cm_core.listen_list_lock, flags);\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * irdma_netdev_vlan_ipv6 - Gets the netdev and mac\n+ * @addr: local IPv6 address\n+ * @vlan_id: vlan id for the given IPv6 address\n+ * @mac: mac address for the given IPv6 address\n+ *\n+ * Returns the net_device of the IPv6 address and also sets the\n+ * vlan id and mac for that address.\n+ */\n+struct net_device *irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac)\n+{\n+\tstruct net_device *ip_dev = NULL;\n+\tstruct in6_addr laddr6;\n+\n+\tif (!IS_ENABLED(CONFIG_IPV6))\n+\t\treturn NULL;\n+\n+\tirdma_copy_ip_htonl(laddr6.in6_u.u6_addr32, addr);\n+\tif (vlan_id)\n+\t\t*vlan_id = 0xFFFF;\t/* Match rdma_vlan_dev_vlan_id() */\n+\tif (mac)\n+\t\teth_zero_addr(mac);\n+\n+\trcu_read_lock();\n+\tfor_each_netdev_rcu (&init_net, ip_dev) {\n+\t\tif (ipv6_chk_addr(&init_net, &laddr6, ip_dev, 1)) {\n+\t\t\tif (vlan_id)\n+\t\t\t\t*vlan_id = rdma_vlan_dev_vlan_id(ip_dev);\n+\t\t\tif (ip_dev->dev_addr && mac)\n+\t\t\t\tether_addr_copy(mac, ip_dev->dev_addr);\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\trcu_read_unlock();\n+\n+\treturn ip_dev;\n+}\n+\n+/**\n+ * irdma_get_vlan_ipv4 - Returns the vlan_id for IPv4 address\n+ * @addr: local IPv4 address\n+ */\n+u16 irdma_get_vlan_ipv4(u32 *addr)\n+{\n+\tstruct net_device *netdev;\n+\tu16 vlan_id = 0xFFFF;\n+\n+\tnetdev = ip_dev_find(&init_net, htonl(addr[0]));\n+\tif (netdev) {\n+\t\tvlan_id = rdma_vlan_dev_vlan_id(netdev);\n+\t\tdev_put(netdev);\n+\t}\n+\n+\treturn vlan_id;\n+}\n+\n+/**\n+ * irdma_add_mqh_6 - Adds multiple qhashes for IPv6\n+ * @iwdev: iWarp device\n+ * @cm_info: CM info for parent listen node\n+ * @cm_parent_listen_node: The parent listen node\n+ *\n+ * Adds a qhash and a child listen node for every IPv6 address\n+ * on the adapter and adds the associated qhash filter\n+ */\n+static enum irdma_status_code\n+irdma_add_mqh_6(struct irdma_device *iwdev, struct irdma_cm_info *cm_info,\n+\t\tstruct irdma_cm_listener *cm_parent_listen_node)\n+{\n+\tstruct net_device *ip_dev;\n+\tstruct inet6_dev *idev;\n+\tstruct inet6_ifaddr *ifp, *tmp;\n+\tenum irdma_status_code ret = 0;\n+\tstruct irdma_cm_listener *child_listen_node;\n+\tunsigned long flags;\n+\n+\trtnl_lock();\n+\tfor_each_netdev (&init_net, ip_dev) {\n+\t\tif (!(ip_dev->flags & IFF_UP))\n+\t\t\tcontinue;\n+\n+\t\tif (((rdma_vlan_dev_vlan_id(ip_dev) >= VLAN_N_VID) ||\n+\t\t     (rdma_vlan_dev_real_dev(ip_dev) != iwdev->netdev)) &&\n+\t\t    ip_dev != iwdev->netdev)\n+\t\t\tcontinue;\n+\n+\t\tidev = __in6_dev_get(ip_dev);\n+\t\tif (!idev) {\n+\t\t\tibdev_dbg(to_ibdev(iwdev), \"CM: idev == NULL\\n\");\n+\t\t\tbreak;\n+\t\t}\n+\t\tlist_for_each_entry_safe (ifp, tmp, &idev->addr_list, if_list) {\n+\t\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t\t  \"CM: IP=%pI6, vlan_id=%d, MAC=%pM\\n\",\n+\t\t\t\t  &ifp->addr, rdma_vlan_dev_vlan_id(ip_dev),\n+\t\t\t\t  ip_dev->dev_addr);\n+\t\t\tchild_listen_node = kzalloc(sizeof(*child_listen_node), GFP_KERNEL);\n+\t\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t\t  \"CM: Allocating child listener %p\\n\",\n+\t\t\t\t  child_listen_node);\n+\t\t\tif (!child_listen_node) {\n+\t\t\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t\t\t  \"CM: listener memory allocation\\n\");\n+\t\t\t\tret = IRDMA_ERR_NO_MEMORY;\n+\t\t\t\tgoto exit;\n+\t\t\t}\n+\n+\t\t\tcm_info->vlan_id = rdma_vlan_dev_vlan_id(ip_dev);\n+\t\t\tcm_parent_listen_node->vlan_id = cm_info->vlan_id;\n+\t\t\tmemcpy(child_listen_node, cm_parent_listen_node,\n+\t\t\t       sizeof(*child_listen_node));\n+\t\t\tirdma_copy_ip_ntohl(child_listen_node->loc_addr,\n+\t\t\t\t\t    ifp->addr.in6_u.u6_addr32);\n+\t\t\tmemcpy(cm_info->loc_addr, child_listen_node->loc_addr,\n+\t\t\t       sizeof(cm_info->loc_addr));\n+\t\t\tret = irdma_manage_qhash(iwdev, cm_info,\n+\t\t\t\t\t\t IRDMA_QHASH_TYPE_TCP_SYN,\n+\t\t\t\t\t\t IRDMA_QHASH_MANAGE_TYPE_ADD,\n+\t\t\t\t\t\t NULL, true);\n+\t\t\tif (ret) {\n+\t\t\t\tkfree(child_listen_node);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\ttrace_irdma_add_mqh_6(iwdev, child_listen_node,\n+\t\t\t\t\t      ip_dev->dev_addr);\n+\n+\t\t\tchild_listen_node->qhash_set = true;\n+\t\t\tspin_lock_irqsave(&iwdev->cm_core.listen_list_lock, flags);\n+\t\t\tlist_add(&child_listen_node->child_listen_list,\n+\t\t\t\t &cm_parent_listen_node->child_listen_list);\n+\t\t\tspin_unlock_irqrestore(&iwdev->cm_core.listen_list_lock, flags);\n+\t\t\tcm_parent_listen_node->cm_core->stats_listen_nodes_created++;\n+\t\t}\n+\t}\n+exit:\n+\trtnl_unlock();\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * irdma_add_mqh_4 - Adds multiple qhashes for IPv4\n+ * @iwdev: iWarp device\n+ * @cm_info: CM info for parent listen node\n+ * @cm_parent_listen_node: The parent listen node\n+ *\n+ * Adds a qhash and a child listen node for every IPv4 address\n+ * on the adapter and adds the associated qhash filter\n+ */\n+static enum irdma_status_code\n+irdma_add_mqh_4(struct irdma_device *iwdev, struct irdma_cm_info *cm_info,\n+\t\tstruct irdma_cm_listener *cm_parent_listen_node)\n+{\n+\tstruct net_device *dev;\n+\tstruct in_device *idev;\n+\tstruct irdma_cm_listener *child_listen_node;\n+\tenum irdma_status_code ret = 0;\n+\tunsigned long flags;\n+\tconst struct in_ifaddr *ifa;\n+\n+\trtnl_lock();\n+\tfor_each_netdev (&init_net, dev) {\n+\t\tif (!(dev->flags & IFF_UP))\n+\t\t\tcontinue;\n+\n+\t\tif (((rdma_vlan_dev_vlan_id(dev) >= VLAN_N_VID) ||\n+\t\t     (rdma_vlan_dev_real_dev(dev) != iwdev->netdev)) &&\n+\t\t    dev != iwdev->netdev)\n+\t\t\tcontinue;\n+\n+\t\tidev = in_dev_get(dev);\n+\t\tin_dev_for_each_ifa_rtnl(ifa, idev) {\n+\t\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t\t  \"CM: Allocating child CM Listener forIP=%pI4, vlan_id=%d, MAC=%pM\\n\",\n+\t\t\t\t  &ifa->ifa_address,\n+\t\t\t\t  rdma_vlan_dev_vlan_id(dev), dev->dev_addr);\n+\t\t\tchild_listen_node = kzalloc(sizeof(*child_listen_node), GFP_KERNEL);\n+\t\t\tcm_parent_listen_node->cm_core->stats_listen_nodes_created++;\n+\t\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t\t  \"CM: Allocating child listener %p\\n\",\n+\t\t\t\t  child_listen_node);\n+\t\t\tif (!child_listen_node) {\n+\t\t\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t\t\t  \"CM: listener memory allocation\\n\");\n+\t\t\t\tin_dev_put(idev);\n+\t\t\t\tret = IRDMA_ERR_NO_MEMORY;\n+\t\t\t\tgoto exit;\n+\t\t\t}\n+\n+\t\t\tcm_info->vlan_id = rdma_vlan_dev_vlan_id(dev);\n+\t\t\tcm_parent_listen_node->vlan_id = cm_info->vlan_id;\n+\t\t\tmemcpy(child_listen_node, cm_parent_listen_node,\n+\t\t\t       sizeof(*child_listen_node));\n+\t\t\tchild_listen_node->loc_addr[0] =\n+\t\t\t\tntohl(ifa->ifa_address);\n+\t\t\tmemcpy(cm_info->loc_addr, child_listen_node->loc_addr,\n+\t\t\t       sizeof(cm_info->loc_addr));\n+\t\t\tret = irdma_manage_qhash(iwdev, cm_info,\n+\t\t\t\t\t\t IRDMA_QHASH_TYPE_TCP_SYN,\n+\t\t\t\t\t\t IRDMA_QHASH_MANAGE_TYPE_ADD,\n+\t\t\t\t\t\t NULL, true);\n+\t\t\tif (ret) {\n+\t\t\t\tkfree(child_listen_node);\n+\t\t\t\tcm_parent_listen_node->cm_core\n+\t\t\t\t\t->stats_listen_nodes_created--;\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\ttrace_irdma_add_mqh_4(iwdev, child_listen_node,\n+\t\t\t\t\t      dev->dev_addr);\n+\n+\t\t\tchild_listen_node->qhash_set = true;\n+\t\t\tspin_lock_irqsave(&iwdev->cm_core.listen_list_lock,\n+\t\t\t\t\t  flags);\n+\t\t\tlist_add(&child_listen_node->child_listen_list,\n+\t\t\t\t &cm_parent_listen_node->child_listen_list);\n+\t\t\tspin_unlock_irqrestore(&iwdev->cm_core.listen_list_lock, flags);\n+\t\t}\n+\t\tin_dev_put(idev);\n+\t}\n+exit:\n+\trtnl_unlock();\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * irdma_dec_refcnt_listen - delete listener and associated cm nodes\n+ * @cm_core: cm's core\n+ * @listener: pointer to listener node\n+ * @free_hanging_nodes: to free associated cm_nodes\n+ * @apbvt_del: flag to delete the apbvt\n+ */\n+static int irdma_dec_refcnt_listen(struct irdma_cm_core *cm_core,\n+\t\t\t\t   struct irdma_cm_listener *listener,\n+\t\t\t\t   int free_hanging_nodes, bool apbvt_del)\n+{\n+\tint err;\n+\tstruct list_head *list_pos;\n+\tstruct list_head *list_temp;\n+\tstruct irdma_cm_node *cm_node;\n+\tstruct list_head reset_list;\n+\tstruct irdma_cm_info nfo;\n+\tenum irdma_cm_node_state old_state;\n+\tunsigned long flags;\n+\n+\ttrace_irdma_dec_refcnt_listen(listener, __builtin_return_address(0));\n+\t/* free non-accelerated child nodes for this listener */\n+\tINIT_LIST_HEAD(&reset_list);\n+\tif (free_hanging_nodes) {\n+\t\tspin_lock_irqsave(&cm_core->ht_lock, flags);\n+\t\tlist_for_each_safe (list_pos, list_temp,\n+\t\t\t\t    &cm_core->non_accelerated_list) {\n+\t\t\tcm_node = container_of(list_pos, struct irdma_cm_node,\n+\t\t\t\t\t       list);\n+\t\t\tif (cm_node->listener == listener &&\n+\t\t\t    !cm_node->accelerated) {\n+\t\t\t\tatomic_inc(&cm_node->ref_count);\n+\t\t\t\tlist_add(&cm_node->reset_entry, &reset_list);\n+\t\t\t}\n+\t\t}\n+\t\tspin_unlock_irqrestore(&cm_core->ht_lock, flags);\n+\t}\n+\n+\tlist_for_each_safe (list_pos, list_temp, &reset_list) {\n+\t\tcm_node = container_of(list_pos, struct irdma_cm_node,\n+\t\t\t\t       reset_entry);\n+\t\tif (cm_node->state >= IRDMA_CM_STATE_FIN_WAIT1) {\n+\t\t\tirdma_rem_ref_cm_node(cm_node);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\terr = irdma_send_reset(cm_node);\n+\t\tif (err) {\n+\t\t\tcm_node->state = IRDMA_CM_STATE_CLOSED;\n+\t\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t\t  \"CM: send reset failed\\n\");\n+\t\t} else {\n+\t\t\told_state = cm_node->state;\n+\t\t\tcm_node->state = IRDMA_CM_STATE_LISTENER_DESTROYED;\n+\t\t\tif (old_state != IRDMA_CM_STATE_MPAREQ_RCVD)\n+\t\t\t\tirdma_rem_ref_cm_node(cm_node);\n+\t\t}\n+\t}\n+\n+\tif (!atomic_dec_return(&listener->ref_count)) {\n+\t\tspin_lock_irqsave(&cm_core->listen_list_lock, flags);\n+\t\tlist_del(&listener->list);\n+\t\tspin_unlock_irqrestore(&cm_core->listen_list_lock, flags);\n+\n+\t\tif (listener->iwdev) {\n+\t\t\tif (apbvt_del)\n+\t\t\t\tirdma_manage_apbvt(listener->iwdev,\n+\t\t\t\t\t\t   listener->loc_port,\n+\t\t\t\t\t\t   IRDMA_MANAGE_APBVT_DEL);\n+\t\t\tmemcpy(nfo.loc_addr, listener->loc_addr,\n+\t\t\t       sizeof(nfo.loc_addr));\n+\t\t\tnfo.loc_port = listener->loc_port;\n+\t\t\tnfo.ipv4 = listener->ipv4;\n+\t\t\tnfo.vlan_id = listener->vlan_id;\n+\t\t\tnfo.user_pri = listener->user_pri;\n+\t\t\tnfo.qh_qpid = listener->iwdev->vsi.ilq->qp_id;\n+\n+\t\t\tif (!list_empty(&listener->child_listen_list)) {\n+\t\t\t\tirdma_del_multiple_qhash(listener->iwdev, &nfo,\n+\t\t\t\t\t\t\t listener);\n+\t\t\t} else {\n+\t\t\t\tif (listener->qhash_set)\n+\t\t\t\t\tirdma_manage_qhash(listener->iwdev,\n+\t\t\t\t\t\t\t   &nfo,\n+\t\t\t\t\t\t\t   IRDMA_QHASH_TYPE_TCP_SYN,\n+\t\t\t\t\t\t\t   IRDMA_QHASH_MANAGE_TYPE_DELETE,\n+\t\t\t\t\t\t\t   NULL, false);\n+\t\t\t}\n+\t\t}\n+\n+\t\tcm_core->stats_listen_destroyed++;\n+\t\tkfree(listener);\n+\t\tcm_core->stats_listen_nodes_destroyed++;\n+\t\tlistener = NULL;\n+\t\treturn 0;\n+\t}\n+\n+\treturn -EINVAL;\n+}\n+\n+/**\n+ * irdma_cm_del_listen - delete a listener\n+ * @cm_core: cm's core\n+ * @listener: passive connection's listener\n+ * @apbvt_del: flag to delete apbvt\n+ */\n+static int irdma_cm_del_listen(struct irdma_cm_core *cm_core,\n+\t\t\t       struct irdma_cm_listener *listener,\n+\t\t\t       bool apbvt_del)\n+{\n+\tlistener->listener_state = IRDMA_CM_LISTENER_PASSIVE_STATE;\n+\tlistener->cm_id = NULL;\n+\n+\treturn irdma_dec_refcnt_listen(cm_core, listener, 1, apbvt_del);\n+}\n+\n+/**\n+ * irdma_addr_resolve_neigh - resolve neighbor address\n+ * @iwdev: iwarp device structure\n+ * @src_ip: local ip address\n+ * @dst_ip: remote ip address\n+ * @arpindex: if there is an arp entry\n+ */\n+static int irdma_addr_resolve_neigh(struct irdma_device *iwdev, u32 src_ip,\n+\t\t\t\t    u32 dst_ip, int arpindex)\n+{\n+\tstruct rtable *rt;\n+\tstruct neighbour *neigh;\n+\tint rc = arpindex;\n+\t__be32 dst_ipaddr = htonl(dst_ip);\n+\t__be32 src_ipaddr = htonl(src_ip);\n+\n+\trt = ip_route_output(&init_net, dst_ipaddr, src_ipaddr, 0, 0);\n+\tif (IS_ERR(rt)) {\n+\t\tibdev_dbg(to_ibdev(iwdev), \"CM: ip_route_output fail\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tneigh = dst_neigh_lookup(&rt->dst, &dst_ipaddr);\n+\n+\trcu_read_lock();\n+\tif (!neigh)\n+\t\tgoto exit;\n+\n+\tif (neigh->nud_state & NUD_VALID)\n+\t\trc = irdma_add_arp(iwdev->rf, &dst_ip, true, neigh->ha);\n+\telse\n+\t\tneigh_event_send(neigh, NULL);\n+exit:\n+\trcu_read_unlock();\n+\n+\tif (neigh)\n+\t\tneigh_release(neigh);\n+\n+\tip_rt_put(rt);\n+\n+\treturn rc;\n+}\n+\n+/**\n+ * irdma_get_dst_ipv6 - get destination cache entry via ipv6 lookup\n+ * @src_addr: local ipv6 sock address\n+ * @dst_addr: destination ipv6 sock address\n+ */\n+static struct dst_entry *irdma_get_dst_ipv6(struct sockaddr_in6 *src_addr,\n+\t\t\t\t\t    struct sockaddr_in6 *dst_addr)\n+{\n+\tstruct dst_entry *dst = NULL;\n+\n+\tif ((IS_ENABLED(CONFIG_IPV6))) {\n+\t\tstruct flowi6 fl6 = {};\n+\n+\t\tfl6.daddr = dst_addr->sin6_addr;\n+\t\tfl6.saddr = src_addr->sin6_addr;\n+\t\tif (ipv6_addr_type(&fl6.daddr) & IPV6_ADDR_LINKLOCAL)\n+\t\t\tfl6.flowi6_oif = dst_addr->sin6_scope_id;\n+\n+\t\tdst = ip6_route_output(&init_net, NULL, &fl6);\n+\t}\n+\n+\treturn dst;\n+}\n+\n+/**\n+ * irdma_addr_resolve_neigh_ipv6 - resolve neighbor ipv6 address\n+ * @iwdev: iwarp device structure\n+ * @src: local ip address\n+ * @dest: remote ip address\n+ * @arpindex: if there is an arp entry\n+ */\n+static int irdma_addr_resolve_neigh_ipv6(struct irdma_device *iwdev, u32 *src,\n+\t\t\t\t\t u32 *dest, int arpindex)\n+{\n+\tstruct neighbour *neigh;\n+\tint rc = arpindex;\n+\tstruct dst_entry *dst;\n+\tstruct sockaddr_in6 dst_addr = {};\n+\tstruct sockaddr_in6 src_addr = {};\n+\n+\tdst_addr.sin6_family = AF_INET6;\n+\tirdma_copy_ip_htonl(dst_addr.sin6_addr.in6_u.u6_addr32, dest);\n+\tsrc_addr.sin6_family = AF_INET6;\n+\tirdma_copy_ip_htonl(src_addr.sin6_addr.in6_u.u6_addr32, src);\n+\tdst = irdma_get_dst_ipv6(&src_addr, &dst_addr);\n+\tif (!dst || dst->error) {\n+\t\tif (dst) {\n+\t\t\tdst_release(dst);\n+\t\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t\t  \"CM: ip6_route_output returned dst->error = %d\\n\",\n+\t\t\t\t  dst->error);\n+\t\t}\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tneigh = dst_neigh_lookup(dst, dst_addr.sin6_addr.in6_u.u6_addr32);\n+\n+\trcu_read_lock();\n+\tif (!neigh)\n+\t\tgoto exit;\n+\n+\tibdev_dbg(to_ibdev(iwdev), \"CM: dst_neigh_lookup MAC=%pM\\n\",\n+\t\t  neigh->ha);\n+\n+\ttrace_irdma_addr_resolve(iwdev, neigh->ha);\n+\n+\tif (neigh->nud_state & NUD_VALID)\n+\t\trc = irdma_add_arp(iwdev->rf, dest, false, neigh->ha);\n+\telse\n+\t\tneigh_event_send(neigh, NULL);\n+exit:\n+\n+\trcu_read_unlock();\n+\tif (neigh)\n+\t\tneigh_release(neigh);\n+\tdst_release(dst);\n+\n+\treturn rc;\n+}\n+\n+/**\n+ * irdma_ipv4_is_lpb - check if loopback\n+ * @loc_addr: local addr to compare\n+ * @rem_addr: remote address\n+ */\n+bool irdma_ipv4_is_lpb(u32 loc_addr, u32 rem_addr)\n+{\n+\treturn ipv4_is_loopback(htonl(rem_addr)) || (loc_addr == rem_addr);\n+}\n+\n+/**\n+ * irdma_ipv6_is_loopback - check if loopback\n+ * @loc_addr: local addr to compare\n+ * @rem_addr: remote address\n+ */\n+bool irdma_ipv6_is_lpb(u32 *loc_addr, u32 *rem_addr)\n+{\n+\tstruct in6_addr raddr6;\n+\n+\tirdma_copy_ip_htonl(raddr6.in6_u.u6_addr32, rem_addr);\n+\n+\treturn !memcmp(loc_addr, rem_addr, 16) || ipv6_addr_loopback(&raddr6);\n+}\n+\n+/**\n+ * irdma_cm_create_ah - create a cm address handle\n+ * @cm_node: The connection manager node to create AH for\n+ * @wait: Provides option to wait for ah creation or not\n+ */\n+static int irdma_cm_create_ah(struct irdma_cm_node *cm_node, bool wait)\n+{\n+\tstruct irdma_ah_info ah_info = {};\n+\tstruct irdma_device *iwdev = cm_node->iwdev;\n+\n+\tether_addr_copy(ah_info.mac_addr, iwdev->netdev->dev_addr);\n+\n+\tah_info.hop_ttl = 0x40;\n+\tah_info.tc_tos = cm_node->tos;\n+\tah_info.vsi = &iwdev->vsi;\n+\n+\tif (cm_node->ipv4) {\n+\t\tah_info.ipv4_valid = true;\n+\t\tah_info.dest_ip_addr[0] = cm_node->rem_addr[0];\n+\t\tah_info.src_ip_addr[0] = cm_node->loc_addr[0];\n+\t\tah_info.do_lpbk = irdma_ipv4_is_lpb(ah_info.src_ip_addr[0],\n+\t\t\t\t\t\t    ah_info.dest_ip_addr[0]);\n+\t} else {\n+\t\tmemcpy(ah_info.dest_ip_addr, cm_node->rem_addr,\n+\t\t       sizeof(ah_info.dest_ip_addr));\n+\t\tmemcpy(ah_info.src_ip_addr, cm_node->loc_addr,\n+\t\t       sizeof(ah_info.src_ip_addr));\n+\t\tah_info.do_lpbk = irdma_ipv6_is_lpb(ah_info.src_ip_addr,\n+\t\t\t\t\t\t    ah_info.dest_ip_addr);\n+\t}\n+\n+\tah_info.vlan_tag = cm_node->vlan_id;\n+\tif (cm_node->vlan_id < VLAN_N_VID) {\n+\t\tah_info.insert_vlan_tag = 1;\n+\t\tah_info.vlan_tag |= cm_node->user_pri << VLAN_PRIO_SHIFT;\n+\t}\n+\n+\tah_info.dst_arpindex =\n+\t\tirdma_arp_table(iwdev->rf, ah_info.dest_ip_addr,\n+\t\t\t\tah_info.ipv4_valid, NULL, IRDMA_ARP_RESOLVE);\n+\n+\tif (irdma_puda_create_ah(&iwdev->rf->sc_dev, &ah_info, wait,\n+\t\t\t\t IRDMA_PUDA_RSRC_TYPE_ILQ, cm_node,\n+\t\t\t\t &cm_node->ah))\n+\t\treturn -ENOMEM;\n+\n+\ttrace_irdma_create_ah(cm_node);\n+\treturn 0;\n+}\n+\n+/**\n+ * irdma_cm_free_ah - free a cm address handle\n+ * @cm_node: The connection manager node to create AH for\n+ */\n+static void irdma_cm_free_ah(struct irdma_cm_node *cm_node)\n+{\n+\tstruct irdma_device *iwdev = cm_node->iwdev;\n+\n+\ttrace_irdma_cm_free_ah(cm_node);\n+\tirdma_puda_free_ah(&iwdev->rf->sc_dev, cm_node->ah);\n+\tcm_node->ah = NULL;\n+}\n+\n+/**\n+ * irdma_make_cm_node - create a new instance of a cm node\n+ * @cm_core: cm's core\n+ * @iwdev: iwarp device structure\n+ * @cm_info: quad info for connection\n+ * @listener: passive connection's listener\n+ */\n+static struct irdma_cm_node *\n+irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev,\n+\t\t   struct irdma_cm_info *cm_info,\n+\t\t   struct irdma_cm_listener *listener)\n+{\n+\tstruct irdma_cm_node *cm_node;\n+\tint oldarpindex;\n+\tint arpindex;\n+\tstruct net_device *netdev = iwdev->netdev;\n+\n+\t/* create an hte and cm_node for this instance */\n+\tcm_node = kzalloc(sizeof(*cm_node), GFP_ATOMIC);\n+\tif (!cm_node)\n+\t\treturn NULL;\n+\n+\t/* set our node specific transport info */\n+\tcm_node->ipv4 = cm_info->ipv4;\n+\tcm_node->vlan_id = cm_info->vlan_id;\n+\tif (cm_node->vlan_id >= VLAN_N_VID && iwdev->dcb)\n+\t\tcm_node->vlan_id = 0;\n+\tcm_node->tos = cm_info->tos;\n+\tcm_node->user_pri = cm_info->user_pri;\n+\tif (listener) {\n+\t\tif (listener->tos != cm_info->tos)\n+\t\t\tdev_warn(rfdev_to_dev(&iwdev->rf->sc_dev),\n+\t\t\t\t \"application TOS[%d] and remote client TOS[%d] mismatch\\n\",\n+\t\t\t\t listener->tos, cm_info->tos);\n+\t\tcm_node->tos = max(listener->tos, cm_info->tos);\n+\t\tcm_node->user_pri = rt_tos2priority(cm_node->tos);\n+\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t  \"DCB: listener: TOS:[%d] UP:[%d]\\n\", cm_node->tos,\n+\t\t\t  cm_node->user_pri);\n+\t\ttrace_irdma_listener_tos(iwdev, cm_node->tos,\n+\t\t\t\t\t cm_node->user_pri);\n+\t}\n+\tmemcpy(cm_node->loc_addr, cm_info->loc_addr, sizeof(cm_node->loc_addr));\n+\tmemcpy(cm_node->rem_addr, cm_info->rem_addr, sizeof(cm_node->rem_addr));\n+\tcm_node->loc_port = cm_info->loc_port;\n+\tcm_node->rem_port = cm_info->rem_port;\n+\n+\tcm_node->mpa_frame_rev = IRDMA_CM_DEFAULT_MPA_VER;\n+\tcm_node->send_rdma0_op = SEND_RDMA_READ_ZERO;\n+\tcm_node->iwdev = iwdev;\n+\tcm_node->dev = &iwdev->rf->sc_dev;\n+\n+\tcm_node->ird_size = cm_node->dev->hw_attrs.max_hw_ird;\n+\tcm_node->ord_size = cm_node->dev->hw_attrs.max_hw_ord;\n+\n+\tcm_node->listener = listener;\n+\tcm_node->cm_id = cm_info->cm_id;\n+\tether_addr_copy(cm_node->loc_mac, netdev->dev_addr);\n+\tspin_lock_init(&cm_node->retrans_list_lock);\n+\tcm_node->ack_rcvd = false;\n+\n+\tatomic_set(&cm_node->ref_count, 1);\n+\t/* associate our parent CM core */\n+\tcm_node->cm_core = cm_core;\n+\tcm_node->tcp_cntxt.loc_id = IRDMA_CM_DEFAULT_LOCAL_ID;\n+\tcm_node->tcp_cntxt.rcv_wscale = iwdev->rcv_wscale;\n+\tcm_node->tcp_cntxt.rcv_wnd = iwdev->rcv_wnd >> cm_node->tcp_cntxt.rcv_wscale;\n+\tif (cm_node->ipv4) {\n+\t\tcm_node->tcp_cntxt.loc_seq_num = secure_tcp_seq(htonl(cm_node->loc_addr[0]),\n+\t\t\t\t\t\t\t\thtonl(cm_node->rem_addr[0]),\n+\t\t\t\t\t\t\t\thtons(cm_node->loc_port),\n+\t\t\t\t\t\t\t\thtons(cm_node->rem_port));\n+\t\tcm_node->tcp_cntxt.mss = iwdev->vsi.mtu - IRDMA_MTU_TO_MSS_IPV4;\n+\t} else if (IS_ENABLED(CONFIG_IPV6)) {\n+\t\t__be32 loc[4] = {\n+\t\t\thtonl(cm_node->loc_addr[0]), htonl(cm_node->loc_addr[1]),\n+\t\t\thtonl(cm_node->loc_addr[2]), htonl(cm_node->loc_addr[3])\n+\t\t};\n+\t\t__be32 rem[4] = {\n+\t\t\thtonl(cm_node->rem_addr[0]), htonl(cm_node->rem_addr[1]),\n+\t\t\thtonl(cm_node->rem_addr[2]), htonl(cm_node->rem_addr[3])\n+\t\t};\n+\t\tcm_node->tcp_cntxt.loc_seq_num = secure_tcpv6_seq(loc, rem,\n+\t\t\t\t\t\t\t\t  htons(cm_node->loc_port),\n+\t\t\t\t\t\t\t\t  htons(cm_node->rem_port));\n+\t\tcm_node->tcp_cntxt.mss = iwdev->vsi.mtu - IRDMA_MTU_TO_MSS_IPV6;\n+\t}\n+\n+\tif ((cm_node->ipv4 &&\n+\t     irdma_ipv4_is_lpb(cm_node->loc_addr[0], cm_node->rem_addr[0])) ||\n+\t    (!cm_node->ipv4 &&\n+\t     irdma_ipv6_is_lpb(cm_node->loc_addr, cm_node->rem_addr))) {\n+\t\tcm_node->do_lpb = true;\n+\t\tarpindex = irdma_arp_table(iwdev->rf, cm_node->rem_addr,\n+\t\t\t\t\t   cm_node->ipv4, NULL,\n+\t\t\t\t\t   IRDMA_ARP_RESOLVE);\n+\t} else {\n+\t\toldarpindex = irdma_arp_table(iwdev->rf, cm_node->rem_addr,\n+\t\t\t\t\t      cm_node->ipv4, NULL,\n+\t\t\t\t\t      IRDMA_ARP_RESOLVE);\n+\t\tif (cm_node->ipv4)\n+\t\t\tarpindex = irdma_addr_resolve_neigh(iwdev,\n+\t\t\t\t\t\t\t    cm_info->loc_addr[0],\n+\t\t\t\t\t\t\t    cm_info->rem_addr[0],\n+\t\t\t\t\t\t\t    oldarpindex);\n+\t\telse if (IS_ENABLED(CONFIG_IPV6))\n+\t\t\tarpindex = irdma_addr_resolve_neigh_ipv6(iwdev,\n+\t\t\t\t\t\t\t\t cm_info->loc_addr,\n+\t\t\t\t\t\t\t\t cm_info->rem_addr,\n+\t\t\t\t\t\t\t\t oldarpindex);\n+\t\telse\n+\t\t\tarpindex = -EINVAL;\n+\t}\n+\n+\tif (arpindex < 0)\n+\t\tgoto err;\n+\n+\tether_addr_copy(cm_node->rem_mac,\n+\t\t\tiwdev->rf->arp_table[arpindex].mac_addr);\n+\tirdma_add_hte_node(cm_core, cm_node);\n+\tcm_core->stats_nodes_created++;\n+\treturn cm_node;\n+\n+err:\n+\tkfree(cm_node);\n+\n+\treturn NULL;\n+}\n+\n+/**\n+ * irdma_rem_ref_cm_node - destroy an instance of a cm node\n+ * @cm_node: connection's node\n+ */\n+static void irdma_rem_ref_cm_node(struct irdma_cm_node *cm_node)\n+{\n+\tstruct irdma_cm_core *cm_core = cm_node->cm_core;\n+\tstruct irdma_qp *iwqp;\n+\tstruct irdma_cm_info nfo;\n+\tunsigned long flags;\n+\n+\ttrace_irdma_rem_ref_cm_node(cm_node, 0, __builtin_return_address(0));\n+\tspin_lock_irqsave(&cm_node->cm_core->ht_lock, flags);\n+\tif (atomic_dec_return(&cm_node->ref_count)) {\n+\t\tspin_unlock_irqrestore(&cm_node->cm_core->ht_lock, flags);\n+\t\treturn;\n+\t}\n+\n+\tlist_del(&cm_node->list);\n+\tspin_unlock_irqrestore(&cm_node->cm_core->ht_lock, flags);\n+\n+\t/* if the node is destroyed before connection was accelerated */\n+\tif (!cm_node->accelerated && cm_node->accept_pend) {\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t  \"CM: node destroyed before established\\n\");\n+\t\tatomic_dec(&cm_node->listener->pend_accepts_cnt);\n+\t}\n+\tif (cm_node->close_entry)\n+\t\tirdma_handle_close_entry(cm_node, 0);\n+\tif (cm_node->listener) {\n+\t\tirdma_dec_refcnt_listen(cm_core, cm_node->listener, 0, true);\n+\t} else {\n+\t\tif (cm_node->apbvt_set) {\n+\t\t\tirdma_manage_apbvt(cm_node->iwdev, cm_node->loc_port,\n+\t\t\t\t\t   IRDMA_MANAGE_APBVT_DEL);\n+\t\t\tcm_node->apbvt_set = 0;\n+\t\t}\n+\t\tirdma_get_addr_info(cm_node, &nfo);\n+\t\tif (cm_node->qhash_set) {\n+\t\t\tnfo.qh_qpid = cm_node->iwdev->vsi.ilq->qp_id;\n+\t\t\tirdma_manage_qhash(cm_node->iwdev, &nfo,\n+\t\t\t\t\t   IRDMA_QHASH_TYPE_TCP_ESTABLISHED,\n+\t\t\t\t\t   IRDMA_QHASH_MANAGE_TYPE_DELETE, NULL,\n+\t\t\t\t\t   false);\n+\t\t\tcm_node->qhash_set = 0;\n+\t\t}\n+\t}\n+\n+\tiwqp = cm_node->iwqp;\n+\tif (iwqp) {\n+\t\tiwqp->cm_node = NULL;\n+\t\tirdma_rem_ref(&iwqp->ibqp);\n+\t\tcm_node->iwqp = NULL;\n+\t} else if (cm_node->qhash_set) {\n+\t\tirdma_get_addr_info(cm_node, &nfo);\n+\t\tnfo.qh_qpid = cm_node->iwdev->vsi.ilq->qp_id;\n+\t\tirdma_manage_qhash(cm_node->iwdev, &nfo,\n+\t\t\t\t   IRDMA_QHASH_TYPE_TCP_ESTABLISHED,\n+\t\t\t\t   IRDMA_QHASH_MANAGE_TYPE_DELETE, NULL, false);\n+\t\tcm_node->qhash_set = 0;\n+\t}\n+\tcm_core->cm_free_ah(cm_node);\n+\tcm_node->cm_core->stats_nodes_destroyed++;\n+\tkfree(cm_node);\n+}\n+\n+/**\n+ * irdma_handle_fin_pkt - FIN packet received\n+ * @cm_node: connection's node\n+ */\n+static void irdma_handle_fin_pkt(struct irdma_cm_node *cm_node)\n+{\n+\tswitch (cm_node->state) {\n+\tcase IRDMA_CM_STATE_SYN_RCVD:\n+\tcase IRDMA_CM_STATE_SYN_SENT:\n+\tcase IRDMA_CM_STATE_ESTABLISHED:\n+\tcase IRDMA_CM_STATE_MPAREJ_RCVD:\n+\t\tcm_node->tcp_cntxt.rcv_nxt++;\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tcm_node->state = IRDMA_CM_STATE_LAST_ACK;\n+\t\tirdma_send_fin(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_MPAREQ_SENT:\n+\t\tirdma_create_event(cm_node, IRDMA_CM_EVENT_ABORTED);\n+\t\tcm_node->tcp_cntxt.rcv_nxt++;\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tcm_node->state = IRDMA_CM_STATE_CLOSED;\n+\t\tatomic_inc(&cm_node->ref_count);\n+\t\tirdma_send_reset(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_FIN_WAIT1:\n+\t\tcm_node->tcp_cntxt.rcv_nxt++;\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tcm_node->state = IRDMA_CM_STATE_CLOSING;\n+\t\tirdma_send_ack(cm_node);\n+\t\t/*\n+\t\t * Wait for ACK as this is simultaneous close.\n+\t\t * After we receive ACK, do not send anything.\n+\t\t * Just rm the node.\n+\t\t */\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_FIN_WAIT2:\n+\t\tcm_node->tcp_cntxt.rcv_nxt++;\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tcm_node->state = IRDMA_CM_STATE_TIME_WAIT;\n+\t\tirdma_send_ack(cm_node);\n+\t\tirdma_schedule_cm_timer(cm_node, NULL, IRDMA_TIMER_TYPE_CLOSE,\n+\t\t\t\t\t1, 0);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_TIME_WAIT:\n+\t\tcm_node->tcp_cntxt.rcv_nxt++;\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tcm_node->state = IRDMA_CM_STATE_CLOSED;\n+\t\tirdma_rem_ref_cm_node(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_OFFLOADED:\n+\tdefault:\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t  \"CM: bad state node state = %d\\n\", cm_node->state);\n+\t\tbreak;\n+\t}\n+}\n+\n+/**\n+ * irdma_handle_rst_pkt - process received RST packet\n+ * @cm_node: connection's node\n+ * @rbuf: receive buffer\n+ */\n+static void irdma_handle_rst_pkt(struct irdma_cm_node *cm_node,\n+\t\t\t\t struct irdma_puda_buf *rbuf)\n+{\n+\tirdma_cleanup_retrans_entry(cm_node);\n+\tswitch (cm_node->state) {\n+\tcase IRDMA_CM_STATE_SYN_SENT:\n+\tcase IRDMA_CM_STATE_MPAREQ_SENT:\n+\t\tswitch (cm_node->mpa_frame_rev) {\n+\t\tcase IETF_MPA_V2:\n+\t\t\t/* Drop down to MPA_V1*/\n+\t\t\tcm_node->mpa_frame_rev = IETF_MPA_V1;\n+\t\t\t/* send a syn and goto syn sent state */\n+\t\t\tcm_node->state = IRDMA_CM_STATE_SYN_SENT;\n+\t\t\tif (irdma_send_syn(cm_node, 0))\n+\t\t\t\tirdma_active_open_err(cm_node, false);\n+\t\t\tbreak;\n+\t\tcase IETF_MPA_V1:\n+\t\tdefault:\n+\t\t\tirdma_active_open_err(cm_node, false);\n+\t\t\tbreak;\n+\t\t}\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_MPAREQ_RCVD:\n+\t\tatomic_add_return(1, &cm_node->passive_state);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_ESTABLISHED:\n+\tcase IRDMA_CM_STATE_SYN_RCVD:\n+\tcase IRDMA_CM_STATE_LISTENING:\n+\t\tirdma_passive_open_err(cm_node, false);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_OFFLOADED:\n+\t\tirdma_active_open_err(cm_node, false);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_CLOSED:\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_FIN_WAIT2:\n+\tcase IRDMA_CM_STATE_FIN_WAIT1:\n+\tcase IRDMA_CM_STATE_LAST_ACK:\n+\t\tcm_node->cm_id->rem_ref(cm_node->cm_id);\n+\t\t/* fall through */\n+\tcase IRDMA_CM_STATE_TIME_WAIT:\n+\t\tcm_node->state = IRDMA_CM_STATE_CLOSED;\n+\t\tirdma_rem_ref_cm_node(cm_node);\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+}\n+\n+/**\n+ * irdma_handle_rcv_mpa - Process a recv'd mpa buffer\n+ * @cm_node: connection's node\n+ * @rbuf: receive buffer\n+ */\n+static void irdma_handle_rcv_mpa(struct irdma_cm_node *cm_node,\n+\t\t\t\t struct irdma_puda_buf *rbuf)\n+{\n+\tint err;\n+\tint datasize = rbuf->datalen;\n+\tu8 *dataloc = rbuf->data;\n+\n+\tenum irdma_cm_event_type type = IRDMA_CM_EVENT_UNKNOWN;\n+\tu32 res_type;\n+\n+\terr = irdma_parse_mpa(cm_node, dataloc, &res_type, datasize);\n+\tif (err) {\n+\t\tif (cm_node->state == IRDMA_CM_STATE_MPAREQ_SENT)\n+\t\t\tirdma_active_open_err(cm_node, true);\n+\t\telse\n+\t\t\tirdma_passive_open_err(cm_node, true);\n+\t\treturn;\n+\t}\n+\n+\tswitch (cm_node->state) {\n+\tcase IRDMA_CM_STATE_ESTABLISHED:\n+\t\tif (res_type == IRDMA_MPA_REQUEST_REJECT)\n+\t\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t\t  \"CM: state for reject\\n\");\n+\t\tcm_node->state = IRDMA_CM_STATE_MPAREQ_RCVD;\n+\t\ttype = IRDMA_CM_EVENT_MPA_REQ;\n+\t\tirdma_send_ack(cm_node); /* ACK received MPA request */\n+\t\tatomic_set(&cm_node->passive_state,\n+\t\t\t   IRDMA_PASSIVE_STATE_INDICATED);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_MPAREQ_SENT:\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tif (res_type == IRDMA_MPA_REQUEST_REJECT) {\n+\t\t\ttype = IRDMA_CM_EVENT_MPA_REJECT;\n+\t\t\tcm_node->state = IRDMA_CM_STATE_MPAREJ_RCVD;\n+\t\t} else {\n+\t\t\ttype = IRDMA_CM_EVENT_CONNECTED;\n+\t\t\tcm_node->state = IRDMA_CM_STATE_OFFLOADED;\n+\t\t}\n+\t\tirdma_send_ack(cm_node);\n+\t\tbreak;\n+\tdefault:\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t  \"CM: wrong cm_node state =%d\\n\", cm_node->state);\n+\t\tbreak;\n+\t}\n+\tirdma_create_event(cm_node, type);\n+}\n+\n+/**\n+ * irdma_check_syn - Check for error on received syn ack\n+ * @cm_node: connection's node\n+ * @tcph: pointer tcp header\n+ */\n+static int irdma_check_syn(struct irdma_cm_node *cm_node, struct tcphdr *tcph)\n+{\n+\tif (ntohl(tcph->ack_seq) != cm_node->tcp_cntxt.loc_seq_num) {\n+\t\tirdma_active_open_err(cm_node, true);\n+\t\treturn 1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * irdma_check_seq - check seq numbers if OK\n+ * @cm_node: connection's node\n+ * @tcph: pointer tcp header\n+ */\n+static int irdma_check_seq(struct irdma_cm_node *cm_node, struct tcphdr *tcph)\n+{\n+\tu32 seq;\n+\tu32 ack_seq;\n+\tu32 loc_seq_num = cm_node->tcp_cntxt.loc_seq_num;\n+\tu32 rcv_nxt = cm_node->tcp_cntxt.rcv_nxt;\n+\tu32 rcv_wnd;\n+\tint err = 0;\n+\n+\tseq = ntohl(tcph->seq);\n+\tack_seq = ntohl(tcph->ack_seq);\n+\trcv_wnd = cm_node->tcp_cntxt.rcv_wnd;\n+\tif (ack_seq != loc_seq_num ||\n+\t    !between(seq, rcv_nxt, (rcv_nxt + rcv_wnd)))\n+\t\terr = -1;\n+\tif (err)\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev), \"CM: seq number err\\n\");\n+\n+\treturn err;\n+}\n+\n+/**\n+ * irdma_handle_syn_pkt - is for Passive node\n+ * @cm_node: connection's node\n+ * @rbuf: receive buffer\n+ */\n+static void irdma_handle_syn_pkt(struct irdma_cm_node *cm_node,\n+\t\t\t\t struct irdma_puda_buf *rbuf)\n+{\n+\tstruct tcphdr *tcph = (struct tcphdr *)rbuf->tcph;\n+\tint err;\n+\tu32 inc_sequence;\n+\tint optionsize;\n+\tstruct irdma_cm_info nfo;\n+\n+\toptionsize = (tcph->doff << 2) - sizeof(struct tcphdr);\n+\tinc_sequence = ntohl(tcph->seq);\n+\n+\tswitch (cm_node->state) {\n+\tcase IRDMA_CM_STATE_SYN_SENT:\n+\tcase IRDMA_CM_STATE_MPAREQ_SENT:\n+\t\t/* Rcvd syn on active open connection */\n+\t\tirdma_active_open_err(cm_node, 1);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_LISTENING:\n+\t\t/* Passive OPEN */\n+\t\tif (atomic_read(&cm_node->listener->pend_accepts_cnt) >\n+\t\t    cm_node->listener->backlog) {\n+\t\t\tcm_node->cm_core->stats_backlog_drops++;\n+\t\t\tirdma_passive_open_err(cm_node, false);\n+\t\t\tbreak;\n+\t\t}\n+\t\terr = irdma_handle_tcp_options(cm_node, tcph, optionsize, 1);\n+\t\tif (err) {\n+\t\t\tirdma_passive_open_err(cm_node, false);\n+\t\t\t/* drop pkt */\n+\t\t\tbreak;\n+\t\t}\n+\t\terr = cm_node->cm_core->cm_create_ah(cm_node, false);\n+\t\tif (err) {\n+\t\t\tirdma_passive_open_err(cm_node, false);\n+\t\t\t/* drop pkt */\n+\t\t\tbreak;\n+\t\t}\n+\t\tcm_node->tcp_cntxt.rcv_nxt = inc_sequence + 1;\n+\t\tcm_node->accept_pend = 1;\n+\t\tatomic_inc(&cm_node->listener->pend_accepts_cnt);\n+\n+\t\tcm_node->state = IRDMA_CM_STATE_SYN_RCVD;\n+\t\tirdma_get_addr_info(cm_node, &nfo);\n+\t\tnfo.qh_qpid = cm_node->iwdev->vsi.ilq->qp_id;\n+\t\terr = irdma_manage_qhash(cm_node->iwdev, &nfo,\n+\t\t\t\t\t IRDMA_QHASH_TYPE_TCP_ESTABLISHED,\n+\t\t\t\t\t IRDMA_QHASH_MANAGE_TYPE_ADD,\n+\t\t\t\t\t cm_node, false);\n+\t\tcm_node->qhash_set = true;\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_CLOSED:\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tatomic_inc(&cm_node->ref_count);\n+\t\tirdma_send_reset(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_OFFLOADED:\n+\tcase IRDMA_CM_STATE_ESTABLISHED:\n+\tcase IRDMA_CM_STATE_FIN_WAIT1:\n+\tcase IRDMA_CM_STATE_FIN_WAIT2:\n+\tcase IRDMA_CM_STATE_MPAREQ_RCVD:\n+\tcase IRDMA_CM_STATE_LAST_ACK:\n+\tcase IRDMA_CM_STATE_CLOSING:\n+\tcase IRDMA_CM_STATE_UNKNOWN:\n+\tdefault:\n+\t\tbreak;\n+\t}\n+}\n+\n+/**\n+ * irdma_handle_synack_pkt - Process SYN+ACK packet (active side)\n+ * @cm_node: connection's node\n+ * @rbuf: receive buffer\n+ */\n+static void irdma_handle_synack_pkt(struct irdma_cm_node *cm_node,\n+\t\t\t\t    struct irdma_puda_buf *rbuf)\n+{\n+\tstruct tcphdr *tcph = (struct tcphdr *)rbuf->tcph;\n+\tint err;\n+\tu32 inc_sequence;\n+\tint optionsize;\n+\n+\toptionsize = (tcph->doff << 2) - sizeof(struct tcphdr);\n+\tinc_sequence = ntohl(tcph->seq);\n+\tswitch (cm_node->state) {\n+\tcase IRDMA_CM_STATE_SYN_SENT:\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\t/* active open */\n+\t\tif (irdma_check_syn(cm_node, tcph)) {\n+\t\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t\t  \"CM: check syn fail\\n\");\n+\t\t\treturn;\n+\t\t}\n+\t\tcm_node->tcp_cntxt.rem_ack_num = ntohl(tcph->ack_seq);\n+\t\t/* setup options */\n+\t\terr = irdma_handle_tcp_options(cm_node, tcph, optionsize, 0);\n+\t\tif (err) {\n+\t\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t\t  \"CM: cm_node=%p tcp_options failed\\n\",\n+\t\t\t\t  cm_node);\n+\t\t\tbreak;\n+\t\t}\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tcm_node->tcp_cntxt.rcv_nxt = inc_sequence + 1;\n+\t\tirdma_send_ack(cm_node); /* ACK  for the syn_ack */\n+\t\terr = irdma_send_mpa_request(cm_node);\n+\t\tif (err) {\n+\t\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t\t  \"CM: cm_node=%p irdma_send_mpa_request failed\\n\",\n+\t\t\t\t  cm_node);\n+\t\t\tbreak;\n+\t\t}\n+\t\tcm_node->state = IRDMA_CM_STATE_MPAREQ_SENT;\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_MPAREQ_RCVD:\n+\t\tirdma_passive_open_err(cm_node, true);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_LISTENING:\n+\t\tcm_node->tcp_cntxt.loc_seq_num = ntohl(tcph->ack_seq);\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tcm_node->state = IRDMA_CM_STATE_CLOSED;\n+\t\tirdma_send_reset(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_CLOSED:\n+\t\tcm_node->tcp_cntxt.loc_seq_num = ntohl(tcph->ack_seq);\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tatomic_inc(&cm_node->ref_count);\n+\t\tirdma_send_reset(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_ESTABLISHED:\n+\tcase IRDMA_CM_STATE_FIN_WAIT1:\n+\tcase IRDMA_CM_STATE_FIN_WAIT2:\n+\tcase IRDMA_CM_STATE_LAST_ACK:\n+\tcase IRDMA_CM_STATE_OFFLOADED:\n+\tcase IRDMA_CM_STATE_CLOSING:\n+\tcase IRDMA_CM_STATE_UNKNOWN:\n+\tcase IRDMA_CM_STATE_MPAREQ_SENT:\n+\tdefault:\n+\t\tbreak;\n+\t}\n+}\n+\n+/**\n+ * irdma_handle_ack_pkt - process packet with ACK\n+ * @cm_node: connection's node\n+ * @rbuf: receive buffer\n+ */\n+static int irdma_handle_ack_pkt(struct irdma_cm_node *cm_node,\n+\t\t\t\tstruct irdma_puda_buf *rbuf)\n+{\n+\tstruct tcphdr *tcph = (struct tcphdr *)rbuf->tcph;\n+\tu32 inc_sequence;\n+\tint ret;\n+\tint optionsize;\n+\tu32 datasize = rbuf->datalen;\n+\n+\toptionsize = (tcph->doff << 2) - sizeof(struct tcphdr);\n+\n+\tif (irdma_check_seq(cm_node, tcph))\n+\t\treturn -EINVAL;\n+\n+\tinc_sequence = ntohl(tcph->seq);\n+\tswitch (cm_node->state) {\n+\tcase IRDMA_CM_STATE_SYN_RCVD:\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tret = irdma_handle_tcp_options(cm_node, tcph, optionsize, 1);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t\tcm_node->tcp_cntxt.rem_ack_num = ntohl(tcph->ack_seq);\n+\t\tcm_node->state = IRDMA_CM_STATE_ESTABLISHED;\n+\t\tif (datasize) {\n+\t\t\tcm_node->tcp_cntxt.rcv_nxt = inc_sequence + datasize;\n+\t\t\tirdma_handle_rcv_mpa(cm_node, rbuf);\n+\t\t}\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_ESTABLISHED:\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tif (datasize) {\n+\t\t\tcm_node->tcp_cntxt.rcv_nxt = inc_sequence + datasize;\n+\t\t\tirdma_handle_rcv_mpa(cm_node, rbuf);\n+\t\t}\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_MPAREQ_SENT:\n+\t\tcm_node->tcp_cntxt.rem_ack_num = ntohl(tcph->ack_seq);\n+\t\tif (datasize) {\n+\t\t\tcm_node->tcp_cntxt.rcv_nxt = inc_sequence + datasize;\n+\t\t\tcm_node->ack_rcvd = false;\n+\t\t\tirdma_handle_rcv_mpa(cm_node, rbuf);\n+\t\t} else {\n+\t\t\tcm_node->ack_rcvd = true;\n+\t\t}\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_LISTENING:\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tcm_node->state = IRDMA_CM_STATE_CLOSED;\n+\t\tirdma_send_reset(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_CLOSED:\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tatomic_inc(&cm_node->ref_count);\n+\t\tirdma_send_reset(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_LAST_ACK:\n+\tcase IRDMA_CM_STATE_CLOSING:\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tcm_node->state = IRDMA_CM_STATE_CLOSED;\n+\t\tif (!cm_node->accept_pend)\n+\t\t\tcm_node->cm_id->rem_ref(cm_node->cm_id);\n+\t\tirdma_rem_ref_cm_node(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_FIN_WAIT1:\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tcm_node->state = IRDMA_CM_STATE_FIN_WAIT2;\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_SYN_SENT:\n+\tcase IRDMA_CM_STATE_FIN_WAIT2:\n+\tcase IRDMA_CM_STATE_OFFLOADED:\n+\tcase IRDMA_CM_STATE_MPAREQ_RCVD:\n+\tcase IRDMA_CM_STATE_UNKNOWN:\n+\tdefault:\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tbreak;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * irdma_process_packet - process cm packet\n+ * @cm_node: connection's node\n+ * @rbuf: receive buffer\n+ */\n+static void irdma_process_pkt(struct irdma_cm_node *cm_node,\n+\t\t\t      struct irdma_puda_buf *rbuf)\n+{\n+\tenum irdma_tcpip_pkt_type pkt_type = IRDMA_PKT_TYPE_UNKNOWN;\n+\tstruct tcphdr *tcph = (struct tcphdr *)rbuf->tcph;\n+\tu32 fin_set = 0;\n+\tint err;\n+\n+\tif (tcph->rst) {\n+\t\tpkt_type = IRDMA_PKT_TYPE_RST;\n+\t} else if (tcph->syn) {\n+\t\tpkt_type = IRDMA_PKT_TYPE_SYN;\n+\t\tif (tcph->ack)\n+\t\t\tpkt_type = IRDMA_PKT_TYPE_SYNACK;\n+\t} else if (tcph->ack) {\n+\t\tpkt_type = IRDMA_PKT_TYPE_ACK;\n+\t}\n+\tif (tcph->fin)\n+\t\tfin_set = 1;\n+\n+\tswitch (pkt_type) {\n+\tcase IRDMA_PKT_TYPE_SYN:\n+\t\tirdma_handle_syn_pkt(cm_node, rbuf);\n+\t\tbreak;\n+\tcase IRDMA_PKT_TYPE_SYNACK:\n+\t\tirdma_handle_synack_pkt(cm_node, rbuf);\n+\t\tbreak;\n+\tcase IRDMA_PKT_TYPE_ACK:\n+\t\terr = irdma_handle_ack_pkt(cm_node, rbuf);\n+\t\tif (fin_set && !err)\n+\t\t\tirdma_handle_fin_pkt(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_PKT_TYPE_RST:\n+\t\tirdma_handle_rst_pkt(cm_node, rbuf);\n+\t\tbreak;\n+\tdefault:\n+\t\tif (fin_set &&\n+\t\t    (!irdma_check_seq(cm_node, (struct tcphdr *)rbuf->tcph)))\n+\t\t\tirdma_handle_fin_pkt(cm_node);\n+\t\tbreak;\n+\t}\n+}\n+\n+/**\n+ * irdma_make_listen_node - create a listen node with params\n+ * @cm_core: cm's core\n+ * @iwdev: iwarp device structure\n+ * @cm_info: quad info for connection\n+ */\n+static struct irdma_cm_listener *\n+irdma_make_listen_node(struct irdma_cm_core *cm_core,\n+\t\t       struct irdma_device *iwdev,\n+\t\t       struct irdma_cm_info *cm_info)\n+{\n+\tstruct irdma_cm_listener *listener;\n+\tunsigned long flags;\n+\n+\t/* cannot have multiple matching listeners */\n+\tlistener = irdma_find_listener(cm_core, cm_info->loc_addr,\n+\t\t\t\t       cm_info->loc_port, cm_info->vlan_id,\n+\t\t\t\t       IRDMA_CM_LISTENER_EITHER_STATE);\n+\tif (listener &&\n+\t    listener->listener_state == IRDMA_CM_LISTENER_ACTIVE_STATE) {\n+\t\tatomic_dec(&listener->ref_count);\n+\t\treturn NULL;\n+\t}\n+\n+\tif (!listener) {\n+\t\t/* create a CM listen node\n+\t\t * 1/2 node to compare incoming traffic to\n+\t\t */\n+\t\tlistener = kzalloc(sizeof(*listener), GFP_KERNEL);\n+\t\tif (!listener)\n+\t\t\treturn NULL;\n+\t\tcm_core->stats_listen_nodes_created++;\n+\t\tmemcpy(listener->loc_addr, cm_info->loc_addr,\n+\t\t       sizeof(listener->loc_addr));\n+\t\tlistener->loc_port = cm_info->loc_port;\n+\n+\t\tINIT_LIST_HEAD(&listener->child_listen_list);\n+\n+\t\tatomic_set(&listener->ref_count, 1);\n+\t} else {\n+\t\tlistener->reused_node = 1;\n+\t}\n+\n+\tlistener->cm_id = cm_info->cm_id;\n+\tlistener->ipv4 = cm_info->ipv4;\n+\tlistener->vlan_id = cm_info->vlan_id;\n+\tatomic_set(&listener->pend_accepts_cnt, 0);\n+\tlistener->cm_core = cm_core;\n+\tlistener->iwdev = iwdev;\n+\n+\tlistener->backlog = cm_info->backlog;\n+\tlistener->listener_state = IRDMA_CM_LISTENER_ACTIVE_STATE;\n+\n+\tif (!listener->reused_node) {\n+\t\tspin_lock_irqsave(&cm_core->listen_list_lock, flags);\n+\t\tlist_add(&listener->list, &cm_core->listen_nodes);\n+\t\tspin_unlock_irqrestore(&cm_core->listen_list_lock, flags);\n+\t}\n+\n+\treturn listener;\n+}\n+\n+/**\n+ * irdma_create_cm_node - make a connection node with params\n+ * @cm_core: cm's core\n+ * @iwdev: iwarp device structure\n+ * @conn_param: connection parameters\n+ * @cm_info: quad info for connection\n+ * @caller_cm_node: pointer to cm_node structure to return\n+ */\n+static int irdma_create_cm_node(struct irdma_cm_core *cm_core,\n+\t\t\t\tstruct irdma_device *iwdev,\n+\t\t\t\tstruct iw_cm_conn_param *conn_param,\n+\t\t\t\tstruct irdma_cm_info *cm_info,\n+\t\t\t\tstruct irdma_cm_node **caller_cm_node)\n+{\n+\tstruct irdma_cm_node *cm_node;\n+\tu16 private_data_len = conn_param->private_data_len;\n+\tconst void *private_data = conn_param->private_data;\n+\n+\t/* create a CM connection node */\n+\tcm_node = irdma_make_cm_node(cm_core, iwdev, cm_info, NULL);\n+\tif (!cm_node)\n+\t\treturn -ENOMEM;\n+\n+\t/* set our node side to client (active) side */\n+\tcm_node->tcp_cntxt.client = 1;\n+\tcm_node->tcp_cntxt.rcv_wscale = IRDMA_CM_DEFAULT_RCV_WND_SCALE;\n+\n+\tirdma_record_ird_ord(cm_node, conn_param->ird, conn_param->ord);\n+\n+\tcm_node->pdata.size = private_data_len;\n+\tcm_node->pdata.addr = cm_node->pdata_buf;\n+\n+\tmemcpy(cm_node->pdata_buf, private_data, private_data_len);\n+\t*caller_cm_node = cm_node;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * irdma_cm_reject - reject and teardown a connection\n+ * @cm_node: connection's node\n+ * @pdata: ptr to private data for reject\n+ * @plen: size of private data\n+ */\n+static int irdma_cm_reject(struct irdma_cm_node *cm_node, const void *pdata,\n+\t\t\t   u8 plen)\n+{\n+\tint ret;\n+\tint passive_state;\n+\tstruct iw_cm_id *cm_id = cm_node->cm_id;\n+\n+\tif (cm_node->tcp_cntxt.client)\n+\t\treturn 0;\n+\n+\tirdma_cleanup_retrans_entry(cm_node);\n+\n+\tpassive_state = atomic_add_return(1, &cm_node->passive_state);\n+\tif (passive_state == IRDMA_SEND_RESET_EVENT) {\n+\t\tcm_node->state = IRDMA_CM_STATE_CLOSED;\n+\t\tirdma_rem_ref_cm_node(cm_node);\n+\t\treturn 0;\n+\t}\n+\n+\tif (cm_node->state == IRDMA_CM_STATE_LISTENER_DESTROYED) {\n+\t\tirdma_rem_ref_cm_node(cm_node);\n+\t\treturn 0;\n+\t}\n+\n+\tret = irdma_send_mpa_reject(cm_node, pdata, plen);\n+\tif (!ret) {\n+\t\tcm_id->add_ref(cm_id);\n+\t\treturn 0;\n+\t}\n+\n+\tcm_node->state = IRDMA_CM_STATE_CLOSED;\n+\tif (irdma_send_reset(cm_node))\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev), \"CM: send reset failed\\n\");\n+\treturn ret;\n+}\n+\n+/**\n+ * irdma_cm_close - close of cm connection\n+ * @cm_node: connection's node\n+ */\n+static int irdma_cm_close(struct irdma_cm_node *cm_node)\n+{\n+\tif (!cm_node)\n+\t\treturn -EINVAL;\n+\n+\tswitch (cm_node->state) {\n+\tcase IRDMA_CM_STATE_SYN_RCVD:\n+\tcase IRDMA_CM_STATE_SYN_SENT:\n+\tcase IRDMA_CM_STATE_ONE_SIDE_ESTABLISHED:\n+\tcase IRDMA_CM_STATE_ESTABLISHED:\n+\tcase IRDMA_CM_STATE_ACCEPTING:\n+\tcase IRDMA_CM_STATE_MPAREQ_SENT:\n+\tcase IRDMA_CM_STATE_MPAREQ_RCVD:\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tirdma_send_reset(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_CLOSE_WAIT:\n+\t\tcm_node->state = IRDMA_CM_STATE_LAST_ACK;\n+\t\tirdma_send_fin(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_FIN_WAIT1:\n+\tcase IRDMA_CM_STATE_FIN_WAIT2:\n+\tcase IRDMA_CM_STATE_LAST_ACK:\n+\tcase IRDMA_CM_STATE_TIME_WAIT:\n+\tcase IRDMA_CM_STATE_CLOSING:\n+\t\treturn -1;\n+\tcase IRDMA_CM_STATE_LISTENING:\n+\t\tirdma_cleanup_retrans_entry(cm_node);\n+\t\tirdma_send_reset(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_MPAREJ_RCVD:\n+\tcase IRDMA_CM_STATE_UNKNOWN:\n+\tcase IRDMA_CM_STATE_INITED:\n+\tcase IRDMA_CM_STATE_CLOSED:\n+\tcase IRDMA_CM_STATE_LISTENER_DESTROYED:\n+\t\tirdma_rem_ref_cm_node(cm_node);\n+\t\tbreak;\n+\tcase IRDMA_CM_STATE_OFFLOADED:\n+\t\tif (cm_node->send_entry)\n+\t\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t\t  \"CM: CM send_entry in OFFLOADED state\\n\");\n+\t\tirdma_rem_ref_cm_node(cm_node);\n+\t\tbreak;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * irdma_receive_ilq - recv an ETHERNET packet, and process it\n+ * through CM\n+ * @vsi: VSI structure of dev\n+ * @rbuf: receive buffer\n+ */\n+void irdma_receive_ilq(struct irdma_sc_vsi *vsi, struct irdma_puda_buf *rbuf)\n+{\n+\tstruct irdma_cm_node *cm_node;\n+\tstruct irdma_cm_listener *listener;\n+\tstruct iphdr *iph;\n+\tstruct ipv6hdr *ip6h;\n+\tstruct tcphdr *tcph;\n+\tstruct irdma_cm_info cm_info = {};\n+\tstruct irdma_device *iwdev = vsi->back_vsi;\n+\tstruct irdma_cm_core *cm_core = &iwdev->cm_core;\n+\tstruct vlan_ethhdr *ethh;\n+\tu16 vtag;\n+\n+\t/* if vlan, then maclen = 18 else 14 */\n+\tiph = (struct iphdr *)rbuf->iph;\n+\tirdma_debug_buf(vsi->dev, IRDMA_DEBUG_ILQ, \"RECEIVE ILQ BUFFER\",\n+\t\t\trbuf->mem.va, rbuf->totallen);\n+\tif (iwdev->rf->sc_dev.hw_attrs.uk_attrs.hw_rev > IRDMA_GEN_1) {\n+\t\tif (rbuf->vlan_valid) {\n+\t\t\tvtag = rbuf->vlan_id;\n+\t\t\tcm_info.user_pri = (vtag & VLAN_PRIO_MASK) >>\n+\t\t\t\t\t   VLAN_PRIO_SHIFT;\n+\t\t\tcm_info.vlan_id = vtag & VLAN_VID_MASK;\n+\t\t} else {\n+\t\t\tcm_info.vlan_id = 0xFFFF;\n+\t\t}\n+\t} else {\n+\t\tethh = rbuf->mem.va;\n+\n+\t\tif (ethh->h_vlan_proto == htons(ETH_P_8021Q)) {\n+\t\t\tvtag = ntohs(ethh->h_vlan_TCI);\n+\t\t\tcm_info.user_pri = (vtag & VLAN_PRIO_MASK) >>\n+\t\t\t\t\t   VLAN_PRIO_SHIFT;\n+\t\t\tcm_info.vlan_id = vtag & VLAN_VID_MASK;\n+\t\t\tibdev_dbg(to_ibdev(cm_core->iwdev),\n+\t\t\t\t  \"CM: vlan_id=%d\\n\", cm_info.vlan_id);\n+\t\t} else {\n+\t\t\tcm_info.vlan_id = 0xFFFF;\n+\t\t}\n+\t}\n+\ttcph = (struct tcphdr *)rbuf->tcph;\n+\n+\tif (rbuf->ipv4) {\n+\t\tcm_info.loc_addr[0] = ntohl(iph->daddr);\n+\t\tcm_info.rem_addr[0] = ntohl(iph->saddr);\n+\t\tcm_info.ipv4 = true;\n+\t\tcm_info.tos = iph->tos;\n+\t} else {\n+\t\tip6h = (struct ipv6hdr *)rbuf->iph;\n+\t\tirdma_copy_ip_ntohl(cm_info.loc_addr,\n+\t\t\t\t    ip6h->daddr.in6_u.u6_addr32);\n+\t\tirdma_copy_ip_ntohl(cm_info.rem_addr,\n+\t\t\t\t    ip6h->saddr.in6_u.u6_addr32);\n+\t\tcm_info.ipv4 = false;\n+\t\tcm_info.tos = (ip6h->priority << 4) | (ip6h->flow_lbl[0] >> 4);\n+\t}\n+\tcm_info.loc_port = ntohs(tcph->dest);\n+\tcm_info.rem_port = ntohs(tcph->source);\n+\tcm_node = irdma_find_node(cm_core, cm_info.rem_port, cm_info.rem_addr,\n+\t\t\t\t  cm_info.loc_port, cm_info.loc_addr, true,\n+\t\t\t\t  false);\n+\n+\tif (!cm_node) {\n+\t\t/* Only type of packet accepted are for the\n+\t\t * PASSIVE open (syn only)\n+\t\t */\n+\t\tif (!tcph->syn || tcph->ack)\n+\t\t\treturn;\n+\n+\t\tlistener = irdma_find_listener(cm_core,\n+\t\t\t\t\t       cm_info.loc_addr,\n+\t\t\t\t\t       cm_info.loc_port,\n+\t\t\t\t\t       cm_info.vlan_id,\n+\t\t\t\t\t       IRDMA_CM_LISTENER_ACTIVE_STATE);\n+\t\tif (!listener) {\n+\t\t\tcm_info.cm_id = NULL;\n+\t\t\tibdev_dbg(to_ibdev(cm_core->iwdev),\n+\t\t\t\t  \"CM: no listener found\\n\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tcm_info.cm_id = listener->cm_id;\n+\t\tcm_node = irdma_make_cm_node(cm_core, iwdev, &cm_info,\n+\t\t\t\t\t     listener);\n+\t\tif (!cm_node) {\n+\t\t\tibdev_dbg(to_ibdev(cm_core->iwdev),\n+\t\t\t\t  \"CM: allocate node failed\\n\");\n+\t\t\tatomic_dec(&listener->ref_count);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (!tcph->rst && !tcph->fin) {\n+\t\t\tcm_node->state = IRDMA_CM_STATE_LISTENING;\n+\t\t} else {\n+\t\t\tirdma_rem_ref_cm_node(cm_node);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tatomic_inc(&cm_node->ref_count);\n+\t} else if (cm_node->state == IRDMA_CM_STATE_OFFLOADED) {\n+\t\tirdma_rem_ref_cm_node(cm_node);\n+\t\treturn;\n+\t}\n+\n+\tirdma_process_pkt(cm_node, rbuf);\n+\tirdma_rem_ref_cm_node(cm_node);\n+}\n+\n+static int irdma_cm_create_ah_nop(struct irdma_cm_node *cm_node, bool wait)\n+{\n+\treturn 0;\n+}\n+\n+static void irdma_cm_free_ah_nop(struct irdma_cm_node *cm_node)\n+{\n+}\n+\n+/**\n+ * irdma_setup_cm_core - setup top level instance of a cm core\n+ * @iwdev: iwarp device structure\n+ * @rdma_ver: HW version\n+ */\n+enum irdma_status_code irdma_setup_cm_core(struct irdma_device *iwdev,\n+\t\t\t\t\t   u8 rdma_ver)\n+{\n+\tstruct irdma_cm_core *cm_core = &iwdev->cm_core;\n+\n+\tcm_core->iwdev = iwdev;\n+\tcm_core->dev = &iwdev->rf->sc_dev;\n+\n+\tcm_core->event_wq = alloc_ordered_workqueue(\"iwewq\", WQ_MEM_RECLAIM);\n+\tif (!cm_core->event_wq)\n+\t\treturn IRDMA_ERR_NO_MEMORY;\n+\tcm_core->disconn_wq = alloc_ordered_workqueue(\"iwdwq\", WQ_MEM_RECLAIM);\n+\tif (!cm_core->disconn_wq) {\n+\t\tdestroy_workqueue(cm_core->event_wq);\n+\t\treturn IRDMA_ERR_NO_MEMORY;\n+\t}\n+\n+\tINIT_LIST_HEAD(&cm_core->accelerated_list);\n+\tINIT_LIST_HEAD(&cm_core->non_accelerated_list);\n+\tINIT_LIST_HEAD(&cm_core->listen_nodes);\n+\n+\ttimer_setup(&cm_core->tcp_timer, irdma_cm_timer_tick, 0);\n+\n+\tspin_lock_init(&cm_core->ht_lock);\n+\tspin_lock_init(&cm_core->listen_list_lock);\n+\tspin_lock_init(&cm_core->apbvt_lock);\n+\n+\tswitch (rdma_ver) {\n+\tcase IRDMA_GEN_1:\n+\t\tcm_core->form_cm_frame = irdma_form_uda_cm_frame;\n+\t\tcm_core->cm_create_ah = irdma_cm_create_ah_nop;\n+\t\tcm_core->cm_free_ah = irdma_cm_free_ah_nop;\n+\t\tbreak;\n+\tcase IRDMA_GEN_2:\n+\tdefault:\n+\t\tcm_core->form_cm_frame = irdma_form_ah_cm_frame;\n+\t\tcm_core->cm_create_ah = irdma_cm_create_ah;\n+\t\tcm_core->cm_free_ah = irdma_cm_free_ah;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * irdma_cleanup_cm_core - deallocate a top level instance of a\n+ * cm core\n+ * @cm_core: cm's core\n+ */\n+void irdma_cleanup_cm_core(struct irdma_cm_core *cm_core)\n+{\n+\tunsigned long flags;\n+\n+\tif (!cm_core)\n+\t\treturn;\n+\n+\tspin_lock_irqsave(&cm_core->ht_lock, flags);\n+\tif (timer_pending(&cm_core->tcp_timer))\n+\t\tdel_timer_sync(&cm_core->tcp_timer);\n+\tspin_unlock_irqrestore(&cm_core->ht_lock, flags);\n+\n+\tdestroy_workqueue(cm_core->event_wq);\n+\tdestroy_workqueue(cm_core->disconn_wq);\n+\tcm_core->dev->ws_reset(&cm_core->iwdev->vsi);\n+}\n+\n+/**\n+ * irdma_init_tcp_ctx - setup qp context\n+ * @cm_node: connection's node\n+ * @tcp_info: offload info for tcp\n+ * @iwqp: associate qp for the connection\n+ */\n+static void irdma_init_tcp_ctx(struct irdma_cm_node *cm_node,\n+\t\t\t       struct irdma_tcp_offload_info *tcp_info,\n+\t\t\t       struct irdma_qp *iwqp)\n+{\n+\ttcp_info->ipv4 = cm_node->ipv4;\n+\ttcp_info->drop_ooo_seg = !iwqp->iwdev->rf->ooo;\n+\ttcp_info->wscale = true;\n+\ttcp_info->ignore_tcp_opt = true;\n+\ttcp_info->ignore_tcp_uns_opt = true;\n+\ttcp_info->no_nagle = false;\n+\n+\ttcp_info->ttl = IRDMA_DEFAULT_TTL;\n+\ttcp_info->rtt_var = IRDMA_DEFAULT_RTT_VAR;\n+\ttcp_info->ss_thresh = IRDMA_DEFAULT_SS_THRESH;\n+\ttcp_info->rexmit_thresh = IRDMA_DEFAULT_REXMIT_THRESH;\n+\n+\ttcp_info->tcp_state = IRDMA_TCP_STATE_ESTABLISHED;\n+\ttcp_info->snd_wscale = cm_node->tcp_cntxt.snd_wscale;\n+\ttcp_info->rcv_wscale = cm_node->tcp_cntxt.rcv_wscale;\n+\n+\ttcp_info->snd_nxt = cm_node->tcp_cntxt.loc_seq_num;\n+\ttcp_info->snd_wnd = cm_node->tcp_cntxt.snd_wnd;\n+\ttcp_info->rcv_nxt = cm_node->tcp_cntxt.rcv_nxt;\n+\ttcp_info->snd_max = cm_node->tcp_cntxt.loc_seq_num;\n+\n+\ttcp_info->snd_una = cm_node->tcp_cntxt.loc_seq_num;\n+\ttcp_info->cwnd = 2 * cm_node->tcp_cntxt.mss;\n+\ttcp_info->snd_wl1 = cm_node->tcp_cntxt.rcv_nxt;\n+\ttcp_info->snd_wl2 = cm_node->tcp_cntxt.loc_seq_num;\n+\ttcp_info->max_snd_window = cm_node->tcp_cntxt.max_snd_wnd;\n+\ttcp_info->rcv_wnd = cm_node->tcp_cntxt.rcv_wnd\n+\t\t\t    << cm_node->tcp_cntxt.rcv_wscale;\n+\n+\ttcp_info->flow_label = 0;\n+\ttcp_info->snd_mss = (u32)cm_node->tcp_cntxt.mss;\n+\tif (cm_node->vlan_id < VLAN_N_VID) {\n+\t\ttcp_info->insert_vlan_tag = true;\n+\t\ttcp_info->vlan_tag = cm_node->vlan_id;\n+\t\ttcp_info->vlan_tag |= cm_node->user_pri << VLAN_PRIO_SHIFT;\n+\t\ttcp_info->tos = cm_node->tos;\n+\t}\n+\tif (cm_node->ipv4) {\n+\t\ttcp_info->src_port = cm_node->loc_port;\n+\t\ttcp_info->dst_port = cm_node->rem_port;\n+\n+\t\ttcp_info->dest_ip_addr3 = cm_node->rem_addr[0];\n+\t\ttcp_info->local_ipaddr3 = cm_node->loc_addr[0];\n+\t\ttcp_info->arp_idx = (u16)irdma_arp_table(iwqp->iwdev->rf,\n+\t\t\t\t\t\t\t &tcp_info->dest_ip_addr3,\n+\t\t\t\t\t\t\t true, NULL,\n+\t\t\t\t\t\t\t IRDMA_ARP_RESOLVE);\n+\t} else {\n+\t\ttcp_info->src_port = cm_node->loc_port;\n+\t\ttcp_info->dst_port = cm_node->rem_port;\n+\t\ttcp_info->dest_ip_addr0 = cm_node->rem_addr[0];\n+\t\ttcp_info->dest_ip_addr1 = cm_node->rem_addr[1];\n+\t\ttcp_info->dest_ip_addr2 = cm_node->rem_addr[2];\n+\t\ttcp_info->dest_ip_addr3 = cm_node->rem_addr[3];\n+\t\ttcp_info->local_ipaddr0 = cm_node->loc_addr[0];\n+\t\ttcp_info->local_ipaddr1 = cm_node->loc_addr[1];\n+\t\ttcp_info->local_ipaddr2 = cm_node->loc_addr[2];\n+\t\ttcp_info->local_ipaddr3 = cm_node->loc_addr[3];\n+\t\ttcp_info->arp_idx = (u16)irdma_arp_table(iwqp->iwdev->rf,\n+\t\t\t\t\t\t\t &tcp_info->dest_ip_addr0,\n+\t\t\t\t\t\t\t false, NULL,\n+\t\t\t\t\t\t\t IRDMA_ARP_RESOLVE);\n+\t}\n+}\n+\n+/**\n+ * irdma_cm_init_tsa_conn - setup qp for RTS\n+ * @iwqp: associate qp for the connection\n+ * @cm_node: connection's node\n+ */\n+static void irdma_cm_init_tsa_conn(struct irdma_qp *iwqp,\n+\t\t\t\t   struct irdma_cm_node *cm_node)\n+{\n+\tstruct irdma_iwarp_offload_info *iwarp_info;\n+\tstruct irdma_qp_host_ctx_info *ctx_info;\n+\tstruct irdma_sc_dev *dev = &iwqp->iwdev->rf->sc_dev;\n+\n+\tiwarp_info = &iwqp->iwarp_info;\n+\tctx_info = &iwqp->ctx_info;\n+\n+\tctx_info->tcp_info = &iwqp->tcp_info;\n+\tctx_info->send_cq_num = iwqp->iwscq->sc_cq.cq_uk.cq_id;\n+\tctx_info->rcv_cq_num = iwqp->iwrcq->sc_cq.cq_uk.cq_id;\n+\n+\tiwarp_info->ord_size = cm_node->ord_size;\n+\tiwarp_info->ird_size = irdma_derive_hw_ird_setting(cm_node->ird_size);\n+\tiwarp_info->rd_en = true;\n+\tiwarp_info->rdmap_ver = 1;\n+\tiwarp_info->ddp_ver = 1;\n+\tiwarp_info->pd_id = iwqp->iwpd->sc_pd.pd_id;\n+\n+\tctx_info->tcp_info_valid = true;\n+\tctx_info->iwarp_info_valid = true;\n+\tctx_info->user_pri = cm_node->user_pri;\n+\n+\tirdma_init_tcp_ctx(cm_node, &iwqp->tcp_info, iwqp);\n+\tif (cm_node->snd_mark_en) {\n+\t\tiwarp_info->snd_mark_en = true;\n+\t\tiwarp_info->snd_mark_offset = (iwqp->tcp_info.snd_nxt & SNDMARKER_SEQNMASK) +\n+\t\t\t\t\t      cm_node->lsmm_size;\n+\t}\n+\n+\tcm_node->state = IRDMA_CM_STATE_OFFLOADED;\n+\tiwqp->tcp_info.tcp_state = IRDMA_TCP_STATE_ESTABLISHED;\n+\tiwqp->tcp_info.src_mac_addr_idx = iwqp->iwdev->mac_ip_table_idx;\n+\n+\tdev->iw_priv_qp_ops->qp_setctx(&iwqp->sc_qp, iwqp->host_ctx.va,\n+\t\t\t\t       ctx_info);\n+\n+\t/* once tcp_info is set, no need to do it again */\n+\tctx_info->tcp_info_valid = false;\n+\tctx_info->iwarp_info_valid = false;\n+}\n+\n+/**\n+ * irdma_cm_disconn - when a connection is being closed\n+ * @iwqp: associated qp for the connection\n+ */\n+void irdma_cm_disconn(struct irdma_qp *iwqp)\n+{\n+\tstruct disconn_work *work;\n+\tstruct irdma_device *iwdev = iwqp->iwdev;\n+\tstruct irdma_cm_core *cm_core = &iwdev->cm_core;\n+\tunsigned long flags;\n+\n+\twork = kzalloc(sizeof(*work), GFP_ATOMIC);\n+\tif (!work)\n+\t\treturn;\n+\n+\tspin_lock_irqsave(&iwdev->rf->qptable_lock, flags);\n+\tif (!iwdev->rf->qp_table[iwqp->ibqp.qp_num]) {\n+\t\tspin_unlock_irqrestore(&iwdev->rf->qptable_lock, flags);\n+\t\tibdev_dbg(to_ibdev(iwdev), \"CM: qp_id %d is already freed\\n\",\n+\t\t\t  iwqp->ibqp.qp_num);\n+\t\tkfree(work);\n+\t\treturn;\n+\t}\n+\tirdma_add_ref(&iwqp->ibqp);\n+\tspin_unlock_irqrestore(&iwdev->rf->qptable_lock, flags);\n+\n+\twork->iwqp = iwqp;\n+\tINIT_WORK(&work->work, irdma_disconnect_worker);\n+\tqueue_work(cm_core->disconn_wq, &work->work);\n+}\n+\n+/**\n+ * irdma_qp_disconnect - free qp and close cm\n+ * @iwqp: associate qp for the connection\n+ */\n+static void irdma_qp_disconnect(struct irdma_qp *iwqp)\n+{\n+\tstruct irdma_device *iwdev;\n+\tstruct irdma_ib_device *iwibdev;\n+\n+\tiwdev = iwqp->iwdev;\n+\tiwibdev = iwdev->iwibdev;\n+\n+\tif (iwqp->active_conn) {\n+\t\t/* indicate this connection is NOT active */\n+\t\tiwqp->active_conn = 0;\n+\t} else {\n+\t\t/* Need to free the Last Streaming Mode Message */\n+\t\tif (iwqp->ietf_mem.va) {\n+\t\t\tif (iwqp->lsmm_mr)\n+\t\t\t\tiwibdev->ibdev.ops.dereg_mr(iwqp->lsmm_mr, NULL);\n+\t\t\tdma_free_coherent(hw_to_dev(iwdev->rf->sc_dev.hw),\n+\t\t\t\t\t  iwqp->ietf_mem.size,\n+\t\t\t\t\t  iwqp->ietf_mem.va,\n+\t\t\t\t\t  iwqp->ietf_mem.pa);\n+\t\t\tiwqp->ietf_mem.va = NULL;\n+\t\t}\n+\t}\n+\n+\t/* close the CM node down if it is still active */\n+\tif (iwqp->cm_node) {\n+\t\tibdev_dbg(to_ibdev(iwdev), \"CM: Call close API\\n\");\n+\t\tirdma_cm_close(iwqp->cm_node);\n+\t}\n+}\n+\n+/**\n+ * irdma_cm_disconn_true - called by worker thread to disconnect qp\n+ * @iwqp: associate qp for the connection\n+ */\n+static void irdma_cm_disconn_true(struct irdma_qp *iwqp)\n+{\n+\tstruct iw_cm_id *cm_id;\n+\tstruct irdma_device *iwdev;\n+\tstruct irdma_sc_qp *qp = &iwqp->sc_qp;\n+\tu16 last_ae;\n+\tu8 original_hw_tcp_state;\n+\tu8 original_ibqp_state;\n+\tint disconn_status = 0;\n+\tint issue_disconn = 0;\n+\tint issue_close = 0;\n+\tint issue_flush = 0;\n+\tstruct ib_event ibevent;\n+\tunsigned long flags;\n+\tint err;\n+\n+\tiwdev = iwqp->iwdev;\n+\tspin_lock_irqsave(&iwqp->lock, flags);\n+\tif (rdma_protocol_roce(&iwdev->iwibdev->ibdev, 1)) {\n+\t\tstruct ib_qp_attr attr;\n+\n+\t\tif (iwqp->flush_issued || iwqp->destroyed) {\n+\t\t\tspin_unlock_irqrestore(&iwqp->lock, flags);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tspin_unlock_irqrestore(&iwqp->lock, flags);\n+\n+\t\tattr.qp_state = IB_QPS_ERR;\n+\t\tirdma_modify_qp_roce(&iwqp->ibqp, &attr, IB_QP_STATE, NULL);\n+\t\tif (iwqp->ibqp.event_handler) {\n+\t\t\tibevent.device = iwqp->ibqp.device;\n+\t\t\tibevent.event = IB_EVENT_QP_FATAL;\n+\t\t\tibevent.element.qp = &iwqp->ibqp;\n+\t\t\tiwqp->ibqp.event_handler(&ibevent,\n+\t\t\t\t\t\t iwqp->ibqp.qp_context);\n+\t\t}\n+\t\treturn;\n+\t}\n+\n+\tcm_id = iwqp->cm_id;\n+\t/* make sure we havent already closed this connection */\n+\tif (!cm_id) {\n+\t\tspin_unlock_irqrestore(&iwqp->lock, flags);\n+\t\treturn;\n+\t}\n+\n+\toriginal_hw_tcp_state = iwqp->hw_tcp_state;\n+\toriginal_ibqp_state = iwqp->ibqp_state;\n+\tlast_ae = iwqp->last_aeq;\n+\n+\tif (qp->term_flags) {\n+\t\tissue_disconn = 1;\n+\t\tissue_close = 1;\n+\t\tiwqp->cm_id = NULL;\n+\t\tirdma_terminate_del_timer(qp);\n+\t\tif (!iwqp->flush_issued) {\n+\t\t\tiwqp->flush_issued = 1;\n+\t\t\tissue_flush = 1;\n+\t\t}\n+\t} else if ((original_hw_tcp_state == IRDMA_TCP_STATE_CLOSE_WAIT) ||\n+\t\t   ((original_ibqp_state == IB_QPS_RTS) &&\n+\t\t    (last_ae == IRDMA_AE_LLP_CONNECTION_RESET))) {\n+\t\tissue_disconn = 1;\n+\t\tif (last_ae == IRDMA_AE_LLP_CONNECTION_RESET)\n+\t\t\tdisconn_status = -ECONNRESET;\n+\t}\n+\n+\tif ((original_hw_tcp_state == IRDMA_TCP_STATE_CLOSED ||\n+\t     original_hw_tcp_state == IRDMA_TCP_STATE_TIME_WAIT ||\n+\t     last_ae == IRDMA_AE_RDMAP_ROE_BAD_LLP_CLOSE ||\n+\t     last_ae == IRDMA_AE_LLP_CONNECTION_RESET || iwdev->reset)) {\n+\t\tissue_close = 1;\n+\t\tiwqp->cm_id = NULL;\n+\t\tqp->term_flags = 0;\n+\t\tif (!iwqp->flush_issued) {\n+\t\t\tiwqp->flush_issued = 1;\n+\t\t\tissue_flush = 1;\n+\t\t}\n+\t}\n+\n+\tspin_unlock_irqrestore(&iwqp->lock, flags);\n+\tif (issue_flush && !iwqp->destroyed) {\n+\t\t/* Flush the queues */\n+\t\tirdma_flush_wqes(iwdev->rf, iwqp);\n+\n+\t\tif (qp->term_flags && iwqp->ibqp.event_handler) {\n+\t\t\tibevent.device = iwqp->ibqp.device;\n+\t\t\tibevent.event = (qp->eventtype == TERM_EVENT_QP_FATAL) ?\n+\t\t\t\t\t\tIB_EVENT_QP_FATAL :\n+\t\t\t\t\t\tIB_EVENT_QP_ACCESS_ERR;\n+\t\t\tibevent.element.qp = &iwqp->ibqp;\n+\t\t\tiwqp->ibqp.event_handler(&ibevent,\n+\t\t\t\t\t\t iwqp->ibqp.qp_context);\n+\t\t}\n+\t}\n+\n+\tif (!cm_id || !cm_id->event_handler)\n+\t\treturn;\n+\tif (issue_disconn) {\n+\t\terr = irdma_send_cm_event(NULL, cm_id, IW_CM_EVENT_DISCONNECT,\n+\t\t\t\t\t  disconn_status);\n+\t\tif (err)\n+\t\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t\t  \"CM: disconnect event failed: - cm_id = %p\\n\",\n+\t\t\t\t  cm_id);\n+\t}\n+\tif (issue_close) {\n+\t\tirdma_qp_disconnect(iwqp);\n+\t\tcm_id->provider_data = iwqp;\n+\t\terr = irdma_send_cm_event(NULL, cm_id, IW_CM_EVENT_CLOSE, 0);\n+\t\tif (err)\n+\t\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t\t  \"CM: close event failed: - cm_id = %p\\n\",\n+\t\t\t\t  cm_id);\n+\t\tcm_id->rem_ref(cm_id);\n+\t}\n+}\n+\n+/**\n+ * irdma_disconnect_worker - worker for connection close\n+ * @work: points or disconn structure\n+ */\n+static void irdma_disconnect_worker(struct work_struct *work)\n+{\n+\tstruct disconn_work *dwork = container_of(work, struct disconn_work, work);\n+\tstruct irdma_qp *iwqp = dwork->iwqp;\n+\n+\tkfree(dwork);\n+\tirdma_cm_disconn_true(iwqp);\n+\tirdma_rem_ref(&iwqp->ibqp);\n+}\n+\n+/**\n+ * irdma_accept - registered call for connection to be accepted\n+ * @cm_id: cm information for passive connection\n+ * @conn_param: accpet parameters\n+ */\n+int irdma_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)\n+{\n+\tstruct ib_qp *ibqp;\n+\tstruct irdma_qp *iwqp;\n+\tstruct irdma_device *iwdev;\n+\tstruct irdma_sc_dev *dev;\n+\tstruct irdma_cm_core *cm_core;\n+\tstruct irdma_cm_node *cm_node;\n+\tstruct ib_qp_attr attr = {};\n+\tint passive_state;\n+\tstruct ib_mr *ibmr;\n+\tstruct irdma_pd *iwpd;\n+\tu16 buf_len = 0;\n+\tstruct irdma_kmem_info accept;\n+\tunsigned long flags;\n+\tu64 tagged_offset;\n+\tint wait_ret;\n+\tint ret;\n+\n+\tibqp = irdma_get_qp(cm_id->device, conn_param->qpn);\n+\tif (!ibqp)\n+\t\treturn -EINVAL;\n+\n+\tiwqp = to_iwqp(ibqp);\n+\tiwdev = iwqp->iwdev;\n+\tdev = &iwdev->rf->sc_dev;\n+\tcm_core = &iwdev->cm_core;\n+\tcm_node = cm_id->provider_data;\n+\n+\tif (((struct sockaddr_in *)&cm_id->local_addr)->sin_family == AF_INET) {\n+\t\tcm_node->ipv4 = true;\n+\t\tcm_node->vlan_id = irdma_get_vlan_ipv4(cm_node->loc_addr);\n+\t} else {\n+\t\tcm_node->ipv4 = false;\n+\t\tirdma_netdev_vlan_ipv6(cm_node->loc_addr, &cm_node->vlan_id,\n+\t\t\t\t       NULL);\n+\t}\n+\tibdev_dbg(to_ibdev(iwdev), \"CM: Accept vlan_id=%d\\n\",\n+\t\t  cm_node->vlan_id);\n+\n+\ttrace_irdma_accept(cm_node, 0, NULL);\n+\n+\tif (cm_node->state == IRDMA_CM_STATE_LISTENER_DESTROYED) {\n+\t\tret = -EINVAL;\n+\t\tgoto error;\n+\t}\n+\n+\tpassive_state = atomic_add_return(1, &cm_node->passive_state);\n+\tif (passive_state == IRDMA_SEND_RESET_EVENT) {\n+\t\tret = -ECONNRESET;\n+\t\tgoto error;\n+\t}\n+\n+\tcm_node->cm_core->stats_accepts++;\n+\tiwqp->cm_node = (void *)cm_node;\n+\tcm_node->iwqp = iwqp;\n+\n+\tbuf_len = conn_param->private_data_len + IRDMA_MAX_IETF_SIZE;\n+\n+\tiwqp->ietf_mem.size = ALIGN(buf_len, 1);\n+\tiwqp->ietf_mem.va = dma_alloc_coherent(hw_to_dev(dev->hw),\n+\t\t\t\t\t       iwqp->ietf_mem.size,\n+\t\t\t\t\t       &iwqp->ietf_mem.pa, GFP_KERNEL);\n+\tif (!iwqp->ietf_mem.va) {\n+\t\tret = -ENOMEM;\n+\t\tgoto error;\n+\t}\n+\n+\tcm_node->pdata.size = conn_param->private_data_len;\n+\taccept.addr = iwqp->ietf_mem.va;\n+\taccept.size = irdma_cm_build_mpa_frame(cm_node, &accept, MPA_KEY_REPLY);\n+\tmemcpy(accept.addr + accept.size, conn_param->private_data,\n+\t       conn_param->private_data_len);\n+\n+\tif (cm_node->dev->ws_add(iwqp->sc_qp.vsi, cm_node->user_pri)) {\n+\t\tret = -ENOMEM;\n+\t\tgoto error;\n+\t}\n+\tirdma_qp_add_qos(&iwqp->sc_qp);\n+\n+\t/* setup our first outgoing iWarp send WQE (the IETF frame response) */\n+\tiwpd = iwqp->iwpd;\n+\ttagged_offset = (uintptr_t)iwqp->ietf_mem.va;\n+\tibmr = irdma_reg_phys_mr(&iwpd->ibpd, iwqp->ietf_mem.pa, buf_len,\n+\t\t\t\t IB_ACCESS_LOCAL_WRITE, &tagged_offset);\n+\tif (IS_ERR(ibmr)) {\n+\t\tret = -ENOMEM;\n+\t\tgoto error;\n+\t}\n+\n+\tibmr->pd = &iwpd->ibpd;\n+\tibmr->device = iwpd->ibpd.device;\n+\tiwqp->lsmm_mr = ibmr;\n+\tif (iwqp->page)\n+\t\tiwqp->sc_qp.qp_uk.sq_base = kmap(iwqp->page);\n+\tdev->iw_priv_qp_ops->qp_send_lsmm(&iwqp->sc_qp,\n+\t\t\t\t\t  iwqp->ietf_mem.va,\n+\t\t\t\t\t  (accept.size + conn_param->private_data_len),\n+\t\t\t\t\t  ibmr->lkey);\n+\n+\tif (iwqp->page)\n+\t\tkunmap(iwqp->page);\n+\n+\tiwqp->cm_id = cm_id;\n+\tcm_node->cm_id = cm_id;\n+\n+\tcm_id->provider_data = (void *)iwqp;\n+\tiwqp->active_conn = 0;\n+\n+\tcm_node->lsmm_size = accept.size + conn_param->private_data_len;\n+\n+\tirdma_cm_init_tsa_conn(iwqp, cm_node);\n+\tcm_id->add_ref(cm_id);\n+\tirdma_add_ref(&iwqp->ibqp);\n+\n+\tattr.qp_state = IB_QPS_RTS;\n+\tcm_node->qhash_set = false;\n+\tcm_node->cm_core->cm_free_ah(cm_node);\n+\n+\tirdma_modify_qp(&iwqp->ibqp, &attr, IB_QP_STATE, NULL);\n+\tspin_lock_irqsave(&cm_core->ht_lock, flags);\n+\tlist_move_tail(&cm_node->list, &cm_core->accelerated_list);\n+\tspin_unlock_irqrestore(&cm_core->ht_lock, flags);\n+\n+\tif (dev->hw_attrs.uk_attrs.feature_flags & IRDMA_FEATURE_RTS_AE) {\n+\t\twait_ret = wait_event_interruptible_timeout(iwqp->waitq,\n+\t\t\t\t\t\t\t    iwqp->rts_ae_rcvd,\n+\t\t\t\t\t\t\t    IRDMA_MAX_TIMEOUT);\n+\t\tif (!wait_ret)\n+\t\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t\t  \"CM: Slow Connection: cm_node=%p, loc_port=%d, rem_port=%d, cm_id=%p\\n\",\n+\t\t\t\t  cm_node, cm_node->loc_port,\n+\t\t\t\t  cm_node->rem_port, cm_node->cm_id);\n+\t}\n+\n+\tcm_node->accelerated = true;\n+\tirdma_send_cm_event(cm_node, cm_id, IW_CM_EVENT_ESTABLISHED, 0);\n+\n+\tif (cm_node->accept_pend) {\n+\t\tatomic_dec(&cm_node->listener->pend_accepts_cnt);\n+\t\tcm_node->accept_pend = 0;\n+\t}\n+\n+\tibdev_dbg(to_ibdev(iwdev), \"CM: rem_port=0x%04x, loc_port=0x%04x\\n\",\n+\t\t  cm_node->rem_port, cm_node->loc_port);\n+\n+\treturn 0;\n+error:\n+\tif (iwqp->ietf_mem.va) {\n+\t\tdma_free_coherent(hw_to_dev(dev->hw), iwqp->ietf_mem.size,\n+\t\t\t\t  iwqp->ietf_mem.va, iwqp->ietf_mem.pa);\n+\t\tiwqp->ietf_mem.va = NULL;\n+\t\tiwqp->ietf_mem.va = NULL;\n+\t}\n+\tirdma_rem_ref_cm_node(cm_node);\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * irdma_reject - registered call for connection to be rejected\n+ * @cm_id: cm information for passive connection\n+ * @pdata: private data to be sent\n+ * @pdata_len: private data length\n+ */\n+int irdma_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)\n+{\n+\tstruct irdma_device *iwdev;\n+\tstruct irdma_cm_node *cm_node;\n+\n+\tcm_node = cm_id->provider_data;\n+\tcm_node->cm_id = cm_id;\n+\tcm_node->pdata.size = pdata_len;\n+\n+\ttrace_irdma_reject(cm_node, 0, NULL);\n+\n+\tiwdev = to_iwdev(cm_id->device);\n+\tif (!iwdev)\n+\t\treturn -EINVAL;\n+\n+\tcm_node->cm_core->stats_rejects++;\n+\n+\tif (pdata_len + sizeof(struct ietf_mpa_v2) > IRDMA_MAX_CM_BUF)\n+\t\treturn -EINVAL;\n+\n+\treturn irdma_cm_reject(cm_node, pdata, pdata_len);\n+}\n+\n+/**\n+ * irdma_connect - registered call for connection to be established\n+ * @cm_id: cm information for passive connection\n+ * @conn_param: Information about the connection\n+ */\n+int irdma_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)\n+{\n+\tstruct ib_qp *ibqp;\n+\tstruct irdma_qp *iwqp;\n+\tstruct irdma_device *iwdev;\n+\tstruct irdma_cm_node *cm_node;\n+\tstruct irdma_cm_info cm_info;\n+\tstruct sockaddr_in *laddr;\n+\tstruct sockaddr_in *raddr;\n+\tstruct sockaddr_in6 *laddr6;\n+\tstruct sockaddr_in6 *raddr6;\n+\tint ret = 0;\n+\n+\tibqp = irdma_get_qp(cm_id->device, conn_param->qpn);\n+\tif (!ibqp)\n+\t\treturn -EINVAL;\n+\tiwqp = to_iwqp(ibqp);\n+\tif (!iwqp)\n+\t\treturn -EINVAL;\n+\tiwdev = iwqp->iwdev;\n+\tif (!iwdev)\n+\t\treturn -EINVAL;\n+\n+\tladdr = (struct sockaddr_in *)&cm_id->m_local_addr;\n+\traddr = (struct sockaddr_in *)&cm_id->m_remote_addr;\n+\tladdr6 = (struct sockaddr_in6 *)&cm_id->m_local_addr;\n+\traddr6 = (struct sockaddr_in6 *)&cm_id->m_remote_addr;\n+\n+\tif (!(laddr->sin_port) || !(raddr->sin_port))\n+\t\treturn -EINVAL;\n+\n+\tiwqp->active_conn = 1;\n+\tiwqp->cm_id = NULL;\n+\tcm_id->provider_data = iwqp;\n+\n+\t/* set up the connection params for the node */\n+\tif (cm_id->remote_addr.ss_family == AF_INET) {\n+\t\tif (iwdev->vsi.mtu < IRDMA_MIN_MTU_IPV4)\n+\t\t\treturn -EINVAL;\n+\n+\t\tcm_info.ipv4 = true;\n+\t\tmemset(cm_info.loc_addr, 0, sizeof(cm_info.loc_addr));\n+\t\tmemset(cm_info.rem_addr, 0, sizeof(cm_info.rem_addr));\n+\t\tcm_info.loc_addr[0] = ntohl(laddr->sin_addr.s_addr);\n+\t\tcm_info.rem_addr[0] = ntohl(raddr->sin_addr.s_addr);\n+\t\tcm_info.loc_port = ntohs(laddr->sin_port);\n+\t\tcm_info.rem_port = ntohs(raddr->sin_port);\n+\t\tcm_info.vlan_id = irdma_get_vlan_ipv4(cm_info.loc_addr);\n+\t} else {\n+\t\tif (iwdev->vsi.mtu < IRDMA_MIN_MTU_IPV6)\n+\t\t\treturn -EINVAL;\n+\n+\t\tcm_info.ipv4 = false;\n+\t\tirdma_copy_ip_ntohl(cm_info.loc_addr,\n+\t\t\t\t    laddr6->sin6_addr.in6_u.u6_addr32);\n+\t\tirdma_copy_ip_ntohl(cm_info.rem_addr,\n+\t\t\t\t    raddr6->sin6_addr.in6_u.u6_addr32);\n+\t\tcm_info.loc_port = ntohs(laddr6->sin6_port);\n+\t\tcm_info.rem_port = ntohs(raddr6->sin6_port);\n+\t\tirdma_netdev_vlan_ipv6(cm_info.loc_addr, &cm_info.vlan_id,\n+\t\t\t\t       NULL);\n+\t}\n+\tcm_info.cm_id = cm_id;\n+\tcm_info.qh_qpid = iwdev->vsi.ilq->qp_id;\n+\tcm_info.tos = cm_id->tos;\n+\tcm_info.user_pri = rt_tos2priority(cm_id->tos);\n+\n+\tif (iwqp->sc_qp.dev->ws_add(iwqp->sc_qp.vsi, cm_info.user_pri))\n+\t\treturn -ENOMEM;\n+\tirdma_qp_add_qos(&iwqp->sc_qp);\n+\n+\tibdev_dbg(to_ibdev(iwdev), \"DCB: DCB: TOS:[%d] UP:[%d]\\n\", cm_id->tos,\n+\t\t  cm_info.user_pri);\n+\n+\ttrace_irdma_dcb_tos(iwdev, cm_id->tos, cm_info.user_pri);\n+\n+\tcm_id->add_ref(cm_id);\n+\tret = irdma_create_cm_node(&iwdev->cm_core, iwdev, conn_param, &cm_info,\n+\t\t\t\t   &cm_node);\n+\tif (ret) {\n+\t\tcm_id->rem_ref(cm_id);\n+\t\treturn ret;\n+\t}\n+\tret = cm_node->cm_core->cm_create_ah(cm_node, true);\n+\tif (ret)\n+\t\tgoto err;\n+\tif (irdma_manage_qhash(iwdev, &cm_info,\n+\t\t\t       IRDMA_QHASH_TYPE_TCP_ESTABLISHED,\n+\t\t\t       IRDMA_QHASH_MANAGE_TYPE_ADD, NULL, true)) {\n+\t\tret = -EINVAL;\n+\t\tgoto err;\n+\t}\n+\tcm_node->qhash_set = true;\n+\n+\tif (irdma_manage_apbvt(iwdev, cm_info.loc_port,\n+\t\t\t       IRDMA_MANAGE_APBVT_ADD)) {\n+\t\tret = -EINVAL;\n+\t\tgoto err;\n+\t}\n+\n+\tcm_node->apbvt_set = true;\n+\tiwqp->cm_node = cm_node;\n+\tcm_node->iwqp = iwqp;\n+\tiwqp->cm_id = cm_id;\n+\tirdma_add_ref(&iwqp->ibqp);\n+\n+\tif (cm_node->state != IRDMA_CM_STATE_OFFLOADED) {\n+\t\tcm_node->state = IRDMA_CM_STATE_SYN_SENT;\n+\t\tret = irdma_send_syn(cm_node, 0);\n+\t\tif (ret)\n+\t\t\tgoto err;\n+\t}\n+\n+\tibdev_dbg(to_ibdev(iwdev),\n+\t\t  \"CM: rem_port=0x%04x, loc_port=0x%04x, cm_node=%p, cm_id = %p.\\n\",\n+\t\t  cm_node->rem_port, cm_node->loc_port, cm_node,\n+\t\t  cm_node->cm_id);\n+\n+\ttrace_irdma_connect(cm_node, 0, NULL);\n+\n+\treturn 0;\n+\n+err:\n+\tif (cm_info.ipv4)\n+\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t  \"CM: connect() FAILED: dest addr=%pI4\",\n+\t\t\t  cm_info.rem_addr);\n+\telse\n+\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t  \"CM: connect() FAILED: dest addr=%pI6\",\n+\t\t\t  cm_info.rem_addr);\n+\tirdma_rem_ref_cm_node(cm_node);\n+\tcm_id->rem_ref(cm_id);\n+\tiwdev->cm_core.stats_connect_errs++;\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * irdma_create_listen - registered call creating listener\n+ * @cm_id: cm information for passive connection\n+ * @backlog: to max accept pending count\n+ */\n+int irdma_create_listen(struct iw_cm_id *cm_id, int backlog)\n+{\n+\tstruct irdma_device *iwdev;\n+\tstruct irdma_cm_listener *cm_listen_node;\n+\tstruct irdma_cm_info cm_info = {};\n+\tenum irdma_status_code err;\n+\tstruct sockaddr_in *laddr;\n+\tstruct sockaddr_in6 *laddr6;\n+\tbool wildcard = false;\n+\n+\tiwdev = to_iwdev(cm_id->device);\n+\tif (!iwdev)\n+\t\treturn -EINVAL;\n+\n+\tladdr = (struct sockaddr_in *)&cm_id->m_local_addr;\n+\tladdr6 = (struct sockaddr_in6 *)&cm_id->m_local_addr;\n+\tcm_info.qh_qpid = iwdev->vsi.ilq->qp_id;\n+\n+\tif (laddr->sin_family == AF_INET) {\n+\t\tif (iwdev->vsi.mtu < IRDMA_MIN_MTU_IPV4)\n+\t\t\treturn -EINVAL;\n+\n+\t\tcm_info.ipv4 = true;\n+\t\tcm_info.loc_addr[0] = ntohl(laddr->sin_addr.s_addr);\n+\t\tcm_info.loc_port = ntohs(laddr->sin_port);\n+\n+\t\tif (laddr->sin_addr.s_addr != htonl(INADDR_ANY)) {\n+\t\t\tcm_info.vlan_id = irdma_get_vlan_ipv4(cm_info.loc_addr);\n+\t\t} else {\n+\t\t\tcm_info.vlan_id = 0xFFFF;\n+\t\t\twildcard = true;\n+\t\t}\n+\t} else {\n+\t\tif (iwdev->vsi.mtu < IRDMA_MIN_MTU_IPV6)\n+\t\t\treturn -EINVAL;\n+\n+\t\tcm_info.ipv4 = false;\n+\t\tirdma_copy_ip_ntohl(cm_info.loc_addr,\n+\t\t\t\t    laddr6->sin6_addr.in6_u.u6_addr32);\n+\t\tcm_info.loc_port = ntohs(laddr6->sin6_port);\n+\t\tif (ipv6_addr_type(&laddr6->sin6_addr) != IPV6_ADDR_ANY) {\n+\t\t\tirdma_netdev_vlan_ipv6(cm_info.loc_addr,\n+\t\t\t\t\t       &cm_info.vlan_id, NULL);\n+\t\t} else {\n+\t\t\tcm_info.vlan_id = 0xFFFF;\n+\t\t\twildcard = true;\n+\t\t}\n+\t}\n+\n+\tif (cm_info.vlan_id >= VLAN_N_VID && iwdev->dcb)\n+\t\tcm_info.vlan_id = 0;\n+\tcm_info.backlog = backlog;\n+\tcm_info.cm_id = cm_id;\n+\n+\ttrace_irdma_create_listen(iwdev, &cm_info);\n+\n+\tcm_listen_node = irdma_make_listen_node(&iwdev->cm_core, iwdev,\n+\t\t\t\t\t\t&cm_info);\n+\tif (!cm_listen_node) {\n+\t\tibdev_dbg(to_ibdev(iwdev), \"CM: cm_listen_node == NULL\\n\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tcm_id->provider_data = cm_listen_node;\n+\n+\tcm_listen_node->tos = cm_id->tos;\n+\tcm_listen_node->user_pri = rt_tos2priority(cm_id->tos);\n+\tcm_info.user_pri = cm_listen_node->user_pri;\n+\tif (!cm_listen_node->reused_node) {\n+\t\tif (wildcard) {\n+\t\t\tif (cm_info.ipv4)\n+\t\t\t\terr = irdma_add_mqh_4(iwdev, &cm_info,\n+\t\t\t\t\t\t      cm_listen_node);\n+\t\t\telse\n+\t\t\t\terr = irdma_add_mqh_6(iwdev, &cm_info,\n+\t\t\t\t\t\t      cm_listen_node);\n+\t\t\tif (err)\n+\t\t\t\tgoto error;\n+\n+\t\t\terr = irdma_manage_apbvt(iwdev, cm_info.loc_port,\n+\t\t\t\t\t\t IRDMA_MANAGE_APBVT_ADD);\n+\n+\t\t\tif (err)\n+\t\t\t\tgoto error;\n+\t\t} else {\n+\t\t\terr = irdma_manage_qhash(iwdev, &cm_info,\n+\t\t\t\t\t\t IRDMA_QHASH_TYPE_TCP_SYN,\n+\t\t\t\t\t\t IRDMA_QHASH_MANAGE_TYPE_ADD,\n+\t\t\t\t\t\t NULL, true);\n+\t\t\tif (err)\n+\t\t\t\tgoto error;\n+\n+\t\t\tcm_listen_node->qhash_set = true;\n+\t\t\terr = irdma_manage_apbvt(iwdev, cm_info.loc_port,\n+\t\t\t\t\t\t IRDMA_MANAGE_APBVT_ADD);\n+\t\t\tif (err)\n+\t\t\t\tgoto error;\n+\t\t}\n+\t}\n+\tcm_id->add_ref(cm_id);\n+\tcm_listen_node->cm_core->stats_listen_created++;\n+\treturn 0;\n+\n+error:\n+\n+\tirdma_cm_del_listen(&iwdev->cm_core, (void *)cm_listen_node, false);\n+\n+\treturn -EINVAL;\n+}\n+\n+/**\n+ * irdma_destroy_listen - registered call to destroy listener\n+ * @cm_id: cm information for passive connection\n+ */\n+int irdma_destroy_listen(struct iw_cm_id *cm_id)\n+{\n+\tstruct irdma_device *iwdev;\n+\n+\tiwdev = to_iwdev(cm_id->device);\n+\tif (cm_id->provider_data)\n+\t\tirdma_cm_del_listen(&iwdev->cm_core, cm_id->provider_data,\n+\t\t\t\t    true);\n+\telse\n+\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t  \"CM: cm_id->provider_data was NULL\\n\");\n+\n+\tcm_id->rem_ref(cm_id);\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * irdma_cm_event_connected - handle connected active node\n+ * @event: the info for cm_node of connection\n+ */\n+static void irdma_cm_event_connected(struct irdma_cm_event *event)\n+{\n+\tstruct irdma_qp *iwqp;\n+\tstruct irdma_device *iwdev;\n+\tstruct irdma_cm_core *cm_core;\n+\tstruct irdma_cm_node *cm_node;\n+\tstruct irdma_sc_dev *dev;\n+\tstruct ib_qp_attr attr = {};\n+\tstruct iw_cm_id *cm_id;\n+\tunsigned long flags;\n+\tint status;\n+\tbool read0;\n+\tint wait_ret = 0;\n+\n+\tcm_node = event->cm_node;\n+\tcm_id = cm_node->cm_id;\n+\tiwqp = cm_id->provider_data;\n+\tiwdev = iwqp->iwdev;\n+\tdev = &iwdev->rf->sc_dev;\n+\tcm_core = &iwdev->cm_core;\n+\n+\tif (iwqp->destroyed) {\n+\t\tstatus = -ETIMEDOUT;\n+\t\tgoto error;\n+\t}\n+\n+\tirdma_cm_init_tsa_conn(iwqp, cm_node);\n+\tread0 = (cm_node->send_rdma0_op == SEND_RDMA_READ_ZERO);\n+\tif (iwqp->page)\n+\t\tiwqp->sc_qp.qp_uk.sq_base = kmap(iwqp->page);\n+\tdev->iw_priv_qp_ops->qp_send_rtt(&iwqp->sc_qp, read0);\n+\tif (iwqp->page)\n+\t\tkunmap(iwqp->page);\n+\n+\tattr.qp_state = IB_QPS_RTS;\n+\tcm_node->qhash_set = false;\n+\tirdma_modify_qp(&iwqp->ibqp, &attr, IB_QP_STATE, NULL);\n+\tspin_lock_irqsave(&cm_core->ht_lock, flags);\n+\tlist_move_tail(&cm_node->list, &cm_core->accelerated_list);\n+\tspin_unlock_irqrestore(&cm_core->ht_lock, flags);\n+\n+\tif (dev->hw_attrs.uk_attrs.feature_flags & IRDMA_FEATURE_RTS_AE) {\n+\t\twait_ret = wait_event_interruptible_timeout(iwqp->waitq,\n+\t\t\t\t\t\t\t    iwqp->rts_ae_rcvd,\n+\t\t\t\t\t\t\t    IRDMA_MAX_TIMEOUT);\n+\t\tif (!wait_ret)\n+\t\t\tibdev_dbg(to_ibdev(iwdev),\n+\t\t\t\t  \"CM: Slow Connection: cm_node=%p, loc_port=%d, rem_port=%d, cm_id=%p\\n\",\n+\t\t\t\t  cm_node, cm_node->loc_port,\n+\t\t\t\t  cm_node->rem_port, cm_node->cm_id);\n+\t}\n+\n+\tcm_node->accelerated = true;\n+\tirdma_send_cm_event(cm_node, cm_id, IW_CM_EVENT_CONNECT_REPLY, 0);\n+\tcm_node->cm_core->cm_free_ah(cm_node);\n+\treturn;\n+\n+error:\n+\tiwqp->cm_id = NULL;\n+\tcm_id->provider_data = NULL;\n+\tirdma_send_cm_event(event->cm_node, cm_id, IW_CM_EVENT_CONNECT_REPLY,\n+\t\t\t    status);\n+\tcm_id->rem_ref(cm_id);\n+\tirdma_rem_ref_cm_node(event->cm_node);\n+}\n+\n+/**\n+ * irdma_cm_event_reset - handle reset\n+ * @event: the info for cm_node of connection\n+ */\n+static void irdma_cm_event_reset(struct irdma_cm_event *event)\n+{\n+\tstruct irdma_cm_node *cm_node = event->cm_node;\n+\tstruct iw_cm_id *cm_id = cm_node->cm_id;\n+\tstruct irdma_qp *iwqp;\n+\n+\tif (!cm_id)\n+\t\treturn;\n+\n+\tiwqp = cm_id->provider_data;\n+\tif (!iwqp)\n+\t\treturn;\n+\n+\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t  \"CM: reset event %p - cm_id = %p\\n\", event->cm_node, cm_id);\n+\tiwqp->cm_id = NULL;\n+\n+\tirdma_send_cm_event(cm_node, cm_node->cm_id, IW_CM_EVENT_DISCONNECT,\n+\t\t\t    -ECONNRESET);\n+\tirdma_send_cm_event(cm_node, cm_node->cm_id, IW_CM_EVENT_CLOSE, 0);\n+}\n+\n+/**\n+ * irdma_cm_event_handler - send event to cm upper layer\n+ * @work: pointer of cm event info.\n+ */\n+static void irdma_cm_event_handler(struct work_struct *work)\n+{\n+\tstruct irdma_cm_event *event = container_of(work, struct irdma_cm_event, event_work);\n+\tstruct irdma_cm_node *cm_node;\n+\n+\tif (!event || !event->cm_node || !event->cm_node->cm_core)\n+\t\treturn;\n+\n+\tcm_node = event->cm_node;\n+\ttrace_irdma_cm_event_handler(cm_node, event->type, NULL);\n+\n+\tswitch (event->type) {\n+\tcase IRDMA_CM_EVENT_MPA_REQ:\n+\t\tirdma_send_cm_event(cm_node, cm_node->cm_id,\n+\t\t\t\t    IW_CM_EVENT_CONNECT_REQUEST, 0);\n+\t\tbreak;\n+\tcase IRDMA_CM_EVENT_RESET:\n+\t\tirdma_cm_event_reset(event);\n+\t\tbreak;\n+\tcase IRDMA_CM_EVENT_CONNECTED:\n+\t\tif (!event->cm_node->cm_id ||\n+\t\t    event->cm_node->state != IRDMA_CM_STATE_OFFLOADED)\n+\t\t\tbreak;\n+\t\tirdma_cm_event_connected(event);\n+\t\tbreak;\n+\tcase IRDMA_CM_EVENT_MPA_REJECT:\n+\t\tif (!event->cm_node->cm_id ||\n+\t\t    cm_node->state == IRDMA_CM_STATE_OFFLOADED)\n+\t\t\tbreak;\n+\t\tirdma_send_cm_event(cm_node, cm_node->cm_id,\n+\t\t\t\t    IW_CM_EVENT_CONNECT_REPLY, -ECONNREFUSED);\n+\t\tbreak;\n+\tcase IRDMA_CM_EVENT_ABORTED:\n+\t\tif (!event->cm_node->cm_id ||\n+\t\t    event->cm_node->state == IRDMA_CM_STATE_OFFLOADED)\n+\t\t\tbreak;\n+\t\tirdma_event_connect_error(event);\n+\t\tbreak;\n+\tdefault:\n+\t\tibdev_dbg(to_ibdev(cm_node->iwdev),\n+\t\t\t  \"CM: bad event type = %d\\n\", event->type);\n+\t\tbreak;\n+\t}\n+\n+\tevent->cm_info.cm_id->rem_ref(event->cm_info.cm_id);\n+\tirdma_rem_ref_cm_node(event->cm_node);\n+\tkfree(event);\n+}\n+\n+/**\n+ * irdma_cm_post_event - queue event request for worker thread\n+ * @event: cm node's info for up event call\n+ */\n+static void irdma_cm_post_event(struct irdma_cm_event *event)\n+{\n+\tatomic_inc(&event->cm_node->ref_count);\n+\tevent->cm_info.cm_id->add_ref(event->cm_info.cm_id);\n+\tINIT_WORK(&event->event_work, irdma_cm_event_handler);\n+\tqueue_work(event->cm_node->cm_core->event_wq, &event->event_work);\n+}\n+\n+/**\n+ * irdma_qhash_ctrl - enable/disable qhash for list\n+ * @iwdev: device pointer\n+ * @parent_listen_node: parent listen node\n+ * @nfo: cm info node\n+ * @ipaddr: Pointer to IPv4 or IPv6 address\n+ * @ipv4: flag indicating IPv4 when true\n+ * @ifup: flag indicating interface up when true\n+ *\n+ * Enables or disables the qhash for the node in the child\n+ * listen list that matches ipaddr. If no matching IP was found\n+ * it will allocate and add a new child listen node to the\n+ * parent listen node. The listen_list_lock is assumed to be\n+ * held when called.\n+ */\n+static void irdma_qhash_ctrl(struct irdma_device *iwdev,\n+\t\t\t     struct irdma_cm_listener *parent_listen_node,\n+\t\t\t     struct irdma_cm_info *nfo, u32 *ipaddr, bool ipv4,\n+\t\t\t     bool ifup)\n+{\n+\tstruct list_head *child_listen_list = &parent_listen_node->child_listen_list;\n+\tstruct irdma_cm_listener *child_listen_node;\n+\tstruct list_head *pos, *tpos;\n+\tenum irdma_status_code err;\n+\tbool node_allocated = false;\n+\tenum irdma_quad_hash_manage_type op = ifup ?\n+\t\t\t\t\t      IRDMA_QHASH_MANAGE_TYPE_ADD :\n+\t\t\t\t\t      IRDMA_QHASH_MANAGE_TYPE_DELETE;\n+\n+\tlist_for_each_safe (pos, tpos, child_listen_list) {\n+\t\tchild_listen_node = list_entry(pos, struct irdma_cm_listener,\n+\t\t\t\t\t       child_listen_list);\n+\t\tif (!memcmp(child_listen_node->loc_addr, ipaddr, ipv4 ? 4 : 16))\n+\t\t\tgoto set_qhash;\n+\t}\n+\n+\t/* if not found then add a child listener if interface is going up */\n+\tif (!ifup)\n+\t\treturn;\n+\tchild_listen_node = kmemdup(parent_listen_node,\n+\t\t\t\t    sizeof(*child_listen_node), GFP_ATOMIC);\n+\tif (!child_listen_node)\n+\t\treturn;\n+\n+\tnode_allocated = true;\n+\tmemcpy(child_listen_node->loc_addr, ipaddr, ipv4 ? 4 : 16);\n+\n+set_qhash:\n+\tmemcpy(nfo->loc_addr, child_listen_node->loc_addr,\n+\t       sizeof(nfo->loc_addr));\n+\tnfo->vlan_id = child_listen_node->vlan_id;\n+\terr = irdma_manage_qhash(iwdev, nfo, IRDMA_QHASH_TYPE_TCP_SYN, op, NULL,\n+\t\t\t\t false);\n+\tif (!err) {\n+\t\tchild_listen_node->qhash_set = ifup;\n+\t\tif (node_allocated)\n+\t\t\tlist_add(&child_listen_node->child_listen_list,\n+\t\t\t\t &parent_listen_node->child_listen_list);\n+\t} else if (node_allocated) {\n+\t\tkfree(child_listen_node);\n+\t}\n+}\n+\n+/**\n+ * irdma_cm_teardown_connections - teardown QPs\n+ * @iwdev: device pointer\n+ * @ipaddr: Pointer to IPv4 or IPv6 address\n+ * @nfo: Connection info\n+ * @disconnect_all: flag indicating disconnect all QPs\n+ *\n+ * teardown QPs where source or destination addr matches ip addr\n+ */\n+void irdma_cm_teardown_connections(struct irdma_device *iwdev, u32 *ipaddr,\n+\t\t\t\t   struct irdma_cm_info *nfo,\n+\t\t\t\t   bool disconnect_all)\n+{\n+\tstruct irdma_cm_core *cm_core = &iwdev->cm_core;\n+\tstruct list_head *list_core_temp;\n+\tstruct list_head *list_node;\n+\tstruct irdma_cm_node *cm_node;\n+\tstruct list_head teardown_list;\n+\tstruct ib_qp_attr attr;\n+\tstruct irdma_sc_vsi *vsi = &iwdev->vsi;\n+\tstruct irdma_sc_qp *sc_qp;\n+\tstruct irdma_qp *qp;\n+\tint i;\n+\tunsigned long flags;\n+\n+\tINIT_LIST_HEAD(&teardown_list);\n+\n+\tspin_lock_irqsave(&cm_core->ht_lock, flags);\n+\tlist_for_each_safe (list_node, list_core_temp,\n+\t\t\t    &cm_core->accelerated_list) {\n+\t\tcm_node = container_of(list_node, struct irdma_cm_node, list);\n+\t\tif (disconnect_all ||\n+\t\t    (nfo->vlan_id == cm_node->vlan_id &&\n+\t\t     !memcmp(cm_node->loc_addr, ipaddr, nfo->ipv4 ? 4 : 16))) {\n+\t\t\tatomic_inc(&cm_node->ref_count);\n+\t\t\tlist_add(&cm_node->teardown_entry, &teardown_list);\n+\t\t}\n+\t}\n+\tlist_for_each_safe (list_node, list_core_temp,\n+\t\t\t    &cm_core->non_accelerated_list) {\n+\t\tcm_node = container_of(list_node, struct irdma_cm_node, list);\n+\t\tif (disconnect_all ||\n+\t\t    (nfo->vlan_id == cm_node->vlan_id &&\n+\t\t     !memcmp(cm_node->loc_addr, ipaddr, nfo->ipv4 ? 4 : 16))) {\n+\t\t\tatomic_inc(&cm_node->ref_count);\n+\t\t\tlist_add(&cm_node->teardown_entry, &teardown_list);\n+\t\t}\n+\t}\n+\tspin_unlock_irqrestore(&cm_core->ht_lock, flags);\n+\n+\tlist_for_each_safe (list_node, list_core_temp, &teardown_list) {\n+\t\tcm_node = container_of(list_node, struct irdma_cm_node,\n+\t\t\t\t       teardown_entry);\n+\t\tattr.qp_state = IB_QPS_ERR;\n+\t\tirdma_modify_qp(&cm_node->iwqp->ibqp, &attr, IB_QP_STATE, NULL);\n+\t\tif (iwdev->reset)\n+\t\t\tirdma_cm_disconn(cm_node->iwqp);\n+\t\tirdma_rem_ref_cm_node(cm_node);\n+\t}\n+\tif (!iwdev->roce_mode)\n+\t\treturn;\n+\n+\tINIT_LIST_HEAD(&teardown_list);\n+\tfor (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++) {\n+\t\tspin_lock_irqsave(&vsi->qos[i].lock, flags);\n+\t\tlist_for_each_safe (list_node, list_core_temp,\n+\t\t\t\t    &vsi->qos[i].qplist) {\n+\t\t\tu32 qp_ip[4];\n+\n+\t\t\tsc_qp = container_of(list_node, struct irdma_sc_qp,\n+\t\t\t\t\t     list);\n+\t\t\tif (sc_qp->qp_type != IRDMA_QP_TYPE_ROCE_RC)\n+\t\t\t\tcontinue;\n+\n+\t\t\tqp = sc_qp->qp_uk.back_qp;\n+\t\t\tif (!disconnect_all) {\n+\t\t\t\tif (nfo->ipv4)\n+\t\t\t\t\tqp_ip[0] = qp->udp_info.local_ipaddr3;\n+\t\t\t\telse\n+\t\t\t\t\tmemcpy(qp_ip,\n+\t\t\t\t\t       &qp->udp_info.local_ipaddr0,\n+\t\t\t\t\t       sizeof(qp_ip));\n+\t\t\t}\n+\n+\t\t\tif (disconnect_all ||\n+\t\t\t    (nfo->vlan_id == (qp->udp_info.vlan_tag & VLAN_VID_MASK) &&\n+\t\t\t     !memcmp(qp_ip, ipaddr, nfo->ipv4 ? 4 : 16))) {\n+\t\t\t\tspin_lock(&iwdev->rf->qptable_lock);\n+\t\t\t\tif (iwdev->rf->qp_table[sc_qp->qp_uk.qp_id]) {\n+\t\t\t\t\tirdma_add_ref(&qp->ibqp);\n+\t\t\t\t\tlist_add(&qp->teardown_entry,\n+\t\t\t\t\t\t &teardown_list);\n+\t\t\t\t}\n+\t\t\t\tspin_unlock(&iwdev->rf->qptable_lock);\n+\t\t\t}\n+\t\t}\n+\t\tspin_unlock_irqrestore(&vsi->qos[i].lock, flags);\n+\t}\n+\n+\tlist_for_each_safe (list_node, list_core_temp, &teardown_list) {\n+\t\tqp = container_of(list_node, struct irdma_qp, teardown_entry);\n+\t\tattr.qp_state = IB_QPS_ERR;\n+\t\tirdma_modify_qp_roce(&qp->ibqp, &attr, IB_QP_STATE, NULL);\n+\t\tirdma_rem_ref(&qp->ibqp);\n+\t}\n+}\n+\n+/**\n+ * irdma_ifdown_notify - process an ifdown on an interface\n+ * @iwdev: device pointer\n+ * @netdev: network device structure\n+ * @ipaddr: Pointer to IPv4 or IPv6 address\n+ * @ipv4: flag indicating IPv4 when true\n+ * @ifup: flag indicating interface up when true\n+ */\n+void irdma_if_notify(struct irdma_device *iwdev, struct net_device *netdev,\n+\t\t     u32 *ipaddr, bool ipv4, bool ifup)\n+{\n+\tstruct irdma_cm_core *cm_core = &iwdev->cm_core;\n+\tunsigned long flags;\n+\tstruct irdma_cm_listener *listen_node;\n+\tstatic const u32 ip_zero[4] = { 0, 0, 0, 0 };\n+\tstruct irdma_cm_info nfo;\n+\tu16 vlan_id = rdma_vlan_dev_vlan_id(netdev);\n+\tenum irdma_quad_hash_manage_type op = ifup ?\n+\t\t\t\t\t      IRDMA_QHASH_MANAGE_TYPE_ADD :\n+\t\t\t\t\t      IRDMA_QHASH_MANAGE_TYPE_DELETE;\n+\n+\tnfo.vlan_id = vlan_id;\n+\tnfo.ipv4 = ipv4;\n+\n+\t/* Disable or enable qhash for listeners */\n+\tspin_lock_irqsave(&cm_core->listen_list_lock, flags);\n+\tlist_for_each_entry (listen_node, &cm_core->listen_nodes, list) {\n+\t\tif (vlan_id != listen_node->vlan_id ||\n+\t\t    (memcmp(listen_node->loc_addr, ipaddr, ipv4 ? 4 : 16) &&\n+\t\t     memcmp(listen_node->loc_addr, ip_zero, ipv4 ? 4 : 16)))\n+\t\t\tcontinue;\n+\n+\t\tmemcpy(nfo.loc_addr, listen_node->loc_addr,\n+\t\t       sizeof(nfo.loc_addr));\n+\t\tnfo.loc_port = listen_node->loc_port;\n+\t\tnfo.user_pri = listen_node->user_pri;\n+\t\tif (!list_empty(&listen_node->child_listen_list)) {\n+\t\t\tirdma_qhash_ctrl(iwdev, listen_node, &nfo, ipaddr, ipv4,\n+\t\t\t\t\t ifup);\n+\t\t} else if (memcmp(listen_node->loc_addr, ip_zero,\n+\t\t\t\t  ipv4 ? 4 : 16)) {\n+\t\t\tif (!irdma_manage_qhash(iwdev, &nfo,\n+\t\t\t\t\t\tIRDMA_QHASH_TYPE_TCP_SYN, op,\n+\t\t\t\t\t\tNULL, false))\n+\t\t\t\tlisten_node->qhash_set = ifup;\n+\t\t}\n+\t}\n+\tspin_unlock_irqrestore(&cm_core->listen_list_lock, flags);\n+\n+\t/* disconnect any connected qp's on ifdown */\n+\tif (!ifup)\n+\t\tirdma_cm_teardown_connections(iwdev, ipaddr, &nfo, false);\n+}\ndiff --git a/drivers/infiniband/hw/irdma/cm.h b/drivers/infiniband/hw/irdma/cm.h\nnew file mode 100644\nindex 0000000..7cf531a\n--- /dev/null\n+++ b/drivers/infiniband/hw/irdma/cm.h\n@@ -0,0 +1,415 @@\n+/* SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB */\n+/* Copyright (c) 2019, Intel Corporation. */\n+\n+#ifndef IRDMA_CM_H\n+#define IRDMA_CM_H\n+\n+#define IRDMA_MANAGE_APBVT_DEL\t0\n+#define IRDMA_MANAGE_APBVT_ADD\t1\n+\n+#define IRDMA_MPA_REQUEST_ACCEPT\t1\n+#define IRDMA_MPA_REQUEST_REJECT\t2\n+\n+/* IETF MPA -- defines */\n+#define IEFT_MPA_KEY_REQ\t\"MPA ID Req Frame\"\n+#define IEFT_MPA_KEY_REP\t\"MPA ID Rep Frame\"\n+#define IETF_MPA_KEY_SIZE\t16\n+#define IETF_MPA_VER\t\t1\n+#define IETF_MAX_PRIV_DATA_LEN\t512\n+#define IETF_MPA_FRAME_SIZE\t20\n+#define IETF_RTR_MSG_SIZE\t4\n+#define IETF_MPA_V2_FLAG\t0x10\n+#define SNDMARKER_SEQNMASK\t0x000001ff\n+#define IRDMA_MAX_IETF_SIZE\t32\n+\n+/* IETF RTR MSG Fields */\n+#define IETF_PEER_TO_PEER\t0x8000\n+#define IETF_FLPDU_ZERO_LEN\t0x4000\n+#define IETF_RDMA0_WRITE\t0x8000\n+#define IETF_RDMA0_READ\t\t0x4000\n+#define IETF_NO_IRD_ORD\t\t0x3fff\n+\n+/* HW-supported IRD sizes*/\n+#define\tIRDMA_HW_IRD_SETTING_2\t\t2\n+#define\tIRDMA_HW_IRD_SETTING_4\t\t4\n+#define\tIRDMA_HW_IRD_SETTING_8\t\t8\n+#define\tIRDMA_HW_IRD_SETTING_16\t\t16\n+#define\tIRDMA_HW_IRD_SETTING_32\t\t32\n+#define\tIRDMA_HW_IRD_SETTING_64\t\t64\n+#define\tIRDMA_HW_IRD_SETTING_128\t128\n+\n+#define MAX_PORTS\t65536\n+\n+#define IRDMA_PASSIVE_STATE_INDICATED\t0\n+#define IRDMA_DO_NOT_SEND_RESET_EVENT\t1\n+#define IRDMA_SEND_RESET_EVENT\t\t2\n+\n+#define MAX_IRDMA_IFS\t4\n+\n+#define SET_ACK\t\t1\n+#define SET_SYN\t\t2\n+#define SET_FIN\t\t4\n+#define SET_RST\t\t8\n+\n+#define TCP_OPTIONS_PADDING\t3\n+\n+#define IRDMA_DEFAULT_RETRYS\t64\n+#define IRDMA_DEFAULT_RETRANS\t8\n+#define IRDMA_DEFAULT_TTL\t\t0x40\n+#define IRDMA_DEFAULT_RTT_VAR\t\t6\n+#define IRDMA_DEFAULT_SS_THRESH\t\t0x3fffffff\n+#define IRDMA_DEFAULT_REXMIT_THRESH\t8\n+\n+#define IRDMA_RETRY_TIMEOUT\tHZ\n+#define IRDMA_SHORT_TIME\t10\n+#define IRDMA_LONG_TIME\t\t(2 * HZ)\n+#define IRDMA_MAX_TIMEOUT\t((unsigned long)(12 * HZ))\n+\n+#define IRDMA_CM_HASHTABLE_SIZE\t\t1024\n+#define IRDMA_CM_TCP_TIMER_INTERVAL\t3000\n+#define IRDMA_CM_DEFAULT_MTU\t\t1540\n+#define IRDMA_CM_DEFAULT_FRAME_CNT\t10\n+#define IRDMA_CM_THREAD_STACK_SIZE\t256\n+#define IRDMA_CM_DEFAULT_RCV_WND\t64240\n+#define IRDMA_CM_DEFAULT_RCV_WND_SCALED\t0x3fffc\n+#define IRDMA_CM_DEFAULT_RCV_WND_SCALE\t2\n+#define IRDMA_CM_DEFAULT_FREE_PKTS\t10\n+#define IRDMA_CM_FREE_PKT_LO_WATERMARK\t2\n+#define IRDMA_CM_DEFAULT_MSS\t\t536\n+#define IRDMA_CM_DEFAULT_MPA_VER\t2\n+#define IRDMA_CM_DEFAULT_SEQ\t\t0x159bf75f\n+#define IRDMA_CM_DEFAULT_LOCAL_ID\t0x3b47\n+#define IRDMA_CM_DEFAULT_SEQ2\t\t0x18ed5740\n+#define IRDMA_CM_DEFAULT_LOCAL_ID2\t0xb807\n+#define IRDMA_MAX_CM_BUF\t\t(IRDMA_MAX_IETF_SIZE + IETF_MAX_PRIV_DATA_LEN)\n+\n+enum ietf_mpa_flags {\n+\tIETF_MPA_FLAGS_REJECT  = 0x20,\n+\tIETF_MPA_FLAGS_CRC     = 0x40,\n+\tIETF_MPA_FLAGS_MARKERS = 0x80,\n+};\n+\n+enum irdma_timer_type {\n+\tIRDMA_TIMER_TYPE_SEND,\n+\tIRDMA_TIMER_TYPE_CLOSE,\n+};\n+\n+enum option_nums {\n+\tOPTION_NUM_EOL,\n+\tOPTION_NUM_NONE,\n+\tOPTION_NUM_MSS,\n+\tOPTION_NUM_WINDOW_SCALE,\n+\tOPTION_NUM_SACK_PERM,\n+\tOPTION_NUM_SACK,\n+\tOPTION_NUM_WRITE0 = 0xbc,\n+};\n+\n+/* cm node transition states */\n+enum irdma_cm_node_state {\n+\tIRDMA_CM_STATE_UNKNOWN,\n+\tIRDMA_CM_STATE_INITED,\n+\tIRDMA_CM_STATE_LISTENING,\n+\tIRDMA_CM_STATE_SYN_RCVD,\n+\tIRDMA_CM_STATE_SYN_SENT,\n+\tIRDMA_CM_STATE_ONE_SIDE_ESTABLISHED,\n+\tIRDMA_CM_STATE_ESTABLISHED,\n+\tIRDMA_CM_STATE_ACCEPTING,\n+\tIRDMA_CM_STATE_MPAREQ_SENT,\n+\tIRDMA_CM_STATE_MPAREQ_RCVD,\n+\tIRDMA_CM_STATE_MPAREJ_RCVD,\n+\tIRDMA_CM_STATE_OFFLOADED,\n+\tIRDMA_CM_STATE_FIN_WAIT1,\n+\tIRDMA_CM_STATE_FIN_WAIT2,\n+\tIRDMA_CM_STATE_CLOSE_WAIT,\n+\tIRDMA_CM_STATE_TIME_WAIT,\n+\tIRDMA_CM_STATE_LAST_ACK,\n+\tIRDMA_CM_STATE_CLOSING,\n+\tIRDMA_CM_STATE_LISTENER_DESTROYED,\n+\tIRDMA_CM_STATE_CLOSED,\n+};\n+\n+enum mpa_frame_ver {\n+\tIETF_MPA_V1 = 1,\n+\tIETF_MPA_V2 = 2,\n+};\n+\n+enum mpa_frame_key {\n+\tMPA_KEY_REQUEST,\n+\tMPA_KEY_REPLY,\n+};\n+\n+enum send_rdma0 {\n+\tSEND_RDMA_READ_ZERO  = 1,\n+\tSEND_RDMA_WRITE_ZERO = 2,\n+};\n+\n+enum irdma_tcpip_pkt_type {\n+\tIRDMA_PKT_TYPE_UNKNOWN,\n+\tIRDMA_PKT_TYPE_SYN,\n+\tIRDMA_PKT_TYPE_SYNACK,\n+\tIRDMA_PKT_TYPE_ACK,\n+\tIRDMA_PKT_TYPE_FIN,\n+\tIRDMA_PKT_TYPE_RST,\n+};\n+\n+enum irdma_cm_listener_state {\n+\tIRDMA_CM_LISTENER_PASSIVE_STATE = 1,\n+\tIRDMA_CM_LISTENER_ACTIVE_STATE  = 2,\n+\tIRDMA_CM_LISTENER_EITHER_STATE  = 3,\n+};\n+\n+/* CM event codes */\n+enum irdma_cm_event_type {\n+\tIRDMA_CM_EVENT_UNKNOWN,\n+\tIRDMA_CM_EVENT_ESTABLISHED,\n+\tIRDMA_CM_EVENT_MPA_REQ,\n+\tIRDMA_CM_EVENT_MPA_CONNECT,\n+\tIRDMA_CM_EVENT_MPA_ACCEPT,\n+\tIRDMA_CM_EVENT_MPA_REJECT,\n+\tIRDMA_CM_EVENT_MPA_ESTABLISHED,\n+\tIRDMA_CM_EVENT_CONNECTED,\n+\tIRDMA_CM_EVENT_RESET,\n+\tIRDMA_CM_EVENT_ABORTED,\n+};\n+\n+struct irdma_bth { /* Base Trasnport Header */\n+\tu8 opcode;\n+\tu8 flags;\n+\t__be16 pkey;\n+\t__be32 qpn;\n+\t__be32 apsn;\n+};\n+\n+struct ietf_mpa_v1 {\n+\tu8 key[IETF_MPA_KEY_SIZE];\n+\tu8 flags;\n+\tu8 rev;\n+\t__be16 priv_data_len;\n+\tu8 priv_data[0];\n+};\n+\n+struct ietf_rtr_msg {\n+\t__be16 ctrl_ird;\n+\t__be16 ctrl_ord;\n+};\n+\n+struct ietf_mpa_v2 {\n+\tu8 key[IETF_MPA_KEY_SIZE];\n+\tu8 flags;\n+\tu8 rev;\n+\t__be16 priv_data_len;\n+\tstruct ietf_rtr_msg rtr_msg;\n+\tu8 priv_data[0];\n+};\n+\n+struct option_base {\n+\tu8 optionnum;\n+\tu8 len;\n+};\n+\n+struct option_mss {\n+\tu8 optionnum;\n+\tu8 len;\n+\t__be16 mss;\n+};\n+\n+struct option_windowscale {\n+\tu8 optionnum;\n+\tu8 len;\n+\tu8 shiftcount;\n+};\n+\n+union all_known_options {\n+\tchar eol;\n+\tstruct option_base base;\n+\tstruct option_mss mss;\n+\tstruct option_windowscale windowscale;\n+};\n+\n+struct irdma_timer_entry {\n+\tstruct list_head list;\n+\tunsigned long timetosend; /* jiffies */\n+\tstruct irdma_puda_buf *sqbuf;\n+\tu32 type;\n+\tu32 retrycount;\n+\tu32 retranscount;\n+\tu32 context;\n+\tu32 send_retrans;\n+\tint close_when_complete;\n+};\n+\n+/* CM context params */\n+struct irdma_cm_tcp_context {\n+\tu8 client;\n+\tu32 loc_seq_num;\n+\tu32 loc_ack_num;\n+\tu32 rem_ack_num;\n+\tu32 rcv_nxt;\n+\tu32 loc_id;\n+\tu32 rem_id;\n+\tu32 snd_wnd;\n+\tu32 max_snd_wnd;\n+\tu32 rcv_wnd;\n+\tu32 mss;\n+\tu8 snd_wscale;\n+\tu8 rcv_wscale;\n+};\n+\n+struct irdma_cm_listener {\n+\tstruct list_head list;\n+\tstruct iw_cm_id *cm_id;\n+\tstruct irdma_cm_core *cm_core;\n+\tstruct irdma_device *iwdev;\n+\tstruct list_head child_listen_list;\n+\tenum irdma_cm_listener_state listener_state;\n+\tatomic_t ref_count;\n+\tatomic_t pend_accepts_cnt;\n+\tu32 loc_addr[4];\n+\tu32 reused_node;\n+\tint backlog;\n+\tu16 loc_port;\n+\tu16 vlan_id;\n+\tu8 loc_mac[ETH_ALEN];\n+\tu8 user_pri;\n+\tu8 tos;\n+\tbool qhash_set;\n+\tbool ipv4;\n+};\n+\n+struct irdma_kmem_info {\n+\tvoid *addr;\n+\tu32 size;\n+};\n+\n+struct irdma_cm_node {\n+\tstruct irdma_qp *iwqp;\n+\tstruct irdma_device *iwdev;\n+\tstruct irdma_sc_dev *dev;\n+\tstruct irdma_cm_tcp_context tcp_cntxt;\n+\tstruct irdma_cm_core *cm_core;\n+\tstruct irdma_timer_entry *send_entry;\n+\tstruct irdma_timer_entry *close_entry;\n+\tstruct irdma_cm_listener *listener;\n+\tstruct list_head timer_entry;\n+\tstruct list_head reset_entry;\n+\tstruct list_head teardown_entry;\n+\tstruct irdma_kmem_info pdata;\n+\tstruct irdma_sc_ah *ah;\n+\tunion {\n+\t\tstruct ietf_mpa_v1 mpa_frame;\n+\t\tstruct ietf_mpa_v2 mpa_v2_frame;\n+\t};\n+\tstruct irdma_kmem_info mpa_hdr;\n+\tstruct iw_cm_id *cm_id;\n+\tstruct list_head list;\n+\tspinlock_t retrans_list_lock; /* protect CM node rexmit updates*/\n+\tatomic_t passive_state;\n+\tatomic_t ref_count;\n+\tenum irdma_cm_node_state state;\n+\tenum send_rdma0 send_rdma0_op;\n+\tenum mpa_frame_ver mpa_frame_rev;\n+\tu32 loc_addr[4], rem_addr[4];\n+\tu16 loc_port, rem_port;\n+\tbool accelerated;\n+\tint apbvt_set;\n+\tint accept_pend;\n+\tu16 vlan_id;\n+\tu16 ird_size;\n+\tu16 ord_size;\n+\tu16 mpav2_ird_ord;\n+\tu16 lsmm_size;\n+\tu8 pdata_buf[IETF_MAX_PRIV_DATA_LEN];\n+\tu8 loc_mac[ETH_ALEN];\n+\tu8 rem_mac[ETH_ALEN];\n+\tu8 user_pri;\n+\tu8 tos;\n+\tbool ack_rcvd;\n+\tbool qhash_set;\n+\tbool ipv4;\n+\tbool snd_mark_en;\n+\tbool do_lpb;\n+};\n+\n+/* Used by internal CM APIs to pass CM information*/\n+struct irdma_cm_info {\n+\tstruct iw_cm_id *cm_id;\n+\tu16 loc_port;\n+\tu16 rem_port;\n+\tu32 loc_addr[4];\n+\tu32 rem_addr[4];\n+\tu32 qh_qpid;\n+\tu16 vlan_id;\n+\tint backlog;\n+\tu8 user_pri;\n+\tu8 tos;\n+\tbool ipv4;\n+};\n+\n+struct irdma_cm_event {\n+\tenum irdma_cm_event_type type;\n+\tstruct irdma_cm_info cm_info;\n+\tstruct work_struct event_work;\n+\tstruct irdma_cm_node *cm_node;\n+};\n+\n+struct irdma_cm_core {\n+\tstruct irdma_device *iwdev;\n+\tstruct irdma_sc_dev *dev;\n+\tstruct list_head listen_nodes;\n+\tstruct list_head accelerated_list;\n+\tstruct list_head non_accelerated_list;\n+\tstruct timer_list tcp_timer;\n+\tstruct workqueue_struct *event_wq;\n+\tstruct workqueue_struct *disconn_wq;\n+\tspinlock_t ht_lock; /* protect CM node (active side) list */\n+\tspinlock_t listen_list_lock; /* protect listener list */\n+\tspinlock_t apbvt_lock; /*serialize apbvt add/del entries*/\n+\tunsigned long ports_in_use[BITS_TO_LONGS(MAX_PORTS)];\n+\tu64 stats_nodes_created;\n+\tu64 stats_nodes_destroyed;\n+\tu64 stats_listen_created;\n+\tu64 stats_listen_destroyed;\n+\tu64 stats_listen_nodes_created;\n+\tu64 stats_listen_nodes_destroyed;\n+\tu64 stats_lpbs;\n+\tu64 stats_accepts;\n+\tu64 stats_rejects;\n+\tu64 stats_connect_errs;\n+\tu64 stats_passive_errs;\n+\tu64 stats_pkt_retrans;\n+\tu64 stats_backlog_drops;\n+\tstruct irdma_puda_buf *(*form_cm_frame)(struct irdma_cm_node *cm_node,\n+\t\t\t\t\t\tstruct irdma_kmem_info *options,\n+\t\t\t\t\t\tstruct irdma_kmem_info *hdr,\n+\t\t\t\t\t\tstruct irdma_kmem_info *pdata,\n+\t\t\t\t\t\tu8 flags);\n+\tint (*cm_create_ah)(struct irdma_cm_node *cm_node, bool wait);\n+\tvoid (*cm_free_ah)(struct irdma_cm_node *cm_node);\n+};\n+\n+int irdma_schedule_cm_timer(struct irdma_cm_node *cm_node,\n+\t\t\t    struct irdma_puda_buf *sqbuf,\n+\t\t\t    enum irdma_timer_type type, int send_retrans,\n+\t\t\t    int close_when_complete);\n+int irdma_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);\n+int irdma_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len);\n+int irdma_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);\n+int irdma_create_listen(struct iw_cm_id *cm_id, int backlog);\n+int irdma_destroy_listen(struct iw_cm_id *cm_id);\n+void irdma_cm_teardown_connections(struct irdma_device *iwdev, u32 *ipaddr,\n+\t\t\t\t   struct irdma_cm_info *nfo,\n+\t\t\t\t   bool disconnect_all);\n+int irdma_cm_start(struct irdma_device *dev);\n+int irdma_cm_stop(struct irdma_device *dev);\n+bool irdma_ipv4_is_lpb(u32 loc_addr, u32 rem_addr);\n+bool irdma_ipv6_is_lpb(u32 *loc_addr, u32 *rem_addr);\n+int irdma_arp_table(struct irdma_pci_f *rf, u32 *ip_addr, bool ipv4,\n+\t\t    u8 *mac_addr, u32 action);\n+int irdma_add_arp(struct irdma_pci_f *rf, u32 *ip, bool ipv4, u8 *mac);\n+void irdma_if_notify(struct irdma_device *iwdev, struct net_device *netdev,\n+\t\t     u32 *ipaddr, bool ipv4, bool ifup);\n+bool irdma_port_in_use(struct irdma_cm_core *cm_core, u16 port);\n+void irdma_send_ack(struct irdma_cm_node *cm_node);\n+void irdma_lpb_nop(struct irdma_sc_qp *qp);\n+u8 irdma_derive_hw_ird_setting(u16 cm_ird);\n+#endif /* IRDMA_CM_H */\n",
    "prefixes": [
        "rdma-nxt",
        "07/16"
    ]
}