From patchwork Tue May 10 12:27:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jian Hui Lee X-Patchwork-Id: 1629127 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=E6JSPPaD; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KyHQW6k8Wz9sGJ for ; Tue, 10 May 2022 22:28:51 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1noOyp-0001Mm-OQ; Tue, 10 May 2022 12:28:43 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1noOyl-0001DK-8b for kernel-team@lists.ubuntu.com; Tue, 10 May 2022 12:28:39 +0000 Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 7BC553F1BE for ; Tue, 10 May 2022 12:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1652185718; bh=T18DurV3VQsJ/GAKYiBqmUANcVf3v1JEE7A6N2watuk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E6JSPPaD+YsigydqaW0bKHvIMX2utUMLLo2KCFNn2tDLt0TVjDM4jmTAscmK0qiBR 5Ji1nLKhXngZ64ZMtyOnAzl/PGBh32NQoaw2UZ9ZHq7QJhSLpnyv0G+f+j+3gXFzJ6 aBn56mATp9XNwMs3psddZnkpeQtmtD1nCuKSezrKUqQLup8jZyVajcn+572gGXHsTE pRML1Y5MFTCQ1dkUy+aaN8kqTsOPbGDS9tTkLqD8GAxCan5gfL9AfWZvYIuOLcQUtj PBv24+xnNwVJqmC+tU6maXkADgNiIAXHFmN4mzxJZhkO9q8u3U2/B+6E5qd4baShJO 6jboKBz3990sQ== Received: by mail-pj1-f70.google.com with SMTP id i6-20020a17090a718600b001dc87aca289so7661194pjk.5 for ; Tue, 10 May 2022 05:28:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T18DurV3VQsJ/GAKYiBqmUANcVf3v1JEE7A6N2watuk=; b=0k5rgrjwSVcG+O+cjugCwaI2rqLLjUwLdU1buUKagI0VE4mjdduWQRHMmPHP/xqcNR XpuGhJveBVKJtxtIR31hxwobLuuImb8aHbtL6EhOCNcMWc82NQFgvvozMMIwWOpqiRZ4 zGZoAWtoiH+ICsK7RPFZncoFg3BhhbFz7sJJO6+yAdr86TJAGFra0/5N780GXKYsMdEu rvIftMajP3EMPLTW5dd42uI1RZV3+TJcFnN1AKRSjpoHnhlUTyKjKZQkJbpoogqBzbU9 yzOQqOZmjabKPJbSqWr9aL7uzBLiUFM2xmuzWu734osrLvZQHv4M1q77l7vr9MfOhfwY FW3Q== X-Gm-Message-State: AOAM532lE95R/Er9iGGh2+1MS4lx6v2Q06RL/q0+8vfQRK+CyZGmCxOx S5XLOcbfkZJCL8jDLtFjGc7Htus7qi8lsqSTx6mJkzkkHUqwjOHEm5pZNO37RI2FJdwhTV+PzBi nbIqQ9HwId/AHa2RxiMwx1XuP/wSRJ9HFxpwjNhQvhg== X-Received: by 2002:a65:4685:0:b0:3da:eb4e:61ed with SMTP id h5-20020a654685000000b003daeb4e61edmr2493669pgr.591.1652185716854; Tue, 10 May 2022 05:28:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyu0qkfbQR6KS0Kvk+KjtFDLwQQR/kP2/Ui6zHXs1GS5qQrMlDRKgr3Fj27VtMJySJI35iYaw== X-Received: by 2002:a65:4685:0:b0:3da:eb4e:61ed with SMTP id h5-20020a654685000000b003daeb4e61edmr2493646pgr.591.1652185716508; Tue, 10 May 2022 05:28:36 -0700 (PDT) Received: from localhost.localdomain (36-230-106-94.dynamic-ip.hinet.net. [36.230.106.94]) by smtp.gmail.com with ESMTPSA id g1-20020a170902e38100b0015e8d4eb1c8sm1903243ple.18.2022.05.10.05.28.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 05:28:35 -0700 (PDT) From: Jian Hui Lee To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy:linux-intel-iotg][PATCH v2 1/3] net: Add support for Intel vnic driver Date: Tue, 10 May 2022 20:27:49 +0800 Message-Id: <20220510122751.130033-2-jianhui.lee@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220510122751.130033-1-jianhui.lee@canonical.com> References: <20220510122751.130033-1-jianhui.lee@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Nachiketa Kumar BugLink: https://bugs.launchpad.net/bugs/1943524 This driver enables a virtual network interface for communicating with a dedicated low power chip over ISHTP v1: - Initial version --- Signed-off-by: Nachiketa Kumar Signed-off-by: Anthony Wong Signed-off-by: Wen-chien Jesse Sung (cherry picked from commit 11d471cbed79cb98bf9108deddacff74435b2c1c linux-intel-5.13) Signed-off-by: Jian Hui Lee --- drivers/net/Kconfig | 1 + drivers/net/Makefile | 1 + drivers/net/vnic/Kconfig | 7 + drivers/net/vnic/Makefile | 1 + drivers/net/vnic/eth-ishtp.c | 499 +++++++++++++++++++++++++++++++++++ 5 files changed, 509 insertions(+) create mode 100644 drivers/net/vnic/Kconfig create mode 100644 drivers/net/vnic/Makefile create mode 100644 drivers/net/vnic/eth-ishtp.c diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index dd335ae1122b..50b9c11c9fff 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -613,4 +613,5 @@ config NETDEV_LEGACY_INIT Drivers that call netdev_boot_setup_check() should select this symbol, everything else no longer needs it. +source "drivers/net/vnic/Kconfig" endif # NETDEVICES diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 739838623cf6..3ff439e99883 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -72,6 +72,7 @@ obj-$(CONFIG_IEEE802154) += ieee802154/ obj-$(CONFIG_WWAN) += wwan/ obj-$(CONFIG_MCTP) += mctp/ +obj-$(CONFIG_INTEL_ISHTP_VNIC) += vnic/ obj-$(CONFIG_VMXNET3) += vmxnet3/ obj-$(CONFIG_XEN_NETDEV_FRONTEND) += xen-netfront.o obj-$(CONFIG_XEN_NETDEV_BACKEND) += xen-netback/ diff --git a/drivers/net/vnic/Kconfig b/drivers/net/vnic/Kconfig new file mode 100644 index 000000000000..55ca8dad28c0 --- /dev/null +++ b/drivers/net/vnic/Kconfig @@ -0,0 +1,7 @@ +config INTEL_ISHTP_VNIC + tristate "Intel ISHTP VNIC controller" + depends on INTEL_ISH_HID + depends on NET + help + If you say Y here, you get support for a virtual newtwork device + on a dedicated low power chip over ISH Transport Protocol (ISHTP). diff --git a/drivers/net/vnic/Makefile b/drivers/net/vnic/Makefile new file mode 100644 index 000000000000..a5ad3b3fe7af --- /dev/null +++ b/drivers/net/vnic/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_INTEL_ISHTP_VNIC) += eth-ishtp.o diff --git a/drivers/net/vnic/eth-ishtp.c b/drivers/net/vnic/eth-ishtp.c new file mode 100644 index 000000000000..9b4df45f423e --- /dev/null +++ b/drivers/net/vnic/eth-ishtp.c @@ -0,0 +1,499 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Intel virtual Network Interface Card driver (vNIC driver) for + * ethernet communication over Intel Integrated Sensor Hub + * (ISH) using ISH Trasport protocol (ISHTP) + * + * Copyright (c) 2019, Intel Corporation. + */ + +#include +#include +#include +#include +#include + +#define ETH_ISHTP_DRV_NAME "eth_ishtp" +#define ETH_ISHTP_DRV_DESC "Intel Ethernet ISHTP Driver" +#define ETH_ISHTP_TX_QUE_LEN 100 +#define WAIT_FOR_SEND_SLICE_MS 100 +#define WAIT_FOR_SEND_COUNT 10 +#define ETH_ISHTP_CL_RX_RING_SIZE 4 +#define ETH_ISHTP_CL_TX_RING_SIZE 4 +#define ETH_ISHTP_DATA_BUFLEN 984 +#define ETH_ISHTP_RX_MAX_LEN 984 +#define ETH_ISHTP_TX_MAX_LEN 984 +#define ETH_ISHTP_TX_MIN_LEN 14 + +/* Default timeout period */ +#define ETH_ISHTP_TIMEOUT 500 /* In jiffies */ +#define ETH_ISHTP_MIN_MTU (ETH_ZLEN - ETH_HLEN) +#define ETH_ISHTP_MAX_MTU ETH_ISHTP_DATA_BUFLEN + +static const guid_t eth_ishtp_uuid = + GUID_INIT(0xeb83e1fb, 0x4c61, 0x4829, + 0x98, 0x4c, 0x3, 0x23, 0xab, 0x4b, 0x41, 0x65); + +struct eth_ishtp_prv { + struct device *dev; + struct net_device *net_dev; + struct net_device_stats stats; + unsigned char *tx_buff; + int tx_len; + struct ishtp_cl *eth_ishtp_cl; + struct ishtp_cl_device *cl_device; + struct ishtp_fw_client *fw_client; + struct ishtp_cl_rb *rb; + struct work_struct reset_work; +}; + +static int eth_ishtp_cl_write(struct eth_ishtp_prv *prv, int *written) +{ + struct ishtp_cl *cl = prv->eth_ishtp_cl; + unsigned char *buf = prv->tx_buff; + int len = prv->tx_len; + int ret; + + ret = ishtp_cl_send(cl, buf, len); + if (ret) + goto err_exit; + + *written = len; + return 0; + +err_exit: + *written = 0; + dev_err(prv->dev, "[WRITE] Data send error: %d\n", ret); + return ret; +} + +static void eth_ishtp_rx(struct net_device *dev) +{ + struct eth_ishtp_prv *prv = netdev_priv(dev); + struct ishtp_cl_rb *rb = prv->rb; + struct sk_buff *skb; + + /* The packet has been retrieved from the transmission + * medium. Build an skb around it, so upper layers can handle it + */ + skb = netdev_alloc_skb_ip_align(dev, rb->buffer.size); + if (!skb) { + dev_err(prv->dev, "eth_ishtp rx: packet dropped\n"); + dev->stats.rx_dropped++; + return; + } + + skb_put(skb, rb->buffer.size); + skb_copy_to_linear_data(skb, rb->buffer.data, rb->buffer.size); + + /* Write metadata, and then pass to the receive level */ + skb->protocol = eth_type_trans(skb, dev); + skb->ip_summed = CHECKSUM_NONE; + dev->stats.rx_packets++; + dev->stats.rx_bytes += rb->buffer.size; + netif_rx(skb); +} + +static void eth_ishtp_cl_event_cb(struct ishtp_cl_device *cl_device) +{ + struct eth_ishtp_prv *prv = ishtp_get_drvdata(cl_device); + struct net_device *net_dev = prv->net_dev; + struct ishtp_cl_rb *rb; + + while ((rb = ishtp_cl_rx_get_rb(prv->eth_ishtp_cl)) != NULL) { + prv->rb = rb; + eth_ishtp_rx(net_dev); + prv->rb = NULL; + + ishtp_cl_io_rb_recycle(rb); + } + + if (ishtp_cl_tx_empty(prv->eth_ishtp_cl) && netif_queue_stopped(prv->net_dev)) + netif_wake_queue(prv->net_dev); +} + +static int eth_ishtp_open(struct net_device *dev) +{ + netif_carrier_on(dev); + netif_start_queue(dev); + return 0; +} + +static int eth_ishtp_stop(struct net_device *dev) +{ + netif_carrier_off(dev); + netif_stop_queue(dev); + return 0; +} + + /* Configuration changes by ifconfig */ +static int eth_ishtp_config(struct net_device *dev, struct ifmap *map) +{ + if (dev->flags & IFF_UP) /* can't act on a running interface */ + return -EBUSY; + + return 0; +} + +/* Transmit a packet (called by the kernel) */ +static int eth_ishtp_xmit(struct sk_buff *skb, struct net_device *dev) +{ + struct eth_ishtp_prv *prv = netdev_priv(dev); + int written; + int status; + + if (skb->len < ETH_ISHTP_TX_MIN_LEN || skb->len > ETH_ISHTP_TX_MAX_LEN) { + dev_kfree_skb_any(skb); + return NETDEV_TX_OK; + } + + if (!netif_running(dev)) { + dev_info(prv->dev, "xmit: iface is down\n"); + dev_kfree_skb_any(skb); + netif_stop_queue(dev); + return NETDEV_TX_OK; + } + + prv->tx_len = skb->len; + prv->tx_buff = skb->data; + status = eth_ishtp_cl_write(prv, &written); + + /* Tx failed */ + if (!status) { + dev_err(prv->dev, "xmit: ishtp_cl_write failed\n"); + netif_stop_queue(dev); + return NETDEV_TX_BUSY; + } + dev_kfree_skb_any(skb); + return NETDEV_TX_OK; +} + +static void eth_ishtp_tx_timeout(struct net_device *dev, unsigned int tx_queue) +{ + struct eth_ishtp_prv *prv = netdev_priv(dev); + + dev_err(prv->dev, "eth_ishtp tx timeout\n"); + dev_err(prv->dev, "Transmit timeout at %ld, latency %ld\n", + jiffies, dev_trans_start(dev)); + + dev->stats.tx_errors++; + dev->stats.tx_dropped++; + + netif_wake_queue(dev); +} + +static int eth_ishtp_dev_init(struct net_device *dev) +{ + struct eth_ishtp_prv *prv = netdev_priv(dev); + struct ishtp_fw_client *fw_client; + struct ishtp_device *ishtp_dev; + struct ishtp_cl *eth_ishtp_cl; + int ret, ishtp_fw_client_id; + + dev->mtu = ETH_ISHTP_MAX_MTU; + dev->type = ARPHRD_ETHER; + + eth_ishtp_cl = ishtp_cl_allocate(prv->cl_device); + if (!eth_ishtp_cl) { + dev_err(prv->dev, "ishtp cl allocate failed\n"); + ret = -ENOMEM; + return ret; + } + + prv->eth_ishtp_cl = eth_ishtp_cl; + + ret = ishtp_cl_link(eth_ishtp_cl); + if (ret) { + dev_err(prv->dev, "ishtp_cl_link failed\n"); + ret = -ENOENT; + goto err_free_cl; + } + + if (!ishtp_get_ishtp_device(eth_ishtp_cl)) { + dev_err(prv->dev, "ishtp_get_ishtp_device failed"); + ret = -ENODEV; + goto err_cl_unlink; + } + + /* Connect to FW client */ + ishtp_set_tx_ring_size(eth_ishtp_cl, ETH_ISHTP_CL_TX_RING_SIZE); + ishtp_set_rx_ring_size(eth_ishtp_cl, ETH_ISHTP_CL_RX_RING_SIZE); + + ishtp_dev = ishtp_get_ishtp_device(eth_ishtp_cl); + fw_client = ishtp_fw_cl_get_client(ishtp_dev, ð_ishtp_uuid); + if (!fw_client) { + dev_err(prv->dev, "FW client not found\n"); + ret = -ENOENT; + goto err_cl_unlink; + } + + ishtp_fw_client_id = ishtp_get_fw_client_id(fw_client); + ishtp_cl_set_fw_client_id(eth_ishtp_cl, ishtp_fw_client_id); + ishtp_set_connection_state(eth_ishtp_cl, ISHTP_CL_CONNECTING); + + ret = ishtp_register_event_cb(prv->cl_device, eth_ishtp_cl_event_cb); + if (ret) { + dev_err(ishtp_device(prv->cl_device), + "ishtp register callback failed\n"); + free_netdev(prv->net_dev); + goto err_cl_unlink; + } + + ret = ishtp_cl_connect(eth_ishtp_cl); + if (ret) { + dev_err(prv->dev, "Client connect failed\n"); + goto err_cl_unlink; + } + + dev_info(prv->dev, "Connected to fw client = %d\n", ishtp_fw_client_id); + + return 0; + +err_cl_unlink: + ishtp_cl_unlink(eth_ishtp_cl); + +err_free_cl: + ishtp_put_device(prv->cl_device); + ishtp_cl_free(eth_ishtp_cl); + prv->eth_ishtp_cl = NULL; + return ret; +} + +static void eth_ishtp_dev_uninit(struct net_device *dev) +{ + struct eth_ishtp_prv *prv = netdev_priv(dev); + int try = WAIT_FOR_SEND_COUNT; + struct ishtp_cl_rb *rb; + struct ishtp_cl *cl; + int ret; + + cancel_work_sync(&prv->reset_work); + + cl = prv->eth_ishtp_cl; + if (cl) { + do { + if (ishtp_cl_tx_empty(cl)) + break; + + msleep_interruptible(WAIT_FOR_SEND_SLICE_MS); + } while (--try); + + ishtp_set_connection_state(cl, ISHTP_CL_DISCONNECTING); + ret = ishtp_cl_disconnect(cl); + ishtp_cl_unlink(cl); + ishtp_cl_flush_queues(cl); + ishtp_cl_free(cl); + + prv->eth_ishtp_cl = NULL; + } + + rb = prv->rb; + if (rb) { + ishtp_cl_io_rb_recycle(rb); + prv->rb = NULL; + } +} + +static const struct net_device_ops eth_ishtp_netdev_ops = { + .ndo_init = eth_ishtp_dev_init, + .ndo_uninit = eth_ishtp_dev_uninit, + .ndo_open = eth_ishtp_open, + .ndo_stop = eth_ishtp_stop, + .ndo_start_xmit = eth_ishtp_xmit, + .ndo_set_mac_address = eth_mac_addr, + .ndo_set_config = eth_ishtp_config, + .ndo_tx_timeout = eth_ishtp_tx_timeout, + .ndo_validate_addr = eth_validate_addr +}; + +static void eth_ishtp_setup(struct net_device *dev) +{ + struct eth_ishtp_prv *prv; + + ether_setup(dev); + dev->watchdog_timeo = ETH_ISHTP_TIMEOUT; + dev->netdev_ops = ð_ishtp_netdev_ops; + dev->flags |= IFF_NOARP; + dev->flags &= ~(IFF_MULTICAST); + dev->priv_flags &= ~IFF_TX_SKB_SHARING; + dev->tx_queue_len = ETH_ISHTP_TX_QUE_LEN; + dev->min_mtu = ETH_ISHTP_MIN_MTU; + dev->max_mtu = ETH_ISHTP_MAX_MTU; + + prv = netdev_priv(dev); +} + +static void eth_ishtp_reset(struct work_struct *work) +{ + struct ishtp_cl_device *cl_device; + struct ishtp_fw_client *fw_client; + struct ishtp_device *ishtp_dev; + struct ishtp_cl *eth_ishtp_cl; + struct eth_ishtp_prv *prv; + int ret, fw_client_id; + + prv = container_of(work, struct eth_ishtp_prv, reset_work); + + cl_device = prv->cl_device; + eth_ishtp_cl = prv->eth_ishtp_cl; + + if (!ishtp_get_ishtp_device(eth_ishtp_cl)) { + dev_err(ishtp_device(prv->cl_device), + "Allocate ishtp_cl failed\n"); + return; + } + + if (eth_ishtp_cl) { + ishtp_cl_unlink(eth_ishtp_cl); + ishtp_cl_flush_queues(eth_ishtp_cl); + ishtp_cl_free(eth_ishtp_cl); + eth_ishtp_cl = NULL; + eth_ishtp_cl = ishtp_cl_allocate(cl_device); + if (!eth_ishtp_cl) { + dev_err(ishtp_device(prv->cl_device), + "Allocate ishtp_cl failed\n"); + return; + } + + prv->eth_ishtp_cl = eth_ishtp_cl; + ret = ishtp_cl_link(eth_ishtp_cl); + if (ret) { + dev_err(ishtp_device(prv->cl_device), + "Can not link to ishtp\n"); + goto out_free; + } + + ishtp_dev = ishtp_get_ishtp_device(prv->eth_ishtp_cl); + + /* Connect to FW client */ + ishtp_set_tx_ring_size(eth_ishtp_cl, ETH_ISHTP_CL_TX_RING_SIZE); + ishtp_set_rx_ring_size(eth_ishtp_cl, ETH_ISHTP_CL_RX_RING_SIZE); + + fw_client = ishtp_fw_cl_get_client(ishtp_dev, ð_ishtp_uuid); + if (!fw_client) { + dev_err(ishtp_device(prv->cl_device), + "Don't find related fw client\n"); + ret = -ENOENT; + goto out_unlink_free; + } + + fw_client_id = ishtp_get_fw_client_id(fw_client); + ishtp_cl_set_fw_client_id(eth_ishtp_cl, fw_client_id); + ishtp_set_connection_state(eth_ishtp_cl, ISHTP_CL_CONNECTING); + + ret = ishtp_cl_connect(eth_ishtp_cl); + if (ret) { + dev_err(ishtp_device(prv->cl_device), + "Connect to fw failed %d\n", ret); + goto out_unlink_free; + } + + prv->eth_ishtp_cl = eth_ishtp_cl; + } + + /* After reset, must register event callback again */ + ishtp_register_event_cb(cl_device, eth_ishtp_cl_event_cb); + + return; + +out_unlink_free: + ishtp_cl_unlink(eth_ishtp_cl); + +out_free: + ishtp_cl_free(eth_ishtp_cl); + prv->eth_ishtp_cl = NULL; + dev_err(ishtp_device(prv->cl_device), "Reset failed\n"); +} + +static int eth_ishtp_cl_reset(struct ishtp_cl_device *cl_device) +{ + struct eth_ishtp_prv *prv; + + prv = (struct eth_ishtp_prv *)ishtp_get_drvdata(cl_device); + if (!prv) { + dev_err(ishtp_device(prv->cl_device), + "Client driver not ready yet\n"); + return -ENODEV; + } + schedule_work(&prv->reset_work); + return 0; +} + +static int eth_ishtp_cl_remove(struct ishtp_cl_device *cl_device) +{ + struct eth_ishtp_prv *prv; + + prv = ishtp_get_drvdata(cl_device); + if (!prv) + return -ENODEV; + + unregister_netdev(prv->net_dev); + free_netdev(prv->net_dev); + ishtp_put_device(cl_device); + return 0; +} + +static int eth_ishtp_cl_probe(struct ishtp_cl_device *cl_device) +{ + struct eth_ishtp_prv *eth_ishtp_prv; + struct net_device *net_dev; + int ret; + + /* Allocate the devices */ + net_dev = alloc_netdev(sizeof(struct eth_ishtp_prv), "ehi%d", + NET_NAME_UNKNOWN, eth_ishtp_setup); + if (!net_dev) { + ret = -ENOMEM; + return ret; + } + + eth_ishtp_prv = netdev_priv(net_dev); + eth_ishtp_prv->net_dev = net_dev; + eth_ishtp_prv->dev = &net_dev->dev; + eth_ishtp_prv->cl_device = cl_device; + + ishtp_set_drvdata(cl_device, eth_ishtp_prv); + ishtp_get_device(cl_device); + + eth_hw_addr_random(eth_ishtp_prv->net_dev); + netdev_info(net_dev, "Using random MAC address: %p\n", + eth_ishtp_prv->net_dev->dev_addr); + + INIT_WORK(ð_ishtp_prv->reset_work, eth_ishtp_reset); + + ret = register_netdev(net_dev); + if (ret) { + netdev_err(net_dev, "Unable to register net device"); + free_netdev(net_dev); + return ret; + } + + return ret; +} + +static struct ishtp_cl_driver eth_ishtp_cl_driver = { + .name = ETH_ISHTP_DRV_NAME, + .guid = ð_ishtp_uuid, + .probe = eth_ishtp_cl_probe, + .remove = eth_ishtp_cl_remove, + .reset = eth_ishtp_cl_reset, +}; + +static int __init eth_ishtp_init(void) +{ + return ishtp_cl_driver_register(ð_ishtp_cl_driver, THIS_MODULE); +} + +static void __exit eth_ishtp_exit(void) +{ + return ishtp_cl_driver_unregister(ð_ishtp_cl_driver); +} + +module_init(eth_ishtp_init); +module_exit(eth_ishtp_exit); + +MODULE_DESCRIPTION(ETH_ISHTP_DRV_DESC); + +MODULE_AUTHOR("Nachiketa Kumar "); +MODULE_AUTHOR("Sing Nallasellan "); + +MODULE_LICENSE("GPL"); From patchwork Tue May 10 12:27:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jian Hui Lee X-Patchwork-Id: 1629128 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=q2PaY7J0; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KyHQX3P2Lz9sG0 for ; Tue, 10 May 2022 22:28:52 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1noOyq-0001Ni-Qk; Tue, 10 May 2022 12:28:44 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1noOyl-0001EH-Mm for kernel-team@lists.ubuntu.com; Tue, 10 May 2022 12:28:39 +0000 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 808843F1B4 for ; Tue, 10 May 2022 12:28:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1652185719; bh=4VhwtjsH7+GcwsyE/PyQmypE1C4lOeKeoKpEwtH8XMs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q2PaY7J06L/CKiOQx++1LMkDxI0nHBwuQUeK06qwJ4gJsb8vLyE7AuEmhSCZdvIOr be/zI8mM2XXnZhqHmBlOzkqmc5fj5arbmzX695/sgfJNhaQB61K7NaNbyIJ8t6AfId wd88zHTo/zrXD8IHDPvvh5oR6Cv+N+bpH8siRox0kkcAr1OqBwm8MwDR/7CMqThraR GPW9+CgmuPFqlVWfMVHpCHGDcUTY0W38aFfknuUSqNYuRaBFyXOQZm3vNITc3F2//U DiU+8qWNM9JxOD5qV9z4lPwjdtaIeWTvjftYcx9W2zkBaqa5lTOqNb2jDKKaYW3IsA /BDT8HMJ4K91A== Received: by mail-pl1-f197.google.com with SMTP id b10-20020a170902bd4a00b0015e7ee90842so9862062plx.8 for ; Tue, 10 May 2022 05:28:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4VhwtjsH7+GcwsyE/PyQmypE1C4lOeKeoKpEwtH8XMs=; b=PF13NgGDUMvMt1IjJzlKeatrYTferKBNCTFyy/4tskKGBoNTymyL2fQ8o3zMZQU8eh we/o5UCsTcRYn93uRPEbZvdQ19ZeQeeF1zAx5+tTMpWMTXmQui6eJgUP1/PuxiyTHg+4 4iz0P8eEuQ5zJQYSkplVzim4d14vBn8MoF5eo9k08NSYJHDflvDsOSAVusyER1huovI7 CjPlgZh2GU8IuICMElHySyeHNeQHK4XmgIgYO9UfvS8nn7/qB+w9u0DfnUQMlboh9sK5 fKBL7Hw/1SMoUDK0+OFducCyo+WIrLMZuSHrD9/54rFbrY5o85xc99P3CxgK3ag3uwBJ Dhvw== X-Gm-Message-State: AOAM530OTmYABxq09O9Kv+g5tqgNA7vHNgh4PUpwUvupwCjOBkHVGyZK ZIK8fAwaEuLtk1E/0vHgZy9E+PVBFBZDCStsZu1p+eodvcfTtHyQQ5AgnT5xoAtaNdzvxPRnThQ 7I6m0M2tqXNFUzre0E55+Ehip9e5d7mnupp7wxC61Hw== X-Received: by 2002:a63:24d:0:b0:3c2:2f74:2ddb with SMTP id 74-20020a63024d000000b003c22f742ddbmr17080800pgc.83.1652185718282; Tue, 10 May 2022 05:28:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxL4Yrm94TVpeBifmLFg91XqaCoMPTcF7TxxuprkXvnfQpWxdwDUGdx/faCtIVZu3C0J3C5ag== X-Received: by 2002:a63:24d:0:b0:3c2:2f74:2ddb with SMTP id 74-20020a63024d000000b003c22f742ddbmr17080782pgc.83.1652185717895; Tue, 10 May 2022 05:28:37 -0700 (PDT) Received: from localhost.localdomain (36-230-106-94.dynamic-ip.hinet.net. [36.230.106.94]) by smtp.gmail.com with ESMTPSA id g1-20020a170902e38100b0015e8d4eb1c8sm1903243ple.18.2022.05.10.05.28.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 05:28:37 -0700 (PDT) From: Jian Hui Lee To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy:linux-intel-iotg][PATCH v2 2/3] UBUNTU: SAUCE: net: fix compile error for Intel vnic driver Date: Tue, 10 May 2022 20:27:50 +0800 Message-Id: <20220510122751.130033-3-jianhui.lee@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220510122751.130033-1-jianhui.lee@canonical.com> References: <20220510122751.130033-1-jianhui.lee@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1943524 Update data structure to meet version 5.15. This is related to commit e22f6f9e64307abc3022b3264d81e3b7fba57ea9. Signed-off-by: Jian Hui Lee --- drivers/net/vnic/eth-ishtp.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/net/vnic/eth-ishtp.c b/drivers/net/vnic/eth-ishtp.c index 9b4df45f423e..b4751ef275b5 100644 --- a/drivers/net/vnic/eth-ishtp.c +++ b/drivers/net/vnic/eth-ishtp.c @@ -29,9 +29,12 @@ #define ETH_ISHTP_MIN_MTU (ETH_ZLEN - ETH_HLEN) #define ETH_ISHTP_MAX_MTU ETH_ISHTP_DATA_BUFLEN -static const guid_t eth_ishtp_uuid = - GUID_INIT(0xeb83e1fb, 0x4c61, 0x4829, - 0x98, 0x4c, 0x3, 0x23, 0xab, 0x4b, 0x41, 0x65); +static const struct ishtp_device_id eth_ishtp_uuid[] = { + { .guid = GUID_INIT(0xeb83e1fb, 0x4c61, 0x4829, + 0x98, 0x4c, 0x3, 0x23, 0xab, 0x4b, 0x41, 0x65), }, + { } +}; +MODULE_DEVICE_TABLE(ishtp, eth_ishtp_uuid); struct eth_ishtp_prv { struct device *dev; @@ -219,7 +222,7 @@ static int eth_ishtp_dev_init(struct net_device *dev) ishtp_set_rx_ring_size(eth_ishtp_cl, ETH_ISHTP_CL_RX_RING_SIZE); ishtp_dev = ishtp_get_ishtp_device(eth_ishtp_cl); - fw_client = ishtp_fw_cl_get_client(ishtp_dev, ð_ishtp_uuid); + fw_client = ishtp_fw_cl_get_client(ishtp_dev, ð_ishtp_uuid[0].guid); if (!fw_client) { dev_err(prv->dev, "FW client not found\n"); ret = -ENOENT; @@ -368,7 +371,7 @@ static void eth_ishtp_reset(struct work_struct *work) ishtp_set_tx_ring_size(eth_ishtp_cl, ETH_ISHTP_CL_TX_RING_SIZE); ishtp_set_rx_ring_size(eth_ishtp_cl, ETH_ISHTP_CL_RX_RING_SIZE); - fw_client = ishtp_fw_cl_get_client(ishtp_dev, ð_ishtp_uuid); + fw_client = ishtp_fw_cl_get_client(ishtp_dev, ð_ishtp_uuid[0].guid); if (!fw_client) { dev_err(ishtp_device(prv->cl_device), "Don't find related fw client\n"); @@ -418,18 +421,17 @@ static int eth_ishtp_cl_reset(struct ishtp_cl_device *cl_device) return 0; } -static int eth_ishtp_cl_remove(struct ishtp_cl_device *cl_device) +static void eth_ishtp_cl_remove(struct ishtp_cl_device *cl_device) { struct eth_ishtp_prv *prv; prv = ishtp_get_drvdata(cl_device); if (!prv) - return -ENODEV; + return; unregister_netdev(prv->net_dev); free_netdev(prv->net_dev); ishtp_put_device(cl_device); - return 0; } static int eth_ishtp_cl_probe(struct ishtp_cl_device *cl_device) @@ -472,7 +474,7 @@ static int eth_ishtp_cl_probe(struct ishtp_cl_device *cl_device) static struct ishtp_cl_driver eth_ishtp_cl_driver = { .name = ETH_ISHTP_DRV_NAME, - .guid = ð_ishtp_uuid, + .id = eth_ishtp_uuid, .probe = eth_ishtp_cl_probe, .remove = eth_ishtp_cl_remove, .reset = eth_ishtp_cl_reset, From patchwork Tue May 10 12:27:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jian Hui Lee X-Patchwork-Id: 1629130 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=swej+Tq/; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KyHQZ6ml6z9sG0 for ; Tue, 10 May 2022 22:28:54 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1noOyt-0001SX-Ql; Tue, 10 May 2022 12:28:47 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1noOyo-0001GG-Ik for kernel-team@lists.ubuntu.com; Tue, 10 May 2022 12:28:42 +0000 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 5081A3F1B4 for ; Tue, 10 May 2022 12:28:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1652185721; bh=CmGiBcgbs1p03xHCbl2q/8ur2peTVPPiP1ocu4ohIhw=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=swej+Tq/rncpsKHxMmVB/lQn05XhT0XaxbzkJGAuP+iuylJPk1aWvFwFuXzMrjPQU GUFgEIPMLmWcnLESmfXfdZNP+DtheqLvKMFbeRuuJs8GLLdVSwWKxGVH+lx/6If+iJ xNZ5G4KKnG/Bf2NuzIL6JmCo/5Uc4AcUBWGT1kZSiWYooUHBdiYOkmqWDnTBwu/bO9 f0u0AnaCFw49XAvQXnXotx6y7fp70OxVVGR0I+E1GUpYPA3WEESal7Of91J8pJjI3J EsIVxLUtbCpOz2SqFCb3FibWh2hjKSCCh7/lBv1TVlQyzPmFDzxfum6ZG4zj1UFVeM iGkUSsG/ZGkhQ== Received: by mail-pg1-f199.google.com with SMTP id f7-20020a6547c7000000b003c600995546so8293666pgs.5 for ; Tue, 10 May 2022 05:28:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CmGiBcgbs1p03xHCbl2q/8ur2peTVPPiP1ocu4ohIhw=; b=zFlvC8DAUsBoW/cXA6tueryykjbjh5Cq7uyY1Xr6I9ytZJYXngTzl86ZF6TiN4PlvI wvm5OkjjgyIWL8pM6ZqXV+Cj95tlUObsN0PF6+y+atLUnlDszvtrsvf3O/qbSjg53PXM 8UeJftmHHIAj89rJ2QMyEQBBQBmnYCIIsUE7PecCbQpZccZP7IJl2bE7Xsl4P6xE5a0R vf4eGQLJNfNAe6STlblQMAZ7UARqx5JN2duXxip+C8WoiGIQermYQvQWi9zd9EaFr+hA k0pWqMUJimO2N7cT2U0ZPpsNA5wFgLVRKnq2PisgpLX64NIHgKHzp2gVkxGOgNPxfE+P fAGA== X-Gm-Message-State: AOAM53102nxZruDW+dchz8NIftxHUBSuNW9wfNVgYMRlaGhShyizVtY9 Kb8zQLbg/tW2KgsVqkb/7wwu6QBK4TOW2GMabszQniT+NFTU5GjVJhy60BHyRIqqCaqjNtO56n+ ag5NDOZCt+Qx1dsMFxkH1y/SA1Xft6ziA9C0wY8BZiA== X-Received: by 2002:a63:ad0c:0:b0:374:50b4:c955 with SMTP id g12-20020a63ad0c000000b0037450b4c955mr16425029pgf.530.1652185719917; Tue, 10 May 2022 05:28:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiIeYEbxW8f+b89QNxvYSpHcIi1DF+fKXpz1d+S1DGF9U53pejYINE8URFUBXU72v28hs12g== X-Received: by 2002:a63:ad0c:0:b0:374:50b4:c955 with SMTP id g12-20020a63ad0c000000b0037450b4c955mr16425011pgf.530.1652185719618; Tue, 10 May 2022 05:28:39 -0700 (PDT) Received: from localhost.localdomain (36-230-106-94.dynamic-ip.hinet.net. [36.230.106.94]) by smtp.gmail.com with ESMTPSA id g1-20020a170902e38100b0015e8d4eb1c8sm1903243ple.18.2022.05.10.05.28.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 05:28:38 -0700 (PDT) From: Jian Hui Lee To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy:linux-intel-iotg][PATCH v2 3/3] UBUNTU: [Config] CONFIG_INTEL_ISHTP_VNIC=m Date: Tue, 10 May 2022 20:27:51 +0800 Message-Id: <20220510122751.130033-4-jianhui.lee@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220510122751.130033-1-jianhui.lee@canonical.com> References: <20220510122751.130033-1-jianhui.lee@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Wen-chien Jesse Sung BugLink: https://bugs.launchpad.net/bugs/1943524 Signed-off-by: Wen-chien Jesse Sung (cherry picked from commit 9908be80385551fc321bc09a373072b2a2e8648c linux-intel-5.13) Signed-off-by: Jian Hui Lee --- debian.intel-iotg/config/config.common.ubuntu | 1 + 1 file changed, 1 insertion(+) diff --git a/debian.intel-iotg/config/config.common.ubuntu b/debian.intel-iotg/config/config.common.ubuntu index cf0bf8eb11f7..26794f9929e2 100644 --- a/debian.intel-iotg/config/config.common.ubuntu +++ b/debian.intel-iotg/config/config.common.ubuntu @@ -3551,6 +3551,7 @@ CONFIG_INTEL_IOMMU_SCALABLE_MODE_DEFAULT_ON=y CONFIG_INTEL_IOMMU_SVM=y CONFIG_INTEL_IPS=m CONFIG_INTEL_ISHTP_ECLITE=m +CONFIG_INTEL_ISHTP_VNIC=m CONFIG_INTEL_ISH_FIRMWARE_DOWNLOADER=m CONFIG_INTEL_ISH_HID=m CONFIG_INTEL_LDMA=y