* [PATCH v3 24/27] HFI: hfi_ip network driver
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
It is a separate binary because it is not strictly necessary to use the HFI.
This patch includes module load/unload and the window open/setup with the
hfi device driver.
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/Kconfig | 1 +
drivers/net/hfi/Makefile | 1 +
drivers/net/hfi/ip/Kconfig | 9 +
drivers/net/hfi/ip/Makefile | 6 +
drivers/net/hfi/ip/hf_proto.h | 48 +++
drivers/net/hfi/ip/hfi_ip_main.c | 613 ++++++++++++++++++++++++++++++++++++++
include/linux/hfi/hfi_ip.h | 148 +++++++++
include/linux/if_arp.h | 1 +
8 files changed, 827 insertions(+), 0 deletions(-)
create mode 100644 drivers/net/hfi/ip/Kconfig
create mode 100644 drivers/net/hfi/ip/Makefile
create mode 100644 drivers/net/hfi/ip/hf_proto.h
create mode 100644 drivers/net/hfi/ip/hfi_ip_main.c
create mode 100644 include/linux/hfi/hfi_ip.h
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 1abbfd9..ddae700 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -3437,5 +3437,6 @@ config VMXNET3
module will be called vmxnet3.
source "drivers/net/hfi/core/Kconfig"
+source "drivers/net/hfi/ip/Kconfig"
endif # NETDEVICES
diff --git a/drivers/net/hfi/Makefile b/drivers/net/hfi/Makefile
index 0440cbe..768f27c 100644
--- a/drivers/net/hfi/Makefile
+++ b/drivers/net/hfi/Makefile
@@ -1 +1,2 @@
obj-$(CONFIG_HFI) += core/
+obj-$(CONFIG_HFI_IP) += ip/
diff --git a/drivers/net/hfi/ip/Kconfig b/drivers/net/hfi/ip/Kconfig
new file mode 100644
index 0000000..422782a
--- /dev/null
+++ b/drivers/net/hfi/ip/Kconfig
@@ -0,0 +1,9 @@
+config HFI_IP
+ tristate "IP-over-HFI"
+ depends on NETDEVICES && INET && HFI
+ ---help---
+ Support for IP over HFI. It transports IP
+ packets over HFI.
+
+ To compile the driver as a module, choose M here. The module
+ will be called hfi_ip.
diff --git a/drivers/net/hfi/ip/Makefile b/drivers/net/hfi/ip/Makefile
new file mode 100644
index 0000000..90c7dea
--- /dev/null
+++ b/drivers/net/hfi/ip/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for the HF IP interface for IBM eServer System p
+#
+obj-$(CONFIG_HFI_IP) += hfi_ip.o
+
+hfi_ip-objs := hfi_ip_main.o
diff --git a/drivers/net/hfi/ip/hf_proto.h b/drivers/net/hfi/ip/hf_proto.h
new file mode 100644
index 0000000..b4133b7
--- /dev/null
+++ b/drivers/net/hfi/ip/hf_proto.h
@@ -0,0 +1,48 @@
+/*
+ * hf_proto.h
+ *
+ * HF IP driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _HF_PROTO_H_
+#define _HF_PROTO_H_
+
+extern int hfidd_open_window_func(struct hfidd_acs *p_acs,
+ u32 is_userspace,
+ struct hfi_client_info *user_p,
+ struct hfi_client_info *out_p);
+extern int hfidd_close_window_func(struct hfidd_acs *p_acs,
+ u32 is_userspace,
+ struct hfi_window_info *user_p);
+extern int hfidd_callback_register(struct hfidd_acs *p_acs,
+ struct hfi_reg_events *arg);
+extern int hfidd_callback_unregister(struct hfidd_acs *p_acs,
+ struct hfi_reg_events *arg);
+
+#endif
diff --git a/drivers/net/hfi/ip/hfi_ip_main.c b/drivers/net/hfi/ip/hfi_ip_main.c
new file mode 100644
index 0000000..0c1ebd7
--- /dev/null
+++ b/drivers/net/hfi/ip/hfi_ip_main.c
@@ -0,0 +1,613 @@
+/*
+ * hfi_ip_main.c
+ *
+ * HF IP driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/hfi/hfi_ip.h>
+#include "hf_proto.h"
+
+MODULE_AUTHOR("James Dykman <dykmanj@linux.vnet.ibm.com>, "
+ "Piyush Chaudhary <piyushc@linux.vnet.ibm.com>");
+MODULE_DESCRIPTION("IP driver v" HF_DRV_VERSION " (" HF_DRV_RELDATE ")"
+ " for IBM eServer HFI for System p");
+MODULE_VERSION(HF_DRV_VERSION);
+MODULE_LICENSE("GPL v2");
+
+struct hf_global_info hf_ginfo;
+
+static const u8 hfi_bcast_addr[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+};
+
+static void hf_free_tx_resource(struct hf_if *net_if)
+{
+ int i;
+
+ if (net_if->tx_skb) {
+ for (i = 0; i <= net_if->tx_fifo.emax; i++) {
+ if (net_if->tx_skb[i])
+ dev_kfree_skb_any(net_if->tx_skb[i]);
+ }
+
+ free_pages((unsigned long)(net_if->tx_skb),
+ get_order((net_if->tx_fifo.emax + 1) *
+ sizeof(struct sk_buff *)));
+ net_if->tx_skb = 0;
+ }
+ if (net_if->tx_fifo.addr) {
+ free_pages((unsigned long)(net_if->tx_fifo.addr),
+ get_order(net_if->tx_fifo.size + PAGE_SIZE_4K));
+ net_if->tx_fifo.addr = 0;
+ }
+}
+
+static int hf_alloc_tx_resource(struct hf_net *net)
+{
+ struct hf_if *net_if = &(net->hfif);
+ int i;
+
+ net_if->tx_fifo.size = HF_SFIFO_SIZE;
+ net_if->tx_fifo.head = 0;
+ net_if->tx_fifo.tail = 0;
+ net_if->tx_fifo.emax = HF_SFIFO_SLOTS - 1;
+ atomic_set(&net_if->tx_fifo.avail, HF_SFIFO_SLOTS - 1);
+
+ net_if->tx_fifo.addr =
+ (void *)__get_free_pages(GFP_KERNEL,
+ get_order(net_if->tx_fifo.size + PAGE_SIZE_4K));
+
+ if (net_if->tx_fifo.addr == 0) {
+ netdev_err(net->netdev, "%s: hf_alloc_tx_resource: "
+ "tx_fifo fail, size=0x%x\n",
+ net_if->name, net_if->tx_fifo.size);
+
+ return -ENOMEM;
+ }
+ memset(net_if->tx_fifo.addr, 0, net_if->tx_fifo.size + PAGE_SIZE_4K);
+
+ /* Sfifo finish vector locates at very next page of sfifo */
+ net_if->sfifo_finishvec = net_if->tx_fifo.addr + net_if->tx_fifo.size;
+ net_if->sfifo_fv_polarity = 0;
+ net_if->sfifo_slots_per_blk = HF_SFIFO_SLOTS / HF_FV_BIT_CNT;
+
+ /* allocate array to hold the tx skbs */
+ net_if->tx_skb =
+ (struct sk_buff **)__get_free_pages(GFP_KERNEL,
+ get_order((net_if->tx_fifo.emax + 1) *
+ sizeof(struct sk_buff *)));
+
+ if (net_if->tx_skb == 0) {
+ netdev_err(net->netdev,
+ "%s: hf_alloc_tx_resource: tx_skb failed\n",
+ net_if->name);
+
+ goto err_out;
+ }
+
+ for (i = 0; i <= net_if->tx_fifo.emax; i++)
+ net_if->tx_skb[i] = NULL;
+
+ return 0;
+
+err_out:
+ hf_free_tx_resource(net_if);
+
+ return -ENOMEM;
+}
+
+static void hf_free_rx_resource(struct hf_if *net_if)
+{
+ if (net_if->rx_fifo.addr) {
+ free_pages((unsigned long)(net_if->rx_fifo.addr),
+ get_order(net_if->rx_fifo.size));
+ net_if->rx_fifo.addr = 0;
+ }
+}
+
+static int hf_alloc_rx_resource(struct hf_net *net)
+{
+ struct hf_if *net_if = &(net->hfif);
+
+ net_if->rx_fifo.size = HF_RFIFO_SIZE;
+ net_if->rx_fifo.head = 0;
+ net_if->rx_fifo.tail = 0;
+ net_if->rx_fifo.emax = HF_RFIFO_SLOTS - 1;
+
+ net_if->rx_fifo.addr =
+ (void *)__get_free_pages(GFP_KERNEL,
+ get_order(net_if->rx_fifo.size));
+
+ if (net_if->rx_fifo.addr == 0) {
+ netdev_err(net->netdev,
+ "%s: hf_alloc_rx_resource: fail, size=0x%x\n",
+ net_if->name, net_if->rx_fifo.size);
+
+ return -ENOMEM;
+ }
+
+ memset(net_if->rx_fifo.addr, 0, net_if->rx_fifo.size);
+
+ return 0;
+}
+
+static void hf_free_resource(struct hf_if *net_if)
+{
+ hf_free_rx_resource(net_if);
+
+ hf_free_tx_resource(net_if);
+}
+
+static int hf_alloc_resource(struct hf_net *net)
+{
+ int rc;
+ struct hf_if *net_if = &(net->hfif);
+
+ rc = hf_alloc_tx_resource(net);
+ if (rc)
+ goto alloc_resource_err0;
+
+ rc = hf_alloc_rx_resource(net);
+ if (rc)
+ goto alloc_resource_err1;
+
+ return 0;
+
+alloc_resource_err1:
+ hf_free_tx_resource(net_if);
+alloc_resource_err0:
+ return rc;
+}
+
+static int hf_close_ip_window(struct hf_net *net, struct hfidd_acs *p_acs)
+{
+ struct hf_if *net_if = &(net->hfif);
+ int rc;
+
+ if (net_if->doorbell) {
+ iounmap(net_if->doorbell);
+ net_if->doorbell = NULL;
+ }
+
+ /* Fill in the request structure */
+ net_if->client.hdr.req = HFIDD_REQ_CLOSE_WINDOW;
+ net_if->client.hdr.req_len = sizeof(struct hfi_window_info);
+ net_if->client.hdr.result.use.kptr = &(net_if->client);
+
+ rc = hfidd_close_window_func(HF_ACS(net_if), 0,
+ (struct hfi_window_info *)(&(net_if->client)));
+ if (rc) {
+ netdev_err(net->netdev,
+ "%s: hf_close_ip_window: fail, rc=0x%x\n",
+ net_if->name, rc);
+ return rc;
+ }
+
+ return 0;
+}
+
+static int hf_open_ip_window(struct hf_net *net,
+ struct hfidd_acs *p_acs)
+{
+ struct hf_if *net_if = &(net->hfif);
+ int rc = 0;
+
+ net_if->client.win_type = HFIDD_IP_WIN;
+
+ net_if->client.sfifo.eaddr.use.kptr = net_if->tx_fifo.addr;
+ net_if->client.sfifo.size = net_if->tx_fifo.size;
+ net_if->client.rfifo.eaddr.use.kptr = net_if->rx_fifo.addr;
+ net_if->client.rfifo.size = net_if->rx_fifo.size;
+ net_if->client.sfifo_finish_vec.use.kptr = net_if->sfifo_finishvec;
+ net_if->client.job_id = HF_IP_JOBID;
+
+ /* Fill in the request structure */
+ net_if->client.hdr.req = HFIDD_REQ_OPEN_WINDOW;
+ net_if->client.hdr.req_len = sizeof(struct hfi_client_info);
+ net_if->client.hdr.result.use.kptr = &(net_if->client);
+
+ rc = hfidd_open_window_func(p_acs, 0, &(net_if->client),
+ &(net_if->client));
+ if (rc) {
+ netdev_err(net->netdev,
+ "%s: hf_open_ip_window: fail open rc=0x%x\n",
+ net_if->name, rc);
+ return rc;
+ }
+
+ net_if->doorbell = (ioremap(
+ (u64)(net_if->client.mmio_regs.use.kptr), PAGE_SIZE_64K));
+
+ if (unlikely(net_if->doorbell == NULL)) {
+ netdev_err(net->netdev,
+ "%s: hf_open_ip_window: fail to map doorbell\n",
+ net_if->name);
+ hf_close_ip_window(net, p_acs);
+ }
+
+ net_if->isr_id = net_if->client.local_isrid;
+
+ return 0;
+}
+
+static int hf_set_mac_addr(struct net_device *netdev, void *p)
+{
+ struct hf_net *net = netdev_priv(netdev);
+ struct hf_if *net_if = &(net->hfif);
+
+ /* Mac address format: 02:ClusterID:ISR:ISR:HFI_WIN:WIN */
+
+ /* Locally administered MAC address */
+ netdev->dev_addr[0] = 0x2; /* bit6=1, bit7=0 */
+
+ netdev->dev_addr[1] = 0x0; /* cluster id */
+
+ *(u16 *)(&(netdev->dev_addr[2])) = (u16)(net_if->isr_id);
+
+ *(u16 *)(&(netdev->dev_addr[4])) = (u16)
+ (((net_if->ai) << HF_MAC_HFI_SHIFT) | (net_if->client.window));
+
+ return 0;
+}
+
+static int hf_net_delayed_open(void *parm, u16 win, u16 ext)
+{
+ struct net_device *netdev = (struct net_device *)parm;
+ struct hf_net *net = netdev_priv(netdev);
+ struct hf_if *net_if = &(net->hfif);
+ int rc = 0;
+ struct hfidd_acs *p_acs = HF_ACS(net_if);
+
+ spin_lock(&(net_if->lock));
+ if (net_if->state != HF_NET_HALF_OPEN) {
+ netdev_err(netdev, "hf_net_delayed_open: net_if state=0x%x\n",
+ net_if->state);
+ spin_unlock(&(net_if->lock));
+ return -EINVAL;
+ }
+
+ rc = hf_alloc_resource(net);
+ if (rc)
+ goto delayed_open_err0;
+
+ rc = hf_open_ip_window(net, p_acs);
+ if (rc)
+ goto delayed_open_err1;
+
+ hf_set_mac_addr(netdev, NULL);
+
+ net_if->state = HF_NET_OPEN;
+ spin_unlock(&(net_if->lock));
+
+ return 0;
+
+delayed_open_err1:
+ hf_free_resource(net_if);
+
+delayed_open_err0:
+ spin_unlock(&(net_if->lock));
+
+ return rc;
+}
+
+static int hf_register_hfi_ready_callback(struct net_device *netdev,
+ struct hfidd_acs *p_acs,
+ int flag)
+{
+ struct hfi_reg_events reg_events;
+ int rc = 0;
+
+ reg_events.hdr.req = flag;
+ reg_events.hdr.req_len = sizeof(struct hfi_reg_events);
+ reg_events.hdr.result.use.kptr = NULL;
+ reg_events.type = FUNCTIONS_FOR_EVENTS;
+
+ reg_events.info.func.index = HFIDD_HFI_READY_REG;
+ reg_events.info.func.function_p.use.kptr = hf_net_delayed_open;
+ reg_events.info.func.parameter.use.kptr = (void *)(netdev);
+
+ if (flag == HFIDD_REQ_EVENT_REGISTER)
+ rc = hfidd_callback_register(p_acs, ®_events);
+ else
+ rc = hfidd_callback_unregister(p_acs, ®_events);
+ if (rc) {
+ netdev_err(netdev, "hf_register_hfi_ready_callback: fail"
+ " flag=0x%x rc=0x%x\n", flag, rc);
+
+ return rc;
+ }
+
+ return 0;
+}
+
+static int hf_net_open(struct net_device *netdev)
+{
+ struct hf_net *net = netdev_priv(netdev);
+ struct hf_if *net_if = &(net->hfif);
+ int rc = 0;
+ struct hfidd_acs *p_acs = HF_ACS(net_if);
+
+ memset(&(netdev->stats), 0, sizeof(struct net_device_stats));
+ net_if->sfifo_packets = 0;
+
+ spin_lock(&(net_if->lock));
+ net_if->state = HF_NET_HALF_OPEN;
+ spin_unlock(&(net_if->lock));
+
+ netif_carrier_off(netdev);
+
+ rc = hf_register_hfi_ready_callback(netdev, p_acs,
+ HFIDD_REQ_EVENT_REGISTER);
+ if (rc != 0) {
+ spin_lock(&(net_if->lock));
+ net_if->state = HF_NET_CLOSE;
+ spin_unlock(&(net_if->lock));
+
+ netdev_err(netdev, "hf_net_open: hf_register_hfi_ready_callback"
+ "fail, rc=0x%x, state=0x%x", rc, net_if->state);
+ return rc;
+ }
+
+ return 0;
+}
+
+static int hf_net_close(struct net_device *netdev)
+{
+ struct hf_net *net = netdev_priv(netdev);
+ struct hf_if *net_if = &(net->hfif);
+ struct hfidd_acs *p_acs = HF_ACS(net_if);
+
+ spin_lock(&(net_if->lock));
+ if (net_if->state == HF_NET_OPEN) {
+ hf_close_ip_window(net, p_acs);
+
+ hf_free_resource(net_if);
+ }
+
+ hf_register_hfi_ready_callback(netdev, p_acs,
+ HFIDD_REQ_EVENT_UNREGISTER);
+
+ net_if->state = HF_NET_CLOSE;
+ spin_unlock(&(net_if->lock));
+
+ return 0;
+}
+
+static int hf_change_mtu(struct net_device *netdev, int new_mtu)
+{
+ if ((new_mtu <= 68) || (new_mtu > HF_NET_MTU))
+ return -ERANGE;
+
+ netdev->mtu = new_mtu;
+
+ return 0;
+}
+
+static int hf_hard_header(struct sk_buff *skb,
+ struct net_device *netdev,
+ u16 type,
+ const void *daddr,
+ const void *saddr,
+ u32 len)
+{
+ struct ethhdr *hwhdr_p;
+
+ skb_push(skb, ETH_HLEN);
+
+ hwhdr_p = (struct ethhdr *)(skb->data);
+ hwhdr_p->h_proto = htons(type);
+
+ if (!saddr)
+ saddr = netdev->dev_addr;
+
+ memcpy(hwhdr_p->h_source, saddr, netdev->addr_len);
+
+ if (daddr) {
+ memcpy(hwhdr_p->h_dest, daddr, netdev->addr_len);
+ return netdev->hard_header_len;
+ }
+
+ if (netdev->flags & IFF_NOARP) {
+ memset(hwhdr_p->h_dest, 0, netdev->addr_len);
+ return netdev->hard_header_len;
+ }
+
+ return -netdev->hard_header_len;
+}
+
+static const struct header_ops hf_header_ops = {
+ .create = hf_hard_header,
+};
+
+static const struct net_device_ops hf_netdev_ops = {
+ .ndo_open = hf_net_open,
+ .ndo_stop = hf_net_close,
+ .ndo_change_mtu = hf_change_mtu,
+ .ndo_set_mac_address = NULL,
+};
+
+static void hf_if_setup(struct net_device *netdev)
+{
+ netdev->type = ARPHRD_HFI;
+ netdev->mtu = HF_NET_MTU;
+ netdev->tx_queue_len = 1000;
+ netdev->flags = IFF_BROADCAST;
+ netdev->hard_header_len = ETH_HLEN;
+ netdev->addr_len = ETH_ALEN;
+ netdev->needed_headroom = 0;
+
+ netdev->header_ops = &hf_header_ops;
+ netdev->netdev_ops = &hf_netdev_ops;
+
+ memcpy(netdev->broadcast, hfi_bcast_addr, ETH_ALEN);
+}
+
+static struct hf_net *hf_init_netdev(int idx, int ai)
+{
+ struct net_device *netdev;
+ struct hf_net *net;
+ int ii;
+ int rc;
+ char ifname[HF_MAX_NAME_LEN];
+
+ ii = (idx * MAX_HFIS) + ai;
+ sprintf(ifname, "hf%d", ii);
+ netdev = alloc_netdev(sizeof(struct hf_net), ifname, hf_if_setup);
+ if (!netdev) {
+ printk(KERN_ERR "hf_init_netdev: "
+ "alloc_netdev for hfi%d:hf%d fail\n", ai, idx);
+ return ERR_PTR(-ENODEV);
+ }
+
+ net = netdev_priv(netdev);
+ net->netdev = netdev;
+
+ memset(&(net->hfif), 0, sizeof(struct hf_if));
+ net->hfif.idx = ii; /* interface index */
+ net->hfif.ai = ai; /* adapter index */
+ strncpy(net->hfif.name, ifname, HF_MAX_NAME_LEN);
+ net->hfif.state = HF_NET_CLOSE;
+
+ spin_lock_init(&net->hfif.lock);
+
+ rc = register_netdev(netdev);
+ if (rc) {
+ netdev_err(netdev, "hf_init_netdev: "
+ "failed to register netdev=hfi%d:hf%d, "
+ "rc = 0x%x\n", ai, idx, rc);
+ free_netdev(netdev);
+ return ERR_PTR(-ENODEV);
+ }
+
+ return net;
+}
+
+static void hf_del_netdev(struct hf_net *net)
+{
+ struct net_device *netdev = net->netdev;
+
+ unregister_netdev(netdev);
+
+ free_netdev(netdev);
+}
+
+static int hf_inet_event(struct notifier_block *this,
+ unsigned long event,
+ void *ifa)
+{
+ struct in_device *in_dev;
+ struct net_device *netdev;
+
+ in_dev = ((struct in_ifaddr *)ifa)->ifa_dev;
+
+ netdev = in_dev->dev;
+
+ if (!net_eq(dev_net(netdev), &init_net))
+ return NOTIFY_DONE;
+
+ if ((event == NETDEV_UP) && (netdev->netdev_ops == &hf_netdev_ops)) {
+ struct hf_if *net_if;
+
+ net_if = &(((struct hf_net *)(netdev_priv(netdev)))->hfif);
+ net_if->ip_addr = ntohl(in_dev->ifa_list->ifa_address);
+ }
+
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block hf_inet_notifier = {
+ .notifier_call = hf_inet_event,
+};
+
+static int __init hf_init_module(void)
+{
+ u32 idx, ai;
+ int rc;
+ struct hf_net *net;
+
+ memset(&hf_ginfo, 0, sizeof(struct hf_global_info));
+
+ for (idx = 0; idx < MAX_HF_PER_HFI; idx++) {
+ for (ai = 0; ai < MAX_HFIS; ai++) {
+ net = hf_init_netdev(idx, ai);
+ if (IS_ERR(net)) {
+ printk(KERN_ERR "hf_init_module: hf_init_netdev"
+ " for idx %d ai %d failed rc"
+ " %ld\n",
+ idx, ai, PTR_ERR(net));
+
+ goto err_out;
+ }
+
+ hf_ginfo.net[idx][ai] = net;
+ }
+ }
+
+ register_inetaddr_notifier(&hf_inet_notifier);
+
+ printk(KERN_INFO "hfi_ip module loaded\n");
+ return 0;
+
+err_out:
+ rc = PTR_ERR(net);
+ for (idx = 0; idx < MAX_HF_PER_HFI; idx++) {
+ for (ai = 0; ai < MAX_HFIS; ai++) {
+ net = hf_ginfo.net[idx][ai];
+ if (net != NULL) {
+ hf_del_netdev(net);
+ hf_ginfo.net[idx][ai] = NULL;
+ }
+ }
+ }
+
+ return rc;
+}
+
+static void __exit hf_cleanup_module(void)
+{
+ u32 idx, ai;
+ struct hf_net *net;
+
+ unregister_inetaddr_notifier(&hf_inet_notifier);
+ for (idx = 0; idx < MAX_HF_PER_HFI; idx++) {
+ for (ai = 0; ai < MAX_HFIS; ai++) {
+
+ net = hf_ginfo.net[idx][ai];
+ if (net != NULL) {
+ hf_del_netdev(net);
+ hf_ginfo.net[idx][ai] = NULL;
+ }
+ }
+ }
+
+ return;
+}
+
+module_init(hf_init_module);
+module_exit(hf_cleanup_module);
diff --git a/include/linux/hfi/hfi_ip.h b/include/linux/hfi/hfi_ip.h
new file mode 100644
index 0000000..6b6a74c
--- /dev/null
+++ b/include/linux/hfi/hfi_ip.h
@@ -0,0 +1,148 @@
+/*
+ * hfi_ip.h
+ *
+ * HF IP driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <wcchen@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _HFI_IP_H_
+#define _HFI_IP_H_
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/netdevice.h>
+#include <linux/inetdevice.h>
+#include <net/arp.h>
+
+#include <linux/hfi/hfidd_internal.h>
+#include <linux/hfi/hfidd_client.h>
+#include <linux/hfi/hfidd_requests.h>
+#include <linux/hfi/hfidd_pkt_formats.h>
+
+#define HF_DRV_VERSION "1.0"
+#define HF_DRV_RELDATE "July 7, 2010"
+#define HF_DRV_NAME "hf"
+
+#define MAX_HF_PER_HFI 2
+#define HF_IP_JOBID 0xFFFFFFF0
+#define HF_MAX_NAME_LEN 64
+
+#define HF_SFIFO_SIZE 0x40000 /* 256K */
+#define HF_SFIFO_SLOTS (HF_SFIFO_SIZE >> HFI_CACHE_LINE_SHIFT)
+#define HF_RFIFO_SIZE 0x1000000 /* 16M */
+#define HF_RFIFO_SLOTS (HF_RFIFO_SIZE >> HFI_CACHE_LINE_SHIFT)
+
+#define HF_FV_BIT_CNT 32
+
+#define HF_NET_MTU (2048 - HF_IP_HDR_LEN - HF_PROTO_LEN)
+
+struct hfi_ip_extended_hdr { /* 16B */
+ unsigned int immediate_len:7;/* In bytes */
+ unsigned int num_desc:3; /* number of descriptors */
+ /* Logical Port ID: */
+ unsigned int lpid_valid:1; /* set by sending HFI */
+ unsigned int lpid:4; /* set by sending HFI */
+ /* Ethernet Service Header is 113 bits, which is 14 bytes + 1 bit */
+ unsigned int ethernet_svc_hdr_hi:1; /* Not used by HFI */
+ char ethernet_svc_hdr[12]; /* Not used by HFI */
+ __sum16 bcast_csum;
+} __packed;
+
+struct hfi_ip_with_payload_pkt {
+ struct hfi_hdr hfi_hdr;
+ struct hfi_ip_extended_hdr ip_ext;
+ char payload[2016];
+} __packed;
+
+#define HF_IP_HDR_LEN ((sizeof(struct hfi_hdr) + \
+ sizeof(struct hfi_ip_extended_hdr)))
+#define HF_ALIGN_PAD 2
+
+struct hf_if_proto_hdr {
+ u16 version;
+ u8 msg_type;
+ u8 msg_flag;
+ u32 msg_len; /* Include HFI header */
+ u32 msg_id;
+};
+
+#define HF_PROTO_LEN sizeof(struct hf_if_proto_hdr)
+
+struct hf_fifo {
+ void *addr;
+ u32 size; /* total bytes */
+ u32 head;
+ u32 tail;
+ u32 emax; /* power 2 mask */
+ atomic_t avail; /* for tx */
+ atomic_t outstanding; /* for rx */
+};
+
+#define HF_NET_CLOSE 0x00
+#define HF_NET_HALF_OPEN 0xA0
+#define HF_NET_OPEN 0xA1
+
+struct hf_if {
+ u32 idx; /* 0, 1, 2, 3 ... */
+ u32 ai; /* 0=hfi0, 1=hfi1 */
+ char name[HF_MAX_NAME_LEN];
+ u32 isr_id;
+ u32 ip_addr;
+ u32 state; /* CLOSE, OPEN */
+ spinlock_t lock; /* lock for state */
+ u32 sfifo_fv_polarity;
+ u32 sfifo_slots_per_blk;
+ u32 sfifo_packets;
+ void __iomem *doorbell; /* mapped mmio_regs */
+ struct hf_fifo tx_fifo;
+ struct hf_fifo rx_fifo;
+ struct hfi_client_info client;
+ struct sk_buff **tx_skb; /* array to store tx
+ 2k skb */
+ void *sfifo_finishvec;
+};
+
+/* Private structure for HF inetrface */
+struct hf_net {
+ struct net_device *netdev;
+ struct hf_if hfif;
+};
+
+extern struct hfidd_global hfidd_global;
+
+#define HF_ACS(net_if) (hfidd_global.p_acs[(net_if)->ai])
+
+struct hf_global_info {
+ struct hf_net *net[MAX_HF_PER_HFI][MAX_HFI_PER_TORRENT];
+};
+
+extern struct hf_global_info hf_ginfo;
+
+#define HF_MAC_HFI_SHIFT 12
+#endif
diff --git a/include/linux/if_arp.h b/include/linux/if_arp.h
index 6d722f4..f2cfdc1 100644
--- a/include/linux/if_arp.h
+++ b/include/linux/if_arp.h
@@ -41,6 +41,7 @@
#define ARPHRD_IEEE1394 24 /* IEEE 1394 IPv4 - RFC 2734 */
#define ARPHRD_EUI64 27 /* EUI-64 */
#define ARPHRD_INFINIBAND 32 /* InfiniBand */
+#define ARPHRD_HFI 37 /* Host Fabric Interface */
/* Dummy types for non ARP hardware */
#define ARPHRD_SLIP 256
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 13/27] HFI: Send and receive fifo address translation
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Prepare for a hypervisor call to set up page tables in the nMMU for the
send and receive fifo.
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/hfidd_proto.h | 9 ++
drivers/net/hfi/core/hfidd_window.c | 132 ++++++++++++++++++++++
drivers/net/hfi/core/hfidd_xlat.c | 210 +++++++++++++++++++++++++++++++++++
include/linux/hfi/hfidd_adpt.h | 28 +++++
include/linux/hfi/hfidd_hcalls.h | 2 +
include/linux/hfi/hfidd_internal.h | 1 +
include/linux/hfi/hfidd_xlat_map.h | 91 +++++++++++++++
7 files changed, 473 insertions(+), 0 deletions(-)
create mode 100644 include/linux/hfi/hfidd_xlat_map.h
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
index 66ea5da..001f6d5 100644
--- a/drivers/net/hfi/core/hfidd_proto.h
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -39,9 +39,18 @@ int hfidd_alloc_windows(struct hfidd_acs *p_acs);
void hfidd_free_windows(struct hfidd_acs *p_acs);
int hfidd_init_adapter(struct hfidd_acs *p_acs, void *uiop);
int hfidd_age_hcall(u64 time_start);
+int hfidd_fifo_xlat(struct hfidd_acs *p_acs, struct fifo_info *fifo_in,
+ int is_userspace, struct hfidd_vlxmem *xlat_p);
+int hfidd_fifo_unxlat(struct hfidd_acs *p_acs, struct fifo_info *fifo_in,
+ int is_userspace, struct hfidd_vlxmem *xlat_p);
+int hfidd_fill_xlat_tab(struct hfidd_acs *p_acs, struct fifo_info *fifo_in,
+ unsigned int is_userspace, struct hfidd_vlxmem *xlat_p);
int hfidd_get_page_size(struct hfidd_acs *p_acs, void *addr,
unsigned int is_userspace, unsigned int length,
unsigned long long *page_size);
+int hfidd_get_page_num(struct hfidd_acs *p_acs, void *start_addr,
+ unsigned long long len, unsigned long long page_sz,
+ unsigned int *pg_num_p);
int hfidd_open_window_func(struct hfidd_acs *p_acs, unsigned int is_userspace,
struct hfi_client_info *user_p,
struct hfi_client_info *out_p);
diff --git a/drivers/net/hfi/core/hfidd_window.c b/drivers/net/hfi/core/hfidd_window.c
index 5a4f395..de2e56d 100644
--- a/drivers/net/hfi/core/hfidd_window.c
+++ b/drivers/net/hfi/core/hfidd_window.c
@@ -359,6 +359,125 @@ static int hfi_validate_window_parm(struct hfidd_acs *p_acs,
return 0;
}
+static int hfi_xlate_fifos(struct hfidd_acs *p_acs,
+ unsigned int is_userspace,
+ struct hfidd_window *win_p,
+ struct hfi_client_info *client_p)
+{
+ int rc = 0;
+
+ /*
+ * add 4K(finish vector) to the sfifo size then call to
+ * xlate when return, restore the sfifo size back..............
+ */
+ client_p->sfifo.size += PAGE_SIZE_4K;
+ rc = hfidd_fifo_xlat(p_acs, &(client_p->sfifo), is_userspace,
+ win_p->sfifo_x_tab);
+ client_p->sfifo.size -= PAGE_SIZE_4K;
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_xlate_fifos: hfidd_fifo_xlat failed, "
+ "rc = 0x%x\n", rc);
+ return rc;
+ }
+
+ rc = hfidd_fifo_xlat(p_acs, &(client_p->rfifo), is_userspace,
+ win_p->rfifo_x_tab);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_xlate_fifos: hfidd_fifo_xlat failed, "
+ "rc = 0x%x\n", rc);
+ goto hfi_xlate_fifos_err1;
+ }
+
+hfi_xlate_fifos_err1:
+ client_p->sfifo.size += PAGE_SIZE_4K;
+ hfidd_fifo_unxlat(p_acs, &(client_p->sfifo), is_userspace,
+ win_p->sfifo_x_tab);
+ client_p->sfifo.size -= PAGE_SIZE_4K;
+
+ return rc;
+}
+
+int hfi_unxlate_fifos(struct hfidd_acs *p_acs, unsigned int is_userspace,
+ struct hfidd_window *win_p, struct hfi_client_info *client_p)
+{
+ int rc = 0;
+
+ hfidd_fifo_unxlat(p_acs, &(client_p->rfifo),
+ is_userspace, win_p->rfifo_x_tab);
+
+ client_p->sfifo.size += PAGE_SIZE_4K;
+ hfidd_fifo_unxlat(p_acs, &(client_p->sfifo),
+ is_userspace, win_p->sfifo_x_tab);
+ client_p->sfifo.size -= PAGE_SIZE_4K;
+
+ return rc;
+}
+
+static inline void hfi_free_xlate_tab(struct hfidd_window *win_p)
+{
+ kfree(win_p->sfifo_x_tab);
+ win_p->sfifo_x_tab = NULL;
+ kfree(win_p->rfifo_x_tab);
+ win_p->rfifo_x_tab = NULL;
+}
+
+static int hfi_alloc_xlate_tab(struct hfidd_acs *p_acs,
+ struct hfidd_window *win_p,
+ struct hfi_client_info *client_p)
+{
+ win_p->sfifo_x_tab = kzalloc(sizeof(*(win_p->sfifo_x_tab)),
+ GFP_KERNEL);
+ if (win_p->sfifo_x_tab == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_alloc_xlate_tab: kzalloc sfifo_x_tab failed\n");
+ return -ENOMEM;
+ }
+
+ win_p->rfifo_x_tab = kzalloc(sizeof(*(win_p->rfifo_x_tab)),
+ GFP_KERNEL);
+ if (win_p->rfifo_x_tab == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_alloc_xlate_tab: kzalloc rfifo_x_tab failed\n");
+ goto hfi_alloc_xlate_tab_err1;
+ }
+
+ return 0;
+
+hfi_alloc_xlate_tab_err1:
+ kfree(win_p->sfifo_x_tab);
+ win_p->sfifo_x_tab = NULL;
+ return -ENOMEM;
+}
+
+static int hfi_alloc_win_resource(struct hfidd_acs *p_acs,
+ unsigned int is_userspace,
+ struct hfidd_window *win_p,
+ struct hfi_client_info *client_p)
+{
+ int rc = 0;
+
+ rc = hfi_alloc_xlate_tab(p_acs, win_p, client_p);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_alloc_win_resource: hfi_alloc_xlate_tab "
+ "failed, rc = 0x%x\n", rc);
+ return rc;
+ }
+
+ rc = hfi_xlate_fifos(p_acs, is_userspace, win_p, client_p);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_alloc_win_resource: hfi_xlate_fifos "
+ "failed, rc = 0x%x\n", rc);
+ hfi_free_xlate_tab(win_p);
+ return rc;
+ }
+
+ return 0;
+}
+
/*
* Allows an user/kernel window to send/receive network traffic thru HFI
* adapter. This function will allocate the system resources needed to open
@@ -371,6 +490,7 @@ int hfidd_open_window_func(struct hfidd_acs *p_acs, unsigned int is_userspace,
{
int rc = 0;
struct hfi_client_info *local_p = NULL;
+ struct hfidd_window *win_p = NULL;
/* Allocate local data structure */
local_p = kmalloc(sizeof(struct hfi_client_info), GFP_KERNEL);
@@ -398,9 +518,21 @@ int hfidd_open_window_func(struct hfidd_acs *p_acs, unsigned int is_userspace,
goto hfidd_open_window_func_err1;
}
+ win_p = hfi_window(p_acs, local_p->window);
+
+ rc = hfi_alloc_win_resource(p_acs, is_userspace, win_p, local_p);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_open_window_func: hfi_alloc_win_resource "
+ "failed, rc = 0x%x\n", rc);
+ goto hfidd_open_window_func_err2;
+ }
+
kfree(local_p);
return rc;
+hfidd_open_window_func_err2:
+ hfi_restore_window_parm(p_acs, win_p);
hfidd_open_window_func_err1:
kfree(local_p);
return rc;
diff --git a/drivers/net/hfi/core/hfidd_xlat.c b/drivers/net/hfi/core/hfidd_xlat.c
index 23236cc..760d7e6 100644
--- a/drivers/net/hfi/core/hfidd_xlat.c
+++ b/drivers/net/hfi/core/hfidd_xlat.c
@@ -129,3 +129,213 @@ out1:
kfree(page_list);
return rc;
}
+
+int hfidd_get_page_num(struct hfidd_acs *p_acs,
+ void *start_addr,
+ unsigned long long len,
+ unsigned long long page_sz,
+ unsigned int *pg_num_p)
+{
+ int rc = 0;
+ int pg_shift_count;
+ unsigned long long address_mask;
+ unsigned long long offset_mask;
+ unsigned long long offset;
+
+ if (pg_num_p == NULL || len == 0) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_get_page_num: len=%llx pg_num_p=0x%llx\n",
+ len, (unsigned long long)pg_num_p);
+ return -EINVAL;
+ }
+
+ /*
+ * Pre-Calculate Masks and shift count:
+ */
+ if (page_sz == PAGE_SIZE_4K) {
+ offset_mask = PAGE_MASK_4K;
+ pg_shift_count = PAGE_SHIFT_4K;
+ } else if (page_sz == PAGE_SIZE_64K) {
+ offset_mask = PAGE_MASK_64K;
+ pg_shift_count = PAGE_SHIFT_64K;
+ } else if (page_sz == PAGE_SIZE_16M) {
+ offset_mask = PAGE_MASK_16M;
+ pg_shift_count = PAGE_SHIFT_16M;
+ } else if (page_sz == PAGE_SIZE_4G) {
+ offset_mask = PAGE_MASK_4G;
+ pg_shift_count = PAGE_SHIFT_4G;
+ } else {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_get_page_num: invalid page_sz 0x%llx "
+ "return EINVAL\n", page_sz);
+ return -EINVAL;
+ }
+ address_mask = ~offset_mask;
+
+ /*
+ * Calculate the buffer offsets into the first page:
+ */
+ offset = (unsigned long long)start_addr & offset_mask;
+ *pg_num_p = (len + offset + offset_mask) >> pg_shift_count;
+
+ return rc;
+}
+
+int hfidd_fill_xlat_tab(struct hfidd_acs *p_acs, struct fifo_info *fifo_in,
+ unsigned int is_userspace, struct hfidd_vlxmem *xlat_p)
+{
+ unsigned int num_pages;
+ unsigned long long page_size;
+ int rc = 0;
+
+ rc = hfidd_get_page_size(p_acs, fifo_in->eaddr.use.kptr, is_userspace,
+ fifo_in->size, &page_size);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_fill_xlat_tab: hfidd_get_page_size failed, "
+ " rc=0x%x\n", rc);
+ return rc;
+ }
+
+ /* Get num of pages based in buffer page size */
+ rc = hfidd_get_page_num(p_acs, fifo_in->eaddr.use.kptr,
+ fifo_in->size, page_size, &num_pages);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_fill_xlat_tab:: hfidd_get_page_num return "
+ "rc 0x%x\n", rc);
+ return rc;
+ }
+
+ xlat_p->v_addr = (caddr_t)(fifo_in->eaddr.use.kptr);
+ xlat_p->e_addr = (caddr_t)(fifo_in->eaddr.use.allu & ~(page_size - 1));
+ xlat_p->page_sz = page_size;
+ xlat_p->num_page = num_pages;
+ xlat_p->len = num_pages * page_size;
+ xlat_p->num_kpage = (xlat_p->len) / PAGE_SIZE;
+
+ return 0;
+}
+
+int hfidd_fifo_xlat(struct hfidd_acs *p_acs, struct fifo_info *fifo_in,
+ int is_userspace, struct hfidd_vlxmem *xlat_p)
+{
+ int rc = 0;
+ int i;
+ unsigned int num_pages, pg_code;
+ unsigned long long page_size;
+ unsigned long long *l_pages;
+ struct page **page_list;
+ unsigned int hw_page = 0;
+
+ if ((fifo_in == NULL) || (xlat_p == NULL)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_fifo_xlat: Invalid fifo_in 0x%llx\n",
+ (unsigned long long)fifo_in);
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_fifo_xlat: Invalid xlat_p 0x%llx\n",
+ (unsigned long long)xlat_p);
+ return -EINVAL;
+ }
+
+ rc = hfidd_fill_xlat_tab(p_acs, fifo_in, is_userspace, xlat_p);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_fifo_xlat: hfidd_fill_xlat_tab failed, "
+ "rc = 0x%x\n", rc);
+ return rc;
+ }
+
+ /* num_page is number of pages of page_sz */
+ num_pages = xlat_p->num_page;
+ page_size = xlat_p->page_sz;
+
+ l_pages = vmalloc(num_pages * sizeof(unsigned long long));
+ if (l_pages == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_fifo_xlat: vmalloc failed for l_pages\n");
+ return -ENOMEM;
+ }
+
+ if (!is_userspace) {
+ void *curr_addr = xlat_p->e_addr;
+
+ for (i = 0; i < num_pages; i++) {
+ l_pages[i] = __pa(curr_addr);
+ curr_addr += page_size;
+ }
+ } else {
+ /* For page_list use number of kernel pages */
+ page_list = kzalloc(xlat_p->num_kpage * sizeof(struct page *),
+ GFP_KERNEL);
+ if (page_list == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_fifo_xlat: kzalloc failed "
+ "for page_list\n");
+ rc = -ENOMEM;
+ goto out_err0;
+ }
+
+ down_read(¤t->mm->mmap_sem);
+ rc = get_user_pages(current, current->mm,
+ (unsigned long long)(xlat_p->e_addr),
+ xlat_p->num_kpage, 1, 0, /* write, !force */
+ page_list, NULL);
+ up_read(¤t->mm->mmap_sem);
+
+ if (rc < xlat_p->num_kpage) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_fifo_xlat: get_user_pages failed, "
+ "rc = 0x%x\n", rc);
+ goto out_err1;
+ }
+
+ for (i = 0; i < num_pages;) {
+ l_pages[hw_page] = page_to_phys(page_list[i]);
+ hw_page++;
+ i += (page_size / PAGE_SIZE);
+ }
+
+ xlat_p->page_list = (void *)page_list;
+ }
+
+ xlat_p->l_pages = (void *)l_pages;
+ xlat_p->map_page_sz = page_size;
+ xlat_p->m_addr = xlat_p->e_addr;
+ xlat_p->num_page_sz.num_code.fields.pg_num = num_pages;
+ encode_pg_sz(page_size, &pg_code);
+ xlat_p->num_page_sz.num_code.fields.pg_code =
+ (pg_code << HFI_PAGE_CODE_SHIFT);
+ return 0;
+
+out_err1:
+ if (rc > 0) {
+ for (i = 0; i < rc; i++)
+ page_cache_release(page_list[i]);
+ rc = -EINVAL;
+ }
+ kfree(page_list);
+out_err0:
+ vfree(l_pages);
+ return rc;
+}
+
+int hfidd_fifo_unxlat(struct hfidd_acs *p_acs, struct fifo_info *fifo_in,
+ int is_userspace, struct hfidd_vlxmem *xlat_p)
+{
+ int rc = 0;
+ int i;
+ struct page **page_list;
+
+ if (!is_userspace)
+ return 0;
+ page_list = (struct page **)xlat_p->page_list;
+ if (page_list != NULL) {
+ /* For page list we used number of kernel pages */
+ for (i = 0; i < xlat_p->num_kpage; i++)
+ page_cache_release(page_list[i]);
+ kfree(page_list);
+ xlat_p->page_list = NULL;
+ }
+ return rc;
+}
diff --git a/include/linux/hfi/hfidd_adpt.h b/include/linux/hfi/hfidd_adpt.h
index a41825f..8eab059 100644
--- a/include/linux/hfi/hfidd_adpt.h
+++ b/include/linux/hfi/hfidd_adpt.h
@@ -74,4 +74,32 @@
#define PAGE_MASK_4G (PAGE_SIZE_4G - 1)
#define PAGE_MASK_16G (PAGE_SIZE_16G - 1)
+#define PAGE_CODE_4K 0x00000000
+#define PAGE_CODE_64K 0x00000001
+#define PAGE_CODE_1M 0x00000002
+#define PAGE_CODE_16M 0x00000003
+#define PAGE_CODE_256M 0x00000004
+#define PAGE_CODE_4G 0x00000005
+#define PAGE_CODE_INVAL 0x00000007
+#define PAGE_CODE_MASK 0x00000007
+
+static inline void encode_pg_sz(unsigned long long pg_sz,
+ unsigned int *pg_sz_code)
+{
+ if (pg_sz == PAGE_SIZE_4K)
+ *pg_sz_code = PAGE_CODE_4K;
+ else if (pg_sz == PAGE_SIZE_64K)
+ *pg_sz_code = PAGE_CODE_64K;
+ else if (pg_sz == PAGE_SIZE_1M)
+ *pg_sz_code = PAGE_CODE_1M;
+ else if (pg_sz == PAGE_SIZE_16M)
+ *pg_sz_code = PAGE_CODE_16M;
+ else if (pg_sz == PAGE_SIZE_256M)
+ *pg_sz_code = PAGE_CODE_256M;
+ else if (pg_sz == PAGE_SIZE_4G)
+ *pg_sz_code = PAGE_CODE_4G;
+ else
+ *pg_sz_code = PAGE_CODE_INVAL;
+}
+
#endif /* _HFIDD_ADPT_H_ */
diff --git a/include/linux/hfi/hfidd_hcalls.h b/include/linux/hfi/hfidd_hcalls.h
index 2a374e6..57140a0 100644
--- a/include/linux/hfi/hfidd_hcalls.h
+++ b/include/linux/hfi/hfidd_hcalls.h
@@ -42,6 +42,8 @@
#define H_NMMU_START 0xF028
#define H_NMMU_STOP 0xF02C
+#define HFI_PAGE_CODE_SHIFT 28
+
#define EEH_QUERY 1
#define COMP_QUERY 2
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index 290e809..8e097d0 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -63,6 +63,7 @@
#include <linux/hfi/hfidd_client.h>
#include <linux/hfi/hfidd_adpt.h>
#include <linux/hfi/hfidd_hcalls.h>
+#include <linux/hfi/hfidd_xlat_map.h>
#define MAX_D_WIN_PER_HFI (p_acs->dds.num_d_windows)
diff --git a/include/linux/hfi/hfidd_xlat_map.h b/include/linux/hfi/hfidd_xlat_map.h
new file mode 100644
index 0000000..e5d1869
--- /dev/null
+++ b/include/linux/hfi/hfidd_xlat_map.h
@@ -0,0 +1,91 @@
+/*
+ * hfidd_xlat_map.h
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _HFIDD_XLAT_MAP_H_
+#define _HFIDD_XLAT_MAP_H_
+
+#include <linux/hfi/hfidd_client.h>
+
+/*
+ * So we can shift rather than divide!
+ */
+#define PAGE_SHIFT_2K 11
+#define PAGE_SHIFT_4K 12
+#define PAGE_SHIFT_64K 16
+#define PAGE_SHIFT_1M 20
+#define PAGE_SHIFT_16M 24
+#define PAGE_SHIFT_4G 32
+
+struct page_num_code {
+ union {
+ unsigned long long llu_value;
+ struct num_and_code {
+ unsigned int pg_num;
+ unsigned int pg_code;
+ } fields;
+ } num_code;
+};
+
+struct hfidd_vlxmem {
+ unsigned long long page_sz; /* actual page size */
+ unsigned int num_page; /* calculated using actual
+ page size */
+ unsigned int rsvd;
+ struct page_num_code num_page_sz; /* page num and size code
+ mapping */
+ unsigned long long map_page_sz; /* page size used for mapping */
+ caddr_t m_addr; /* aligned address start for
+ mapping */
+ caddr_t v_addr; /* user given vaddr */
+ caddr_t e_addr;
+
+ unsigned long long len;
+ unsigned long long access_flag;
+ void *l_pages;
+
+ unsigned long long mr_handle;
+ unsigned int l_key;
+
+ struct task *xd;
+
+ int num_kpage; /* num of kernel pages */
+ atomic_t *share_cnt; /* # of processes sharing this
+ submr */
+ unsigned int num_chunks; /* number of chunks the mr is
+ divided */
+ caddr_t mr_addr; /* aligned submr starting
+ address */
+ void *page_list; /* struct page_list */
+ unsigned int liobn; /* logical I/O bus number */
+};
+
+#endif
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 07/27] HFI: Add nMMU start/stop hypervisor calls
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
H_NMMU_START resets/inits state for the nMMU in the hypervisor.
H_NMMU_STOP cleans up hypervisor nMMU state, called on DD unload after HFIs are
stopped.
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/hfidd_adpt.c | 36 +++++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_hcalls.c | 33 ++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_init.c | 29 +++++++++++++++++++++++++--
drivers/net/hfi/core/hfidd_proto.h | 3 ++
include/linux/hfi/hfidd_hcalls.h | 2 +
5 files changed, 100 insertions(+), 3 deletions(-)
diff --git a/drivers/net/hfi/core/hfidd_adpt.c b/drivers/net/hfi/core/hfidd_adpt.c
index fd4a0cb..487ef0e 100644
--- a/drivers/net/hfi/core/hfidd_adpt.c
+++ b/drivers/net/hfi/core/hfidd_adpt.c
@@ -162,6 +162,42 @@ query1:
return rc;
}
+int hfidd_start_nmmu(struct hfidd_acs *p_acs)
+{
+ long long hvrc;
+ int rc = 0;
+ struct nmmu_info *nmmu_info;
+ caddr_t laddr = NULL;
+ u64 start_time = get_jiffies_64();
+
+ rc = hfidd_get_phyp_page(p_acs, (caddr_t *)&nmmu_info, &laddr,
+ PAGE_SIZE_4K);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_start_nmmu: hfidd_get_phyp_page failed\n");
+ return -ENOMEM;
+ }
+
+ while (1) {
+ hvrc = hfi_start_nmmu(p_acs->dds.torr_id,
+ (struct nmmu_info *) laddr);
+ if (hvrc != H_BUSY)
+ break;
+ if (hfidd_age_hcall(start_time))
+ break;
+ }
+
+ if (hvrc != H_SUCCESS) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_start_nmmu: HFI_START_NMMU failed "
+ "hvrc 0x%llx\n", hvrc);
+ rc = -EPERM;
+ }
+
+ hfidd_release_phyp_page((caddr_t)nmmu_info, PAGE_SIZE_4K);
+ return rc;
+}
+
int hfidd_start_interface(struct hfidd_acs *p_acs)
{
long long hvrc = 0;
diff --git a/drivers/net/hfi/core/hfidd_hcalls.c b/drivers/net/hfi/core/hfidd_hcalls.c
index 84467b3..2ca1c8a 100644
--- a/drivers/net/hfi/core/hfidd_hcalls.c
+++ b/drivers/net/hfi/core/hfidd_hcalls.c
@@ -33,6 +33,18 @@
#include <linux/hfi/hfidd_internal.h>
#include "hfidd_proto.h"
+static inline long long h_nmmu_start(int token,
+ u64 torrent_chip_ID,
+ void *output_page_ptr)
+{
+ return plpar_hcall_norets(token, torrent_chip_ID, output_page_ptr);
+}
+
+static inline long long h_nmmu_stop(int token, u64 torrent_chip_ID)
+{
+ return plpar_hcall_norets(token, torrent_chip_ID);
+}
+
static inline long long h_hfi_start_interface(int token,
u64 HFI_chip_ID)
{
@@ -61,6 +73,27 @@ static inline long long h_hfi_query_interface(int token,
return rc;
}
+long long hfi_start_nmmu(u64 chip_id, void *nmmu_info)
+{
+ return h_nmmu_start(H_NMMU_START, chip_id, nmmu_info);
+}
+
+long long hfi_stop_nmmu(u64 chip_id)
+{
+ long long hvrc;
+ u64 start_time = get_jiffies_64();
+
+ while (1) {
+ hvrc = h_nmmu_stop(H_NMMU_STOP,
+ chip_id);
+ if (hvrc != H_BUSY)
+ break;
+ if (hfidd_age_hcall(start_time))
+ break;
+ }
+ return hvrc;
+}
+
long long hfi_hquery_interface(u64 unit_id, u64 subtype,
u64 query_p, u64 *state)
{
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
index bbfc477..3dcaa8f 100644
--- a/drivers/net/hfi/core/hfidd_init.c
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -320,30 +320,43 @@ hfidd_create_devices_error0:
/*
* Disable message passing to each adapter by calling the
- * Stop Interface hcall.
+ * Stop Interface hcall and free phyp NMMU tables for this
+ * lpar by calling STOP NMMU
*/
static void hfidd_stop_adapter(void)
{
int i;
+ long long hvrc;
for (i = 0; i < MAX_HFIS; i++) {
hfidd_stop_interface(hfidd_global.p_acs[i],
hfidd_global.p_acs[i]->dds.hfi_id);
}
+ hvrc = hfi_stop_nmmu(hfidd_global.p_acs[0]->dds.torr_id);
+ if (hvrc != H_SUCCESS)
+ dev_printk(KERN_ERR, hfidd_global.p_acs[0]->hfidd_dev,
+ "%s: hfidd_stop_adapter: HFI_STOP_NMMU failed"
+ " hvrc = 0x%llx\n", HFIDD_DEV_NAME, hvrc);
}
/*
* Query the interface to check the logical state of HFI.
- * Enable message passing to each adapter by calling Start
- * Interface hcall.
+ * Initialize the phyp NMMU tables for this lpar by calling
+ * the START NMMU hcall and enable message passing to each
+ * adapter by calling Start Interface hcall.
*/
static int hfidd_start_adapter(void)
{
+ long long hvrc;
unsigned long long hfi_state;
int i, j;
int rc = 0;
for (i = 0; i < MAX_HFIS; i++) {
+ /* query interface before doing START_NMMU.
+ * If we crashed the LPAR a few minutes ago, we never did the
+ * stop interface and the stop nmmu. Do it now.
+ */
rc = hfidd_query_interface(hfidd_global.p_acs[i], COMP_QUERY,
hfidd_global.p_acs[i]->dds.hfi_id, &hfi_state);
if (hfi_state != NOT_STARTED) {
@@ -374,6 +387,15 @@ static int hfidd_start_adapter(void)
}
+ hfi_stop_nmmu(hfidd_global.p_acs[0]->dds.torr_id);
+ hvrc = hfidd_start_nmmu(hfidd_global.p_acs[0]);
+ if (hvrc != H_SUCCESS) {
+ dev_printk(KERN_ERR, hfidd_global.p_acs[0]->hfidd_dev,
+ "%s: hfidd_start_adapter: HFI_START_NMMU failed"
+ " hvrc = 0x%llx\n", HFIDD_DEV_NAME, hvrc);
+ return -EIO;
+ }
+
for (i = 0; i < MAX_HFIS; i++) {
rc = hfidd_start_interface(hfidd_global.p_acs[i]);
if (rc) {
@@ -402,6 +424,7 @@ hfidd_start_adapter_err:
hfidd_stop_interface(hfidd_global.p_acs[j],
hfidd_global.p_acs[j]->dds.hfi_id);
}
+ hfi_stop_nmmu(hfidd_global.p_acs[0]->dds.torr_id);
return rc;
}
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
index 6ec9245..320f41f 100644
--- a/drivers/net/hfi/core/hfidd_proto.h
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -42,8 +42,11 @@ int hfidd_get_phyp_page(struct hfidd_acs *p_acs, caddr_t *page,
void hfidd_release_phyp_page(caddr_t page, int size);
int hfidd_query_interface(struct hfidd_acs *p_acs, unsigned int subtype,
unsigned int hfi_id, unsigned long long *state);
+int hfidd_start_nmmu(struct hfidd_acs *p_acs);
int hfidd_start_interface(struct hfidd_acs *p_acs);
int hfidd_stop_interface(struct hfidd_acs *p_acs, unsigned int hfi_id);
+long long hfi_start_nmmu(u64 chip_id, void *nmmu_info);
+long long hfi_stop_nmmu(u64 chip_id);
long long hfi_hquery_interface(u64 unit_id, u64 subtype, u64 query_p,
u64 *state);
long long hfi_start_interface(u64 unit_id);
diff --git a/include/linux/hfi/hfidd_hcalls.h b/include/linux/hfi/hfidd_hcalls.h
index 5349e9e..2a374e6 100644
--- a/include/linux/hfi/hfidd_hcalls.h
+++ b/include/linux/hfi/hfidd_hcalls.h
@@ -39,6 +39,8 @@
#define H_HFI_START_INTERFACE 0xF000
#define H_HFI_QUERY_INTERFACE 0xF004
#define H_HFI_STOP_INTERFACE 0xF008
+#define H_NMMU_START 0xF028
+#define H_NMMU_STOP 0xF02C
#define EEH_QUERY 1
#define COMP_QUERY 2
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 03/27] HFI: Add device_create/device_destroy calls for HFI devices.
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/hfidd_init.c | 52 ++++++++++++++++++++++++++++++++++++
include/linux/hfi/hfidd_internal.h | 1 +
2 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
index 61ed559..40d5aaf 100644
--- a/drivers/net/hfi/core/hfidd_init.c
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -46,6 +46,7 @@ MODULE_LICENSE("GPL v2");
struct hfidd_global hfidd_global;
EXPORT_SYMBOL_GPL(hfidd_global);
+struct device *hfidd_class_dev[MAX_HFIS + 1];
static dev_t hfidd_dev;
#define MAX_HFI_DEVS (MAX_HFIS + 1)
@@ -70,6 +71,38 @@ static const struct file_operations hfidd_fops = {
.write = hfidd_cmd_write,
};
+/* Create the hfi device */
+static int hfidd_mkdev(int ai, struct hfidd_acs *p_acs)
+{
+ char dname[128];
+ int rc = 0;
+
+ sprintf(dname, "%s%d", HFIDD_DEV_NAME, ai);
+
+ hfidd_class_dev[ai] = device_create(hfidd_global.class,
+ NULL, MKDEV(MAJOR(hfidd_dev), ai),
+ (void *)p_acs, (char *)dname);
+
+ if (IS_ERR(hfidd_class_dev[ai])) {
+ rc = PTR_ERR(hfidd_class_dev[ai]);
+ printk(KERN_ERR "%s: hfidd_mkdev: device_create for ai=%d fail"
+ " rc = %d\n", dname, ai, rc);
+ return rc;
+ }
+
+ if (ai == MAX_HFIS)
+ return 0;
+
+ p_acs->hfidd_dev = hfidd_class_dev[ai];
+ return rc;
+}
+
+/* delete the hfi device, /dev/hfi* files and sysclass files */
+static void hfidd_rmdev(int ai)
+{
+ device_destroy(hfidd_global.class, MKDEV(MAJOR(hfidd_dev), ai));
+}
+
/* Destroy the HFI class */
static inline void hfidd_destroy_class(void)
{
@@ -128,6 +161,8 @@ static void hfidd_destroy_devices(void)
hfidd_global.p_acs[i] = NULL;
hfidd_global.acs_cnt--;
}
+ for (i = 0; i <= MAX_HFIS; i++)
+ hfidd_rmdev(i);
}
/*
@@ -155,6 +190,23 @@ static int hfidd_create_devices(void)
}
hfidd_global.acs_cnt++;
}
+
+ for (i = 0; i <= MAX_HFIS; i++) {
+ rc = hfidd_mkdev(i, hfidd_global.p_acs[i]);
+ if (rc) {
+ for (j = 0; j < i; j++)
+ hfidd_rmdev(j);
+ goto hfidd_create_devices_error0;
+ }
+ }
+ return 0;
+
+hfidd_create_devices_error0:
+ for (i = 0; i < MAX_HFIS; i++) {
+ hfidd_free_adapter(hfidd_global.p_acs[i]);
+ hfidd_global.p_acs[i] = NULL;
+ hfidd_global.acs_cnt--;
+ }
return rc;
}
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index 66765a5..956e6b2 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -54,6 +54,7 @@ struct hfidd_acs {
unsigned int index;
unsigned int acs_cnt;
unsigned int state;
+ struct device *hfidd_dev;
};
/* DD global */
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 08/27] HFI: DD request framework and first HFI DD request
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
We use an ioctl-ish mechanism similar to the one found in the HEA driver.
Some of our requests have very large parameter lists, this method allows
us to get the parms into the DD quickly.
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/hfidd_init.c | 94 +++++++++++++++++++++++++++++++++++-
include/linux/hfi/Kbuild | 1 +
include/linux/hfi/hfidd_client.h | 40 +++++++++++++++
include/linux/hfi/hfidd_internal.h | 23 ++++++++-
include/linux/hfi/hfidd_requests.h | 38 ++++++++++++++
5 files changed, 192 insertions(+), 4 deletions(-)
create mode 100644 include/linux/hfi/hfidd_requests.h
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
index 3dcaa8f..df79ae9 100644
--- a/drivers/net/hfi/core/hfidd_init.c
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -36,6 +36,7 @@
#include <linux/of.h>
#include <linux/hfi/hfidd_internal.h>
+#include <linux/hfi/hfidd_requests.h>
#include "hfidd_proto.h"
MODULE_VERSION("1.0");
@@ -59,11 +60,102 @@ static ssize_t hfidd_read(struct file *filep, char *buf, size_t count,
return 0;
}
+/* Query firmare level and use abi version to users */
+static int hfidd_query_dd_info(struct hfidd_acs *p_acs,
+ struct hfi_query_dd_info *user_p)
+{
+ struct hfi_query_dd_info req;
+ int rc;
+
+ req.fw_ec_level = p_acs->dds.fw_ec_level;
+ req.abi_version = HFIDD_USER_ABI_VERSION;
+
+ rc = copy_to_user(user_p, &req, sizeof(struct hfi_query_dd_info));
+ if (rc)
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_query_dd_info: copy_to_user failed\n");
+
+ return rc;
+}
+
/* Entry point for user space to do driver requests. */
static ssize_t hfidd_cmd_write(struct file *filep, const char __user *buf,
size_t count, loff_t *pos)
{
- return 0;
+ struct hfidd_acs *p_acs;
+ int ai;
+ int cnt = 0;
+ int rc = 0;
+ struct hfi_req_hdr cmd;
+ int is_userspace;
+
+ ai = iminor(filep->f_path.dentry->d_inode);
+ if (ai >= MAX_HFIS) {
+ printk(KERN_ERR "%s: hfidd_cmd_write: wrong ai = %d\n",
+ HFIDD_DEV_NAME, ai);
+ return -ENODEV;
+ }
+
+ p_acs = hfidd_global.p_acs[ai];
+ if (p_acs == NULL) {
+ printk(KERN_ERR "%s: hfidd_cmd_write: p_acs is NULL\n",
+ HFIDD_DEV_NAME);
+ return -EINVAL;
+ }
+
+ if (count < sizeof(cmd)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_cmd_write: Invalid count: 0x%lx expected "
+ "count: 0x%lx\n", count, sizeof(cmd));
+ return -EINVAL;
+ }
+
+ is_userspace = 1;
+ if (segment_eq(get_fs(), KERNEL_DS))
+ is_userspace = 0;
+
+ if (copy_from_user(&cmd, buf, sizeof(cmd))) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_cmd_write: copy_from_user failed\n");
+ return -EINVAL;
+ }
+
+ if (cmd.abi_version != HFIDD_USER_ABI_VERSION) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_cmd_write: wrong abi_version %d, "
+ "should be %d for cmd 0x%x\n",
+ cmd.abi_version, HFIDD_USER_ABI_VERSION, cmd.req);
+ return -EINVAL;
+ }
+
+ switch (cmd.req) {
+ case HFIDD_REQ_QUERY_DD_INFO:
+ if (cmd.req_len != sizeof(struct hfi_query_dd_info)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_cmd_write: hdr.reqlen 0x%x expected "
+ "0x%x for cmd req 0x%x\n",
+ cmd.req_len, (unsigned int)
+ sizeof(struct hfi_query_dd_info), cmd.req);
+ return -EINVAL;
+ }
+ rc = hfidd_query_dd_info(p_acs, (struct hfi_query_dd_info *)
+ cmd.result.use.kptr);
+ break;
+
+ default:
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_cmd_write: invalid cmd = 0x%x\n", cmd.req);
+ return -EINVAL;
+ }
+
+ if (rc == 0)
+ cnt = count;
+ else
+ cnt = rc;
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_cmd_write: Exit cmd = 0x%x rc = 0x%x\n", cmd.req, rc);
+ return cnt;
}
static const struct file_operations hfidd_fops = {
diff --git a/include/linux/hfi/Kbuild b/include/linux/hfi/Kbuild
index 3a742ce..6637c65 100644
--- a/include/linux/hfi/Kbuild
+++ b/include/linux/hfi/Kbuild
@@ -1 +1,2 @@
header-y += hfidd_client.h
+header-y += hfidd_requests.h
diff --git a/include/linux/hfi/hfidd_client.h b/include/linux/hfi/hfidd_client.h
index 2714a27..b2ebd01 100644
--- a/include/linux/hfi/hfidd_client.h
+++ b/include/linux/hfi/hfidd_client.h
@@ -33,11 +33,51 @@
#ifndef _HFIDD_CLIENT_H_
#define _HFIDD_CLIENT_H_
+
+#define HFIDD_USER_ABI_VERSION 1
+
+
+/*
+ * New ioctls are not allowed. We will use write() calls to pass
+ * in an ioctl-looking request, with struct hfi_req_hdr giving the
+ * information we used to get from the ioctl() parameter list. The
+ * write() call will copy out the request structure to the buffer pointed
+ * to by result, which is probably the original request.
+ */
+
+struct hfi_64b {
+ union {
+ unsigned long long allu; /* APPLICATION Long long
+ Unsigned 64 bit address
+ container */
+ void *kptr; /* KERNEL Pointer 64 bit
+ container */
+ } use;
+};
+
+/* Request header: first structure in each of the HFI DD requests */
+struct hfi_req_hdr {
+ unsigned int req; /* HFIDD_REQ_* */
+ unsigned int req_len; /* length of req, in bytes */
+ unsigned int abi_version; /* ABI version */
+ struct hfi_64b result; /* user eaddr for output */
+};
+#define HFIDD_REQ_HDR_SIZE sizeof(struct hfi_req_hdr)
+
#define MAX_TORRENTS 1
#define MAX_HFI_PER_TORRENT 2
#define MAX_HFIS (MAX_TORRENTS * MAX_HFI_PER_TORRENT)
#define MAX_WIN_PER_HFI 256
+/*
+ * HFIDD_REQ_QUERY_DD_INFO
+ */
+struct hfi_query_dd_info {
+ struct hfi_req_hdr hdr;
+ unsigned long long fw_ec_level; /* Hardware Version */
+ unsigned int abi_version; /* ABI Version */
+};
+
#define HFI_DYN_WINS_DEFAULT 32
#define PAGE_SIZE_4K 0x1000
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index c7c67ca..0cc8c88 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -36,12 +36,29 @@
#include <linux/fs.h>
#include <linux/kobject.h>
#include <linux/cdev.h>
+#include <linux/compat.h>
+#include <linux/compiler.h>
#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/mman.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/poll.h>
#include <linux/slab.h>
-#include <linux/jiffies.h>
-#include <linux/device.h>
-
+#include <linux/vermagic.h>
+#include <linux/delay.h>
+#include <linux/vmalloc.h>
+#include <linux/timer.h>
+#include <linux/spinlock.h>
+#include <linux/sched.h>
+#include <asm/cputable.h>
+#include <linux/io.h>
+#include <asm/machdep.h>
+#include <linux/mmu_context.h>
+#include <asm/pgalloc.h>
+#include <asm/ibmebus.h>
+#include <linux/kthread.h>
#include <linux/hfi/hfidd_client.h>
#include <linux/hfi/hfidd_adpt.h>
#include <linux/hfi/hfidd_hcalls.h>
diff --git a/include/linux/hfi/hfidd_requests.h b/include/linux/hfi/hfidd_requests.h
new file mode 100644
index 0000000..b6e255f
--- /dev/null
+++ b/include/linux/hfi/hfidd_requests.h
@@ -0,0 +1,38 @@
+/*
+ * hfidd_requests.h
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _HFIDD_REQUESTS_H_
+#define _HFIDD_REQUESTS_H_
+
+#define HFIDD_REQ_QUERY_DD_INFO 0x00001004
+
+#endif /* _HFIDD_REQUESTS_H_ */
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 11/27] HFI: Check window number/assign window number
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
RESERVED windows are reserved by a job scheduler before the application starts.
the application is given a list of windows to use, the DD has to check that
they are opening one of the windows assigned to that jobid.
DYNAMIC windows are used without a job scheduler; the application calls into
the DD and asks for any free window.
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/hfidd_window.c | 161 +++++++++++++++++++++++++++++++++++
include/linux/hfi/hfidd_internal.h | 16 ++++
2 files changed, 177 insertions(+), 0 deletions(-)
diff --git a/drivers/net/hfi/core/hfidd_window.c b/drivers/net/hfi/core/hfidd_window.c
index f16caf7..cc775e3 100644
--- a/drivers/net/hfi/core/hfidd_window.c
+++ b/drivers/net/hfi/core/hfidd_window.c
@@ -35,6 +35,153 @@
#include "hfidd_proto.h"
#include <linux/hfi/hfidd_requests.h>
+/* Validate the type, state and job id for RESERVED window */
+static int hfi_validate_reserve_window_id(struct hfidd_acs *p_acs,
+ struct hfi_client_info *client_p)
+{
+ struct hfidd_window *win_p;
+
+ /* Check if win is between min_hfi_windows and max_hfi_windows */
+ if ((client_p->window < min_hfi_windows(p_acs)) ||
+ (client_p->window >= max_hfi_windows(p_acs))) {
+
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_validate_reserve_window_id: window = 0x%x too big\n",
+ client_p->window);
+ return -EINVAL;
+ }
+
+ /* Check if win_p indexed by window is not NULL */
+ win_p = hfi_window(p_acs, client_p->window);
+ if (win_p == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_validate_reserve_window_id: win 0x%x win_p is NULL\n",
+ client_p->window);
+ return -EINVAL;
+ }
+
+ spin_lock(&(win_p->win_lock));
+ /*
+ * Check if win_p->type is HFIDD_RESERVE_WIN
+ * win_p->state is WIN_RESERVED,
+ * job id is matched
+ */
+ if ((win_p->type != HFIDD_RESERVE_WIN) ||
+ (win_p->state != WIN_RESERVED) ||
+ (win_p->job_id != client_p->job_id)) {
+ spin_unlock(&(win_p->win_lock));
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_validate_reserve_window_id: win 0x%x type0x%x/"
+ "state0x%x/jid invalid\n",
+ client_p->window, win_p->type, win_p->state);
+ return -EINVAL;
+ }
+ spin_unlock(&(win_p->win_lock));
+ return 0;
+}
+
+/* Find an available dynamic window for open window request */
+static int hfi_validate_dynamic_window_id(struct hfidd_acs *p_acs,
+ struct hfi_client_info *client_p)
+{
+ int i;
+ struct hfidd_window *win_p;
+
+ /* Find out next available dynamic window */
+ for (i = min_hfi_windows(p_acs);
+ i < max_hfi_windows(p_acs); i++) {
+
+ win_p = hfi_window(p_acs, i);
+ if (win_p == NULL)
+ continue;
+
+ /* if the spinlock is busy, the window is in use */
+ if (!spin_trylock(&(win_p->win_lock)))
+ continue;
+
+ if ((win_p->type == HFIDD_DYNAMIC_WIN) &&
+ (win_p->state == WIN_AVAILABLE)) {
+ /*
+ * Fill in the window number into
+ * client info and update state
+ */
+ client_p->window = win_p->index;
+ win_p->job_id = client_p->job_id;
+ win_p->state = WIN_RESERVED;
+ win_p->type = client_p->win_type;
+
+ /* Set isIP flag if came from IP */
+ if (win_p->type == HFIDD_IP_WIN)
+ win_p->is_ip = 1;
+ else
+ win_p->is_ip = 0;
+ spin_unlock(&(win_p->win_lock));
+ return 0;
+ }
+ spin_unlock(&(win_p->win_lock));
+ }
+
+ /* We are out of dynamic windows */
+ if (i == max_hfi_windows(p_acs)) {
+ client_p->window = 0;
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_validate_dynamic_window_id: out of dynamic window\n");
+ return -ENOBUFS;
+ }
+
+ return 0;
+}
+
+/* Validate the window request for RESERVED or DYNAMIC window */
+static inline int hfi_validate_window_id(struct hfidd_acs *p_acs,
+ struct hfi_client_info *client_p, unsigned int is_userspace)
+{
+ int rc = 0;
+
+ /* Check the type of window request */
+ switch (client_p->win_type) {
+ case HFIDD_RESERVE_WIN:
+ rc = hfi_validate_reserve_window_id(p_acs, client_p);
+ break;
+ case HFIDD_IP_WIN:
+ case HFIDD_KERNEL_WIN:
+ if (is_userspace) {
+ rc = -EINVAL;
+ break;
+ }
+ /* fall thru here....*/
+ case HFIDD_DYNAMIC_WIN:
+ rc = hfi_validate_dynamic_window_id(p_acs, client_p);
+ break;
+ default:
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_validate_window_id: invalid win type 0x%x\n",
+ client_p->win_type);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+/* Validate window number and type for open window request */
+static int hfi_validate_window_parm(struct hfidd_acs *p_acs,
+ unsigned int is_userspace,
+ struct hfi_client_info *client_p)
+{
+ int rc = 0;
+
+ /* Validate the window number */
+ rc = hfi_validate_window_id(p_acs, client_p, is_userspace);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_validate_window_parm: hfi_validate_window_id "
+ "failed, rc = 0x%x\n", rc);
+ return rc;
+ }
+ return 0;
+}
+
/*
* Allows an user/kernel window to send/receive network traffic thru HFI
* adapter. This function will allocate the system resources needed to open
@@ -62,9 +209,23 @@ int hfidd_open_window_func(struct hfidd_acs *p_acs, unsigned int is_userspace,
if (rc) {
dev_printk(KERN_ERR, p_acs->hfidd_dev,
"open_window_func: hfi_copy_from_user failed\n");
+ goto hfidd_open_window_func_err1;
+ }
+
+ /* Validate the window parms */
+ rc = hfi_validate_window_parm(p_acs, is_userspace, local_p);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "open_window_func: hfi_validate_window_parm failed, "
+ "rc = 0x%x\n", rc);
+ goto hfidd_open_window_func_err1;
}
kfree(local_p);
return rc;
+
+hfidd_open_window_func_err1:
+ kfree(local_p);
+ return rc;
}
EXPORT_SYMBOL_GPL(hfidd_open_window_func);
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index 951314a..290e809 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -142,6 +142,22 @@ struct hfidd_global {
struct hfidd_acs *p_acs[MAX_HFIS];
};
+static inline struct hfidd_window *hfi_window(struct hfidd_acs *p,
+ unsigned int idx)
+{
+ return p->win[idx - p->dds.window_start];
+}
+
+static inline unsigned int min_hfi_windows(struct hfidd_acs *p)
+{
+ return p->dds.window_start;
+}
+
+static inline unsigned int max_hfi_windows(struct hfidd_acs *p)
+{
+ return p->dds.window_start + p->dds.window_num;
+}
+
static inline int hfi_copy_to_user(void *user_p, void *local_p,
unsigned int is_userspace, unsigned int size)
{
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 14/27] HFI: Add hypercalls to create/modify/free page tables in the nMMU
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/hfidd_hcalls.c | 124 +++++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_proto.h | 15 ++++
include/linux/hfi/hfidd_hcalls.h | 3 +
3 files changed, 142 insertions(+), 0 deletions(-)
diff --git a/drivers/net/hfi/core/hfidd_hcalls.c b/drivers/net/hfi/core/hfidd_hcalls.c
index 2ca1c8a..aabb2a8 100644
--- a/drivers/net/hfi/core/hfidd_hcalls.c
+++ b/drivers/net/hfi/core/hfidd_hcalls.c
@@ -45,6 +45,64 @@ static inline long long h_nmmu_stop(int token, u64 torrent_chip_ID)
return plpar_hcall_norets(token, torrent_chip_ID);
}
+static inline long long h_nmmu_allocate_resource(int token,
+ u64 torrent_chip_ID,
+ u64 resource_name,
+ u64 eaddr,
+ u64 memory_region_size,
+ u64 access_controls,
+ u64 protection_domain,
+ u64 MR_Handle_In,
+ u64 *MR_Handle_out,
+ u64 *L_Key,
+ u64 *liobn)
+{
+ u64 hyp_outputs[PLPAR_HCALL9_BUFSIZE];
+ long long rc;
+
+ rc = plpar_hcall9(token, (unsigned long *)hyp_outputs,
+ torrent_chip_ID, resource_name, eaddr,
+ memory_region_size, access_controls,
+ protection_domain, MR_Handle_In);
+ *MR_Handle_out = hyp_outputs[0]; /* 1st ret value */
+ *L_Key = hyp_outputs[1]; /* 2nd */
+ *liobn = hyp_outputs[3]; /* 4th */
+
+ return rc;
+}
+
+static inline long long h_nmmu_free_resource(int token,
+ u64 torrent_chip_ID,
+ u64 resource_name,
+ u64 MR_Handle,
+ u64 subregion)
+{
+ return plpar_hcall_norets(token,
+ torrent_chip_ID,
+ resource_name,
+ MR_Handle,
+ subregion);
+}
+
+static inline long long h_nmmu_modify_resource(int token,
+ u64 torrent_chip_ID,
+ u64 request,
+ u64 MR_Handle,
+ u64 subregion,
+ u64 eaddr,
+ u64 laddr,
+ u64 num_pg_sz)
+{
+ return plpar_hcall_norets(token,
+ torrent_chip_ID,
+ request,
+ MR_Handle,
+ subregion,
+ eaddr,
+ laddr,
+ num_pg_sz);
+}
+
static inline long long h_hfi_start_interface(int token,
u64 HFI_chip_ID)
{
@@ -94,6 +152,72 @@ long long hfi_stop_nmmu(u64 chip_id)
return hvrc;
}
+long long hfi_allocate_mr(u64 chip_id, u64 res, u64 addr, u64 mr_size,
+ u64 access,
+ u64 job_id,
+ u64 mr_handle_in,
+ u64 *mr_handle_out,
+ u64 *lkey_p,
+ u64 *liobn)
+{
+ return h_nmmu_allocate_resource(H_NMMU_ALLOCATE_RESOURCE,
+ chip_id,
+ res,
+ addr,
+ mr_size,
+ access,
+ job_id,
+ mr_handle_in,
+ mr_handle_out,
+ lkey_p,
+ liobn);
+}
+
+long long hfi_modify_mr(u64 chip_id, u64 request, u64 mr_handle,
+ u64 sub_id,
+ u64 e_addr,
+ u64 l_addr,
+ u64 num_pg_sz)
+{
+ long long hvrc;
+ u64 start_time = get_jiffies_64();
+
+ while (1) {
+ hvrc = h_nmmu_modify_resource(H_NMMU_MODIFY_RESOURCE,
+ chip_id,
+ request,
+ mr_handle,
+ sub_id,
+ e_addr,
+ l_addr,
+ num_pg_sz);
+ if (hvrc != H_BUSY)
+ break;
+ if (hfidd_age_hcall(start_time))
+ break;
+ }
+ return hvrc;
+}
+
+long long hfi_free_mr(u64 chip_id, u64 res, u64 mr_handle, u64 sub_region_id)
+{
+ long long hvrc;
+ u64 start_time = get_jiffies_64();
+
+ while (1) {
+ hvrc = h_nmmu_free_resource(H_NMMU_FREE_RESOURCE,
+ chip_id,
+ res,
+ mr_handle,
+ sub_region_id);
+ if (hvrc != H_BUSY)
+ break;
+ if (hfidd_age_hcall(start_time))
+ break;
+ }
+ return hvrc;
+}
+
long long hfi_hquery_interface(u64 unit_id, u64 subtype,
u64 query_p, u64 *state)
{
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
index 001f6d5..fb9c8c8 100644
--- a/drivers/net/hfi/core/hfidd_proto.h
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -64,6 +64,21 @@ int hfidd_start_interface(struct hfidd_acs *p_acs);
int hfidd_stop_interface(struct hfidd_acs *p_acs, unsigned int hfi_id);
long long hfi_start_nmmu(u64 chip_id, void *nmmu_info);
long long hfi_stop_nmmu(u64 chip_id);
+long long hfi_allocate_mr(u64 chip_id, u64 res, u64 addr,
+ u64 mr_size,
+ u64 access,
+ u64 job_id,
+ u64 mr_handle_in,
+ u64 *mr_handle_out,
+ u64 *lkey_p,
+ u64 *liobn);
+long long hfi_modify_mr(u64 chip_id, u64 request, u64 mr_handle,
+ u64 sub_id,
+ u64 e_addr,
+ u64 l_addr,
+ u64 num_pg_sz);
+long long hfi_free_mr(u64 chip_id, u64 res, u64 mr_handle,
+ u64 sub_region_id);
long long hfi_hquery_interface(u64 unit_id, u64 subtype, u64 query_p,
u64 *state);
long long hfi_start_interface(u64 unit_id);
diff --git a/include/linux/hfi/hfidd_hcalls.h b/include/linux/hfi/hfidd_hcalls.h
index 57140a0..9fa87c5 100644
--- a/include/linux/hfi/hfidd_hcalls.h
+++ b/include/linux/hfi/hfidd_hcalls.h
@@ -41,6 +41,9 @@
#define H_HFI_STOP_INTERFACE 0xF008
#define H_NMMU_START 0xF028
#define H_NMMU_STOP 0xF02C
+#define H_NMMU_ALLOCATE_RESOURCE 0xF030
+#define H_NMMU_FREE_RESOURCE 0xF034
+#define H_NMMU_MODIFY_RESOURCE 0xF03C
#define HFI_PAGE_CODE_SHIFT 28
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 05/27] HFI: The first few HFI-specific hypervisor calls
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
H_HFI_START_INTERFACE Notifies the hypervisor that a new instance of the DD is
starting, and any leftover state should be considered stale.
H_HFI_STOP_INTERFACE tells the hypervisor that the DD is unloading, and to
clean up any activity related to this DD instance.
H_HFI_QUERY_INTERFACE lets us get info about the HFIs that is not in the
device tree.
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/Makefile | 3 +-
drivers/net/hfi/core/hfidd_adpt.c | 139 +++++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_hcalls.c | 90 ++++++++++++++++++++++
drivers/net/hfi/core/hfidd_proto.h | 12 +++
include/linux/hfi/hfidd_client.h | 8 ++
include/linux/hfi/hfidd_hcalls.h | 58 +++++++++++++++
include/linux/hfi/hfidd_internal.h | 7 ++-
7 files changed, 315 insertions(+), 2 deletions(-)
create mode 100644 drivers/net/hfi/core/hfidd_hcalls.c
create mode 100644 include/linux/hfi/hfidd_hcalls.h
diff --git a/drivers/net/hfi/core/Makefile b/drivers/net/hfi/core/Makefile
index 6fe4e60..4e6cbd6 100644
--- a/drivers/net/hfi/core/Makefile
+++ b/drivers/net/hfi/core/Makefile
@@ -2,5 +2,6 @@
# Makefile for the HFI device driver for IBM eServer System p
#
hfi_core-objs:= hfidd_adpt.o \
- hfidd_init.o
+ hfidd_init.o \
+ hfidd_hcalls.o
obj-$(CONFIG_HFI) += hfi_core.o
diff --git a/drivers/net/hfi/core/hfidd_adpt.c b/drivers/net/hfi/core/hfidd_adpt.c
index f309a02..fd4a0cb 100644
--- a/drivers/net/hfi/core/hfidd_adpt.c
+++ b/drivers/net/hfi/core/hfidd_adpt.c
@@ -33,6 +33,18 @@
#include <linux/hfi/hfidd_internal.h>
#include "hfidd_proto.h"
+#define HFIDD_TIME_AGE (10 * HZ)
+
+int hfidd_age_hcall(u64 time_start)
+{
+ u64 timestamp = get_jiffies_64();
+
+ if ((timestamp - time_start) > HFIDD_TIME_AGE)
+ return 1;
+ else
+ return 0;
+}
+
int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t devno, void *uiop)
{
@@ -66,3 +78,130 @@ void hfidd_free_adapter(struct hfidd_acs *p_acs)
{
kfree(p_acs);
}
+
+/* Allocate the page for the HCALL */
+int hfidd_get_phyp_page(struct hfidd_acs *p_acs, caddr_t *page, caddr_t *laddr,
+ int size)
+{
+ *page = (caddr_t)__get_free_pages(GFP_KERNEL, get_order(size));
+ if (*page == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_get_phyp_page: __get_free_pages failed\n");
+ return -ENOMEM;
+ }
+
+ /* translate virtual to logical address */
+ *laddr = (caddr_t)__pa((caddr_t) *page);
+ memset(*page, 0, size);
+ return 0;
+}
+
+/* Release the page allocated for the HCALL */
+inline void hfidd_release_phyp_page(caddr_t page, int size)
+{
+ free_pages((unsigned long)page, get_order(size));
+}
+
+int hfidd_query_interface(struct hfidd_acs *p_acs, unsigned int subtype,
+ unsigned int hfi_id, unsigned long long *state)
+{
+ long long hvrc;
+ int rc = 0;
+ struct hfi_query_interface *query_p;
+ caddr_t laddr = NULL;
+
+ if (subtype != COMP_QUERY && subtype != EEH_QUERY) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_query_interface: subtype not supported, %d\n",
+ subtype);
+ return -EINVAL;
+ }
+
+ if (subtype == COMP_QUERY) {
+ /* Allocate the page for the HCALL */
+ rc = hfidd_get_phyp_page(p_acs, (caddr_t *)&query_p, &laddr,
+ PAGE_SIZE_4K);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_query_interface: hfidd_get_phyp_page "
+ "failed\n");
+ return -ENOMEM;
+ }
+ }
+
+ hvrc = hfi_hquery_interface(hfi_id, subtype,
+ (unsigned long long)laddr, state);
+ if (hvrc != H_SUCCESS) {
+ rc = -EPERM;
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_query_interface: failed, state 0x%llx "
+ "hvrc 0x%llx\n", *state, hvrc);
+ goto query1;
+ }
+
+ if (subtype == COMP_QUERY) {
+ if (*state == ACTIVE) {
+ if (p_acs->state != HFI_AVAIL) {
+ p_acs->isr = query_p->local_node_id;
+ p_acs->state = HFI_AVAIL;
+ }
+ } else {
+ p_acs->state = HFI_UNAVAIL;
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_query_interface: Bad state %lld, "
+ "return ENODEV\n", *state);
+ rc = -EIO;
+ }
+ }
+
+query1:
+ if (subtype == COMP_QUERY)
+ hfidd_release_phyp_page((caddr_t)query_p, PAGE_SIZE_4K);
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_query_interface: return rc %d\n", rc);
+ return rc;
+}
+
+int hfidd_start_interface(struct hfidd_acs *p_acs)
+{
+ long long hvrc = 0;
+ int rc = 0;
+ u64 start_time = get_jiffies_64();
+
+ while (1) {
+ hvrc = hfi_start_interface(p_acs->dds.hfi_id);
+ if (hvrc != H_BUSY)
+ break;
+ if (hfidd_age_hcall(start_time))
+ break;
+ }
+ if (hvrc != H_SUCCESS) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_start_interface: HFI_START_INTERFACE failed "
+ "hvrc 0x%llx\n", hvrc);
+ rc = -EPERM;
+ }
+ return rc;
+}
+
+int hfidd_stop_interface(struct hfidd_acs *p_acs, unsigned int hfi_id)
+{
+ long long hvrc = 0;
+ int rc = 0;
+ u64 start_time = get_jiffies_64();
+
+ while (1) {
+ hvrc = hfi_stop_interface(hfi_id);
+ if (hvrc != H_BUSY)
+ break;
+ if (hfidd_age_hcall(start_time))
+ break;
+ }
+ if (hvrc != H_SUCCESS) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_stop_interface: HFI_STOP_INTERFACE failed "
+ "hvrc 0x%llx\n", hvrc);
+ rc = -EPERM;
+ }
+ return rc;
+}
diff --git a/drivers/net/hfi/core/hfidd_hcalls.c b/drivers/net/hfi/core/hfidd_hcalls.c
new file mode 100644
index 0000000..84467b3
--- /dev/null
+++ b/drivers/net/hfi/core/hfidd_hcalls.c
@@ -0,0 +1,90 @@
+/*
+ * hfidd_hcalls.c
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/hfi/hfidd_internal.h>
+#include "hfidd_proto.h"
+
+static inline long long h_hfi_start_interface(int token,
+ u64 HFI_chip_ID)
+{
+ return plpar_hcall_norets(token, HFI_chip_ID);
+}
+
+static inline long long h_hfi_stop_interface(int token,
+ u64 HFI_chip_ID)
+{
+ return plpar_hcall_norets(token, HFI_chip_ID);
+}
+
+static inline long long h_hfi_query_interface(int token,
+ u64 HFI_chip_ID,
+ u64 type,
+ u64 output_page_ptr,
+ u64 *state)
+{
+ long long rc;
+ u64 hyp_outputs[PLPAR_HCALL_BUFSIZE];
+
+ rc = plpar_hcall(token, (unsigned long *)hyp_outputs, HFI_chip_ID, type,
+ output_page_ptr);
+ *state = hyp_outputs[0]; /* 1st ret value */
+
+ return rc;
+}
+
+long long hfi_hquery_interface(u64 unit_id, u64 subtype,
+ u64 query_p, u64 *state)
+{
+ long long hvrc;
+
+ hvrc = h_hfi_query_interface(H_HFI_QUERY_INTERFACE,
+ unit_id,
+ subtype,
+ query_p,
+ state);
+ return hvrc;
+}
+
+long long hfi_start_interface(u64 unit_id)
+{
+ return h_hfi_start_interface(H_HFI_START_INTERFACE,
+ unit_id);
+}
+
+long long hfi_stop_interface(u64 unit_id)
+{
+ long long hvrc;
+
+ hvrc = h_hfi_stop_interface(H_HFI_STOP_INTERFACE,
+ unit_id);
+ return hvrc;
+}
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
index e2ed4c9..6ec9245 100644
--- a/drivers/net/hfi/core/hfidd_proto.h
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -36,5 +36,17 @@
int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t, void *uiop);
void hfidd_free_adapter(struct hfidd_acs *p_acs);
int hfidd_init_adapter(struct hfidd_acs *p_acs, void *uiop);
+int hfidd_age_hcall(u64 time_start);
+int hfidd_get_phyp_page(struct hfidd_acs *p_acs, caddr_t *page,
+ caddr_t *laddr, int size);
+void hfidd_release_phyp_page(caddr_t page, int size);
+int hfidd_query_interface(struct hfidd_acs *p_acs, unsigned int subtype,
+ unsigned int hfi_id, unsigned long long *state);
+int hfidd_start_interface(struct hfidd_acs *p_acs);
+int hfidd_stop_interface(struct hfidd_acs *p_acs, unsigned int hfi_id);
+long long hfi_hquery_interface(u64 unit_id, u64 subtype, u64 query_p,
+ u64 *state);
+long long hfi_start_interface(u64 unit_id);
+long long hfi_stop_interface(u64 unit_id);
#endif
diff --git a/include/linux/hfi/hfidd_client.h b/include/linux/hfi/hfidd_client.h
index 28f1693..2714a27 100644
--- a/include/linux/hfi/hfidd_client.h
+++ b/include/linux/hfi/hfidd_client.h
@@ -40,4 +40,12 @@
#define HFI_DYN_WINS_DEFAULT 32
+#define PAGE_SIZE_4K 0x1000
+#define PAGE_SIZE_64K 0x10000
+#define PAGE_SIZE_1M 0x100000
+#define PAGE_SIZE_16M 0x1000000
+#define PAGE_SIZE_256M 0x10000000
+#define PAGE_SIZE_4G 0x100000000
+#define PAGE_SIZE_16G 0x400000000
+
#endif /* _HFIDD_CLIENT_H_ */
diff --git a/include/linux/hfi/hfidd_hcalls.h b/include/linux/hfi/hfidd_hcalls.h
new file mode 100644
index 0000000..5349e9e
--- /dev/null
+++ b/include/linux/hfi/hfidd_hcalls.h
@@ -0,0 +1,58 @@
+/*
+ * hfidd_hcalls.h
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _HFIDD_HCALLS_H_
+#define _HFIDD_HCALLS_H_
+
+#include <asm/hvcall.h>
+
+/* Token IDs */
+#define H_HFI_START_INTERFACE 0xF000
+#define H_HFI_QUERY_INTERFACE 0xF004
+#define H_HFI_STOP_INTERFACE 0xF008
+
+#define EEH_QUERY 1
+#define COMP_QUERY 2
+
+/* States of Query interface */
+#define NOT_READY 0
+#define NOT_STARTED 1
+#define ACTIVE 2
+#define CLOSING 3
+#define ERROR 101
+
+struct hfi_query_interface {
+ unsigned long long hypervisor_capabilities;
+ unsigned int local_node_id;
+};
+
+#endif /* _HFIDD_HCALLS_H_ */
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index 78a5763..c7c67ca 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -39,10 +39,12 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/slab.h>
+#include <linux/jiffies.h>
+#include <linux/device.h>
#include <linux/hfi/hfidd_client.h>
#include <linux/hfi/hfidd_adpt.h>
-
+#include <linux/hfi/hfidd_hcalls.h>
#define HFIDD_DEV_NAME "hfi"
#define HFIDD_CLASS_NAME "hfi"
@@ -65,6 +67,9 @@ struct hfidd_acs {
unsigned int index;
unsigned int acs_cnt;
unsigned int state;
+
+ unsigned int isr;
+
struct device *hfidd_dev;
struct hfidd_dds dds;
};
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 25/27] HFI: hfi_ip fifo transmit paths
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/ip/hf_proto.h | 1 +
drivers/net/hfi/ip/hfi_ip_main.c | 438 ++++++++++++++++++++++++++++++++++++++
include/linux/hfi/hfi_ip.h | 72 ++++++-
3 files changed, 510 insertions(+), 1 deletions(-)
diff --git a/drivers/net/hfi/ip/hf_proto.h b/drivers/net/hfi/ip/hf_proto.h
index b4133b7..b0232ab 100644
--- a/drivers/net/hfi/ip/hf_proto.h
+++ b/drivers/net/hfi/ip/hf_proto.h
@@ -33,6 +33,7 @@
#ifndef _HF_PROTO_H_
#define _HF_PROTO_H_
+int hf_tx_check_avail(struct hf_net *net, u32 xmit_cls);
extern int hfidd_open_window_func(struct hfidd_acs *p_acs,
u32 is_userspace,
struct hfi_client_info *user_p,
diff --git a/drivers/net/hfi/ip/hfi_ip_main.c b/drivers/net/hfi/ip/hfi_ip_main.c
index 0c1ebd7..689f92e 100644
--- a/drivers/net/hfi/ip/hfi_ip_main.c
+++ b/drivers/net/hfi/ip/hfi_ip_main.c
@@ -185,6 +185,87 @@ alloc_resource_err0:
return rc;
}
+static int hf_send_intr_callback(void *parm, u32 win, u32 ext)
+{
+ struct hf_net *net = (struct hf_net *)parm;
+ struct hf_if *net_if = &(net->hfif);
+ u64 sintr_status;
+
+ sintr_status = hf_mmio_regs_read(net_if, HFI_SINTR_STATUS_REG);
+
+ netdev_info(net->netdev, "hf_send_intr_callback: "
+ "sintr_status 0x%016llx", sintr_status);
+
+ /* mask off the interrupt */
+ if (sintr_status & HF_SFIFO_INTR_EVENT)
+ hf_mmio_regs_write(net_if, HFI_SFIFO_INTR_CNTL, 0);
+
+ /* Make sure interrupts are masked */
+ /* Otherwise after the queue is awaken, it will get stale interrupt */
+ mb();
+
+ netif_wake_queue(net->netdev);
+
+ return 0;
+}
+
+struct hf_events_cb hf_events[HF_EVENT_NUM] = {
+ {HFIDD_SEND, (void *)hf_send_intr_callback},
+};
+
+static int hf_register_ip_events(struct hf_net *net,
+ struct hfidd_acs *p_acs,
+ int flag)
+{
+ struct hf_if *net_if = &(net->hfif);
+ int rc = 0, i, j;
+ struct hfi_reg_events events[HF_EVENT_NUM];
+ int (*reg_func)(struct hfidd_acs *,
+ struct hfi_reg_events *);
+
+ if (flag == HFIDD_REQ_EVENT_REGISTER)
+ reg_func = hfidd_callback_register;
+ else
+ reg_func = hfidd_callback_unregister;
+
+ for (i = 0; i < HF_EVENT_NUM; i++) {
+ events[i].window = net_if->client.window;
+ events[i].type = FUNCTIONS_FOR_EVENTS;
+ events[i].info.func.index = hf_events[i].type;
+ events[i].info.func.function_p.use.kptr = hf_events[i].func;
+ events[i].info.func.parameter.use.kptr = (void *)(net);
+
+ events[i].hdr.req = flag;
+ events[i].hdr.req_len = sizeof(struct hfi_reg_events);
+ events[i].hdr.result.use.kptr = &(events[i]);
+
+ rc = reg_func(p_acs, &(events[i]));
+ if (rc) {
+ netdev_err(net->netdev, "hf_register_ip_events: "
+ "fail event 0x%x, flag=0x%x rc=0x%x\n",
+ hf_events[i].type, flag, rc);
+
+ if (flag == HFIDD_REQ_EVENT_REGISTER)
+ goto err_out;
+ }
+ }
+
+ return rc;
+
+err_out:
+ for (j = 0; j < i; j++) {
+ events[j].hdr.req = HFIDD_REQ_EVENT_UNREGISTER;
+ rc = hfidd_callback_unregister(p_acs, &(events[i]));
+ if (rc) {
+ netdev_err(net->netdev, "hf_register_ip_events: failed "
+ "to unregister callback event 0x%x, rc=0x%x\n",
+ events[i].info.func.index, rc);
+ }
+ }
+
+ return rc;
+}
+
static int hf_close_ip_window(struct hf_net *net, struct hfidd_acs *p_acs)
{
struct hf_if *net_if = &(net->hfif);
@@ -276,6 +357,16 @@ static int hf_set_mac_addr(struct net_device *netdev, void *p)
return 0;
}
+static void hf_init_hw_regs(struct hf_if *net_if)
+{
+ /* setup IP with payload threshold in cache line size */
+ hf_mmio_regs_write(net_if, HFI_IP_RECV_SIZE,
+ (HF_PAYLOAD_RX_THRESHOLD << HF_PAYLOAD_RX_THRESH_SHIFT));
+
+ /* initialize SEND INTR STATUS */
+ hf_mmio_regs_write(net_if, HFI_SINTR_STATUS_REG, 0);
+}
+
static int hf_net_delayed_open(void *parm, u16 win, u16 ext)
{
struct net_device *netdev = (struct net_device *)parm;
@@ -300,13 +391,25 @@ static int hf_net_delayed_open(void *parm, u16 win, u16 ext)
if (rc)
goto delayed_open_err1;
+ rc = hf_register_ip_events(net, p_acs, HFIDD_REQ_EVENT_REGISTER);
+ if (rc)
+ goto delayed_open_err2;
+
hf_set_mac_addr(netdev, NULL);
+ hf_init_hw_regs(net_if);
+
net_if->state = HF_NET_OPEN;
spin_unlock(&(net_if->lock));
+ netif_carrier_on(netdev);
+ netif_start_queue(netdev);
+
return 0;
+delayed_open_err2:
+ hf_close_ip_window(net, p_acs);
+
delayed_open_err1:
hf_free_resource(net_if);
@@ -385,6 +488,11 @@ static int hf_net_close(struct net_device *netdev)
spin_lock(&(net_if->lock));
if (net_if->state == HF_NET_OPEN) {
+ netif_stop_queue(netdev);
+ netif_carrier_off(netdev);
+
+ hf_register_ip_events(net, p_acs, HFIDD_REQ_EVENT_UNREGISTER);
+
hf_close_ip_window(net, p_acs);
hf_free_resource(net_if);
@@ -399,6 +507,332 @@ static int hf_net_close(struct net_device *netdev)
return 0;
}
+static void hf_tx_recycle(struct hf_if *net_if)
+{
+ u32 head, head_idx, slots_per_blk;
+ u32 *fv;
+ int i;
+ u32 fv_bit;
+ u8 nr;
+
+ head = net_if->tx_fifo.head;
+
+ slots_per_blk = net_if->sfifo_slots_per_blk;
+
+ head_idx = head / slots_per_blk;
+
+ fv = (u32 *)(net_if->sfifo_finishvec);
+
+ while (1) {
+ nr = HF_FV_BIT_MAX - head_idx;
+ fv_bit = BIT(nr) & (ACCESS_ONCE(*fv));
+ fv_bit = fv_bit >> nr;
+
+ if ((fv_bit ^ (net_if->sfifo_fv_polarity)) == 0)
+ break;
+
+ for (i = 0; i < slots_per_blk; i++) {
+ struct sk_buff *skb;
+
+ skb = net_if->tx_skb[head + i];
+ if (skb != NULL) {
+ dev_kfree_skb_any(skb);
+ net_if->tx_skb[head + i] = NULL;
+ }
+ }
+
+ head = (head + slots_per_blk) & (net_if->tx_fifo.emax);
+
+ atomic_add(slots_per_blk, &(net_if->tx_fifo.avail));
+
+ if (++head_idx == HF_FV_BIT_CNT) {
+ head_idx = 0;
+ net_if->sfifo_fv_polarity ^= 1;
+ }
+ }
+
+ net_if->tx_fifo.head = head;
+
+ return;
+}
+
+int hf_tx_check_avail(struct hf_net *net, u32 xmit_cls)
+{
+ struct net_device *netdev = net->netdev;
+ struct hf_if *net_if = &(net->hfif);
+
+ if (atomic_read(&net_if->tx_fifo.avail) < xmit_cls) {
+
+ hf_tx_recycle(net_if);
+
+ if (atomic_read(&net_if->tx_fifo.avail) < xmit_cls) {
+ u32 intr_cntl;
+ u64 intr_thresh;
+
+ netif_stop_queue(netdev);
+
+ /* turn on transmit interrupt */
+ intr_thresh = (net_if->sfifo_packets -
+ HF_SFIFO_INTR_WATERMARK) & HF_SFIFO_INTR_MASK;
+
+ intr_cntl = HF_SFIFO_INTR_ENABLE |
+ (intr_thresh << HF_SFIFO_INTR_CNT_SHIFT);
+
+ hf_mmio_regs_write_then_read(net_if,
+ HFI_SFIFO_INTR_CNTL, intr_cntl);
+
+ return -EBUSY;
+ }
+ }
+
+ return 0;
+}
+
+static inline void hf_fill_route(u16 dst_isr, struct base_hdr *base_hdr_p)
+{
+ base_hdr_p->route_control = HFI_HW_DIRECT_ROUTE;
+}
+
+static int hf_copy_skb_to_fifo(struct hf_net *net,
+ struct sk_buff *skb,
+ char *dst,
+ u32 len,
+ u32 offset)
+{
+ struct hf_if *net_if = &(net->hfif);
+ u64 fifo_end;
+ u32 tail_room;
+ int rc;
+
+ fifo_end = (u64)(net_if->tx_fifo.addr) + net_if->tx_fifo.size;
+
+ tail_room = fifo_end - (u64)dst;
+ if (tail_room >= len) {
+ rc = skb_copy_bits(skb, offset, dst, len);
+ if (rc) {
+ netdev_err(net->netdev,
+ "hf_copy_skb_to_fifo: skb_copy_bits"
+ "fail1 offset=0x%x, len=0x%x, rc=0x%x\n",
+ offset, len, rc);
+ return rc;
+ }
+ } else {
+ rc = skb_copy_bits(skb, offset, dst, tail_room);
+ if (rc) {
+ netdev_err(net->netdev,
+ "hf_copy_skb_to_fifo: skb_copy_bits"
+ "fail2 offset=0x%x, len=0x%x, rc=0x%x\n",
+ offset, tail_room, rc);
+
+ return rc;
+ }
+ rc = skb_copy_bits(skb, offset + tail_room,
+ net_if->tx_fifo.addr, len - tail_room);
+ if (rc) {
+ netdev_err(net->netdev,
+ "hf_copy_skb_to_fifo: skb_copy_bits"
+ "fail3 offset=0x%x, len=0x%x, rc=0x%x\n",
+ offset + tail_room, len - tail_room, rc);
+
+ return rc;
+ }
+ }
+
+ return 0;
+}
+
+/* Build base_hdr and proto_hdr for payload pkt.
+ Return pointer to the end of proto_hdr */
+static char *hf_build_payload_hdr(struct hf_net *net,
+ struct sk_buff *skb,
+ u32 msg_len,
+ u32 xmit_cls,
+ u32 is_bcast)
+{
+ struct hf_if *net_if = &(net->hfif);
+ struct hf_if_proto_hdr *proto_hdr_p;
+ struct hfi_ip_with_payload_pkt *hdr_p;
+ char *dst;
+ u8 msg_type, msg_flag;
+ struct ethhdr *hwhdr_p;
+
+ hwhdr_p = (struct ethhdr *)(skb->data);
+
+ if (hwhdr_p->h_proto == htons(ETH_P_IP))
+ msg_type = HF_IF_FIFO;
+ else if (hwhdr_p->h_proto == htons(ETH_P_ARP))
+ msg_type = HF_IF_ARP;
+ else {
+ netdev_err(net->netdev, "hf_build_payload_hdr: h_proto = 0x%x "
+ " not supported\n", hwhdr_p->h_proto);
+
+ dev_kfree_skb_any(skb);
+ return NULL;
+ }
+
+ dst = net_if->tx_fifo.addr +
+ (net_if->tx_fifo.tail << HFI_CACHE_LINE_SHIFT);
+
+ /* fill in base_hdr + ip_extended_hdr */
+ hdr_p = (struct hfi_ip_with_payload_pkt *)dst;
+
+ /* Do not memset over one cacheline since it might wrap */
+ memset(hdr_p, 0, HF_IP_HDR_LEN);
+
+ hdr_p->hfi_hdr.type.header_type = HFI_IP_WITH_PAYLOAD;
+ hdr_p->hfi_hdr.id.job_id = net_if->client.job_id;
+
+ if (is_bcast) {
+ hdr_p->hfi_hdr.base_hdr.dst_isr = HFIDD_DST_BCST_ISR;
+ hdr_p->hfi_hdr.base_hdr.dst_win = HFIDD_DST_BCST_WIN;
+ hdr_p->hfi_hdr.type.header_type = HFI_IP_MULTICAST_WITH_PAYLOAD;
+
+ msg_flag = HF_IF_BCAST;
+ } else {
+ u16 dst_isr, dst_win;
+
+ hf_get_dst_info(hwhdr_p, &dst_isr, &dst_win);
+ hdr_p->hfi_hdr.base_hdr.dst_isr = dst_isr;
+ hdr_p->hfi_hdr.base_hdr.dst_win = dst_win;
+
+ hf_fill_route(dst_isr, &(hdr_p->hfi_hdr.base_hdr));
+
+ msg_flag = HF_IF_UCAST;
+ }
+
+ netdev_dbg(net->netdev, "hf_build_payload_hdr: dst_isr = 0x%x, "
+ "dst_win = 0x%x, xmit_cls = 0x%x\n",
+ hdr_p->hfi_hdr.base_hdr.dst_isr,
+ hdr_p->hfi_hdr.base_hdr.dst_win, xmit_cls);
+
+ hdr_p->hfi_hdr.base_hdr.pkt_len = hfi_cachelines_to_pktlen(xmit_cls);
+
+ dst += HF_IP_HDR_LEN;
+ proto_hdr_p = (struct hf_if_proto_hdr *)dst;
+
+ proto_hdr_p->version = HF_PROTO_HDR_VERSION;
+ proto_hdr_p->msg_len = msg_len;
+ proto_hdr_p->msg_id = net_if->msg_id;
+ proto_hdr_p->msg_type = msg_type;
+ proto_hdr_p->msg_flag = msg_flag;
+
+ dst += HF_PROTO_LEN;
+
+ return dst;
+}
+
+static int hf_payload_tx(struct sk_buff *skb, struct hf_net *net, u32 is_bcast)
+{
+ struct hf_if *net_if = &(net->hfif);
+ u32 msg_len, len;
+ u32 xmit_cls;
+ char *dst;
+ int rc = 0;
+
+ msg_len = skb->len - ETH_HLEN + HF_PROTO_LEN;
+ xmit_cls = hfi_bytes_to_cacheline(msg_len + HF_IP_HDR_LEN);
+
+ if (is_bcast) {
+ if (xmit_cls <= HF_BCAST_CACHE_LINE_2)
+ xmit_cls = HF_BCAST_CACHE_LINE_2;
+ else
+ xmit_cls = HF_BCAST_CACHE_LINE_16;
+ }
+
+ rc = hf_tx_check_avail(net, xmit_cls);
+ if (rc) {
+ netdev_err(net->netdev, "hf_payload_tx: hf_tx_check_avail find "
+ "no avail slot\n");
+ return rc;
+ }
+
+ dst = hf_build_payload_hdr(net, skb, msg_len, xmit_cls, is_bcast);
+ if (!dst)
+ return 0;
+
+ /* copy skb data, skipping hwhdr */
+ len = skb->len - ETH_HLEN;
+
+ rc = hf_copy_skb_to_fifo(net, skb, dst, len, ETH_HLEN);
+ if (rc)
+ return rc;
+
+ net_if->tx_fifo.tail =
+ (net_if->tx_fifo.tail + xmit_cls) & (net_if->tx_fifo.emax);
+ atomic_sub(xmit_cls, &(net_if->tx_fifo.avail));
+
+ net_if->sfifo_packets++;
+ net->netdev->stats.tx_packets++;
+ net->netdev->stats.tx_bytes += msg_len;
+
+ netdev_dbg(net->netdev, "hf_payload_tx: exit, tx_fifo tail = 0x%x, "
+ "avail = 0x%x, skb->len = 0x%x\n", net_if->tx_fifo.tail,
+ atomic_read(&(net_if->tx_fifo.avail)), skb->len);
+
+ dev_kfree_skb_any(skb);
+ return 0;
+
+}
+
+static int hf_start_xmit(struct sk_buff *skb, struct net_device *netdev)
+{
+ struct hf_net *net = netdev_priv(netdev);
+ struct hf_if *net_if = &(net->hfif);
+ u32 len, is_bcast;
+ u32 send_cnt = 1;
+
+ is_bcast = !memcmp(((struct ethhdr *)(skb->data))->h_dest,
+ netdev->broadcast,
+ netdev->addr_len);
+
+ if (unlikely(skb->len <= 0)) {
+ netdev_err(netdev, "hf_start_xmit: invalid skb->len 0x%x\n",
+ skb->len);
+ dev_kfree_skb_any(skb);
+ return NETDEV_TX_OK;
+ }
+
+ /* total len to transfer */
+ len = skb->len - ETH_HLEN;
+
+ if (len <= HF_PAYLOAD_MAX) {
+ /* send ip with payload */
+ if (hf_payload_tx(skb, net, is_bcast) < 0) {
+ netdev_err(netdev, "hf_start_xmit: "
+ "hf_payload_tx fail 1\n");
+
+ return NETDEV_TX_BUSY;
+ }
+ } else {
+ netdev_err(netdev, "hf_start_xmit: skb->len 0x%x "
+ "greater than max 0x%x\n",
+ skb->len, (u32)HF_PAYLOAD_MAX);
+
+ dev_kfree_skb_any(skb);
+ return NETDEV_TX_OK;
+ }
+
+ /* Make sure all fields are written before ringing hw doorbell */
+ wmb();
+
+ /* ring doorbell */
+ hf_mmio_regs_write(net_if, HFI_SFIFO_DB_REG, send_cnt);
+
+ if (atomic_read(&net_if->tx_fifo.avail) < HF_TX_LOW_WATERMARK)
+ hf_tx_check_avail(net, HF_TX_LOW_WATERMARK);
+
+ net_if->msg_id++;
+ netdev->trans_start = jiffies;
+
+ return NETDEV_TX_OK;
+}
+
+static void hf_tx_timeout(struct net_device *netdev)
+{
+ netdev_warn(netdev, "hf_tx_timeout: queue_stopped is %d\n",
+ netif_queue_stopped(netdev));
+}
+
static int hf_change_mtu(struct net_device *netdev, int new_mtu)
{
if ((new_mtu <= 68) || (new_mtu > HF_NET_MTU))
@@ -449,6 +883,8 @@ static const struct net_device_ops hf_netdev_ops = {
.ndo_open = hf_net_open,
.ndo_stop = hf_net_close,
.ndo_change_mtu = hf_change_mtu,
+ .ndo_start_xmit = hf_start_xmit,
+ .ndo_tx_timeout = hf_tx_timeout,
.ndo_set_mac_address = NULL,
};
@@ -465,6 +901,8 @@ static void hf_if_setup(struct net_device *netdev)
netdev->header_ops = &hf_header_ops;
netdev->netdev_ops = &hf_netdev_ops;
+ netdev->watchdog_timeo = HF_TX_TIMEOUT;
+
memcpy(netdev->broadcast, hfi_bcast_addr, ETH_ALEN);
}
diff --git a/include/linux/hfi/hfi_ip.h b/include/linux/hfi/hfi_ip.h
index 6b6a74c..4e70c14 100644
--- a/include/linux/hfi/hfi_ip.h
+++ b/include/linux/hfi/hfi_ip.h
@@ -43,6 +43,7 @@
#include <linux/hfi/hfidd_internal.h>
#include <linux/hfi/hfidd_client.h>
#include <linux/hfi/hfidd_requests.h>
+#include <linux/hfi/hfidd_regs.h>
#include <linux/hfi/hfidd_pkt_formats.h>
#define HF_DRV_VERSION "1.0"
@@ -51,16 +52,32 @@
#define MAX_HF_PER_HFI 2
#define HF_IP_JOBID 0xFFFFFFF0
+#define HF_TX_TIMEOUT (500 * HZ)
+#define HF_NAPI_WEIGHT 256
#define HF_MAX_NAME_LEN 64
+/* sfifo intr: bit 39-55 is threshold */
+/* bit 34 enable, bit 35 unmask */
+#define HF_SFIFO_INTR_ENABLE (0x3 << (63 - 35))
+#define HF_SFIFO_INTR_MASK 0x1FFFF /* 17 bits */
+#define HF_SFIFO_INTR_CNT_SHIFT (63 - 55)
+#define HF_SFIFO_INTR_EVENT 0x00000040 /* bit 57 */
+#define HF_SFIFO_INTR_WATERMARK (HF_SFIFO_SLOTS - (HF_SFIFO_SLOTS >> 3))
+
#define HF_SFIFO_SIZE 0x40000 /* 256K */
#define HF_SFIFO_SLOTS (HF_SFIFO_SIZE >> HFI_CACHE_LINE_SHIFT)
#define HF_RFIFO_SIZE 0x1000000 /* 16M */
#define HF_RFIFO_SLOTS (HF_RFIFO_SIZE >> HFI_CACHE_LINE_SHIFT)
+#define HF_TX_LOW_WATERMARK (HF_SFIFO_SLOTS >> 4)
#define HF_FV_BIT_CNT 32
+#define HF_FV_BIT_MAX 31
+#define HF_SEND_ONE 1
-#define HF_NET_MTU (2048 - HF_IP_HDR_LEN - HF_PROTO_LEN)
+#define HF_PAYLOAD_MAX (2048 - HF_IP_HDR_LEN - HF_PROTO_LEN)
+#define HF_NET_MTU HF_PAYLOAD_MAX
+#define HF_PAYLOAD_RX_THRESHOLD 0x10ULL
+#define HF_PAYLOAD_RX_THRESH_SHIFT 59
struct hfi_ip_extended_hdr { /* 16B */
unsigned int immediate_len:7;/* In bytes */
@@ -83,6 +100,14 @@ struct hfi_ip_with_payload_pkt {
#define HF_IP_HDR_LEN ((sizeof(struct hfi_hdr) + \
sizeof(struct hfi_ip_extended_hdr)))
#define HF_ALIGN_PAD 2
+#define HF_PROTO_HDR_VERSION 0x1
+/* HFI protocol message type */
+#define HF_IF_ARP 0xA0
+#define HF_IF_FIFO 0xA1
+
+/* HFI protocol message flag */
+#define HF_IF_UCAST 0xB0
+#define HF_IF_BCAST 0xB1
struct hf_if_proto_hdr {
u16 version;
@@ -93,6 +118,8 @@ struct hf_if_proto_hdr {
};
#define HF_PROTO_LEN sizeof(struct hf_if_proto_hdr)
+#define HF_BCAST_CACHE_LINE_16 16
+#define HF_BCAST_CACHE_LINE_2 2
struct hf_fifo {
void *addr;
@@ -119,6 +146,7 @@ struct hf_if {
u32 sfifo_fv_polarity;
u32 sfifo_slots_per_blk;
u32 sfifo_packets;
+ u32 msg_id;
void __iomem *doorbell; /* mapped mmio_regs */
struct hf_fifo tx_fifo;
struct hf_fifo rx_fifo;
@@ -144,5 +172,47 @@ struct hf_global_info {
extern struct hf_global_info hf_ginfo;
+#define HF_EVENT_NUM 1
+
+struct hf_events_cb {
+ enum hfi_event_type type;
+ void *func;
+};
+
#define HF_MAC_HFI_SHIFT 12
+#define HF_HDR_HFI_SHIFT 8
+
+static inline u32 hf_get_win(u16 id)
+{
+ return ((id >> HF_MAC_HFI_SHIFT) << HF_HDR_HFI_SHIFT) | (id & 0xFF);
+}
+
+static inline void hf_get_dst_info(struct ethhdr *hwhdr_p,
+ u16 *d_isr,
+ u16 *d_win)
+{
+ *d_isr = (*(u16 *)(&(hwhdr_p->h_dest[2]))) & 0xFFF;
+ *d_win = hf_get_win(*(u16 *)(&(hwhdr_p->h_dest[4])));
+}
+
+static inline void hf_mmio_regs_write_then_read(struct hf_if *net_if,
+ int off,
+ u64 data)
+{
+ __raw_writeq(data, net_if->doorbell + off);
+ isync();
+ __raw_readq(net_if->doorbell + off);
+ /* Make sure all received pkt shows up in rfifo */
+ mb();
+}
+
+static inline u64 hf_mmio_regs_read(struct hf_if *net_if, int off)
+{
+ return __raw_readq(net_if->doorbell + off);
+}
+
+static inline void hf_mmio_regs_write(struct hf_if *net_if, int off, u64 data)
+{
+ __raw_writeq(data, net_if->doorbell + off);
+}
#endif
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 10/27] HFI: HFIDD_REQ_OPEN_WINDOW request
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Set up protocol access to an HFI window.
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/Makefile | 1 +
drivers/net/hfi/core/hfidd_init.c | 14 +++++++
drivers/net/hfi/core/hfidd_proto.h | 3 +
drivers/net/hfi/core/hfidd_window.c | 70 +++++++++++++++++++++++++++++++++++
include/linux/hfi/hfidd_client.h | 22 +++++++++++
include/linux/hfi/hfidd_internal.h | 26 +++++++++++++
include/linux/hfi/hfidd_requests.h | 1 +
7 files changed, 137 insertions(+), 0 deletions(-)
create mode 100644 drivers/net/hfi/core/hfidd_window.c
diff --git a/drivers/net/hfi/core/Makefile b/drivers/net/hfi/core/Makefile
index 4e6cbd6..0224a57 100644
--- a/drivers/net/hfi/core/Makefile
+++ b/drivers/net/hfi/core/Makefile
@@ -2,6 +2,7 @@
# Makefile for the HFI device driver for IBM eServer System p
#
hfi_core-objs:= hfidd_adpt.o \
+ hfidd_window.o \
hfidd_init.o \
hfidd_hcalls.o
obj-$(CONFIG_HFI) += hfi_core.o
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
index df79ae9..49099ec 100644
--- a/drivers/net/hfi/core/hfidd_init.c
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -129,6 +129,20 @@ static ssize_t hfidd_cmd_write(struct file *filep, const char __user *buf,
}
switch (cmd.req) {
+ case HFIDD_REQ_OPEN_WINDOW:
+ if (cmd.req_len != sizeof(struct hfi_client_info)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_cmd_write: hdr.reqlen 0x%x expected "
+ "0x%lx for cmd req 0x%x\n",
+ cmd.req_len,
+ sizeof(struct hfi_client_info), cmd.req);
+ return -EINVAL;
+ }
+ rc = hfidd_open_window_func(p_acs, is_userspace,
+ (struct hfi_client_info *) buf,
+ (struct hfi_client_info *) cmd.result.use.kptr);
+ break;
+
case HFIDD_REQ_QUERY_DD_INFO:
if (cmd.req_len != sizeof(struct hfi_query_dd_info)) {
dev_printk(KERN_ERR, p_acs->hfidd_dev,
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
index c61387e..e7f2901 100644
--- a/drivers/net/hfi/core/hfidd_proto.h
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -39,6 +39,9 @@ int hfidd_alloc_windows(struct hfidd_acs *p_acs);
void hfidd_free_windows(struct hfidd_acs *p_acs);
int hfidd_init_adapter(struct hfidd_acs *p_acs, void *uiop);
int hfidd_age_hcall(u64 time_start);
+int hfidd_open_window_func(struct hfidd_acs *p_acs, unsigned int is_userspace,
+ struct hfi_client_info *user_p,
+ struct hfi_client_info *out_p);
int hfidd_get_phyp_page(struct hfidd_acs *p_acs, caddr_t *page,
caddr_t *laddr, int size);
void hfidd_release_phyp_page(caddr_t page, int size);
diff --git a/drivers/net/hfi/core/hfidd_window.c b/drivers/net/hfi/core/hfidd_window.c
new file mode 100644
index 0000000..f16caf7
--- /dev/null
+++ b/drivers/net/hfi/core/hfidd_window.c
@@ -0,0 +1,70 @@
+/*
+ * hfidd_window.c
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/hfi/hfidd_internal.h>
+#include <linux/hfi/hfidd_hcalls.h>
+#include "hfidd_proto.h"
+#include <linux/hfi/hfidd_requests.h>
+
+/*
+ * Allows an user/kernel window to send/receive network traffic thru HFI
+ * adapter. This function will allocate the system resources needed to open
+ * a window. If any problem detected, then the request will fail. This function
+ * is called directly by kernel users and by a write system call by userspace.
+ */
+int hfidd_open_window_func(struct hfidd_acs *p_acs, unsigned int is_userspace,
+ struct hfi_client_info *user_p,
+ struct hfi_client_info *out_p)
+{
+ int rc = 0;
+ struct hfi_client_info *local_p = NULL;
+
+ /* Allocate local data structure */
+ local_p = kmalloc(sizeof(struct hfi_client_info), GFP_KERNEL);
+ if (local_p == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "open_window_func: kmalloc local_p failed\n");
+ return -ENOMEM;
+ }
+
+ /* Copy into local from user */
+ rc = hfi_copy_from_user((void *)local_p, (void *)user_p,
+ is_userspace, sizeof(struct hfi_client_info));
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "open_window_func: hfi_copy_from_user failed\n");
+ }
+
+ kfree(local_p);
+ return rc;
+}
+EXPORT_SYMBOL_GPL(hfidd_open_window_func);
diff --git a/include/linux/hfi/hfidd_client.h b/include/linux/hfi/hfidd_client.h
index c3c8fef..7e4c1a7 100644
--- a/include/linux/hfi/hfidd_client.h
+++ b/include/linux/hfi/hfidd_client.h
@@ -69,6 +69,28 @@ struct fifo_info {
unsigned long long size; /* bytes */
};
+/*
+ * HFIDD_REQ_OPEN_WINDOW: Window Open
+ * For reserved windows
+ * The job scheduler provides the application with window number and
+ * jobid, which need to be passed in/will be checked on the window open.
+ * Immediate send slots were also reserved by the job scheduler, and the
+ * DD returns the count. The application has the option of setting
+ * protection keys by task or by jobid. Protection key is passed in.
+ * For Dynamic windows
+ * The DD will select a free dynamic window and return its window number.
+ * The jobid will be assigned by the DD (upper bits set to select a
+ * reserved range of jobids, lower bits come from userid). The
+ * protection key flag is always by task. The protection key is passed in.
+ * For Kernel/IP windows
+ * The DD will select a free dynamic window and return its window number.
+ * The jobid is passed in. The jobid is used for the protection key.
+ *
+ * Finished vectors:
+ * sfifo_finishvec and imm_finishvec must reside in an extra page (last
+ * page) in the sfifo memory range, provided by the user.
+ */
+
#define HFIDD_IP_WIN 1 /* IP windows get broadcasts forwarded
to them... */
#define HFIDD_KERNEL_WIN 2 /* ... other kernel windows do not */
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index 420d55a..951314a 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -142,4 +142,30 @@ struct hfidd_global {
struct hfidd_acs *p_acs[MAX_HFIS];
};
+static inline int hfi_copy_to_user(void *user_p, void *local_p,
+ unsigned int is_userspace, unsigned int size)
+{
+ int rc = 0;
+
+ if (is_userspace)
+ rc = copy_to_user(user_p, local_p, size);
+ else
+ memcpy(user_p, local_p, size);
+
+ return rc;
+}
+
+static inline int hfi_copy_from_user(void *local_p, void *user_p,
+ unsigned int is_userspace, unsigned int size)
+{
+ int rc = 0;
+
+ if (is_userspace)
+ rc = copy_from_user(local_p, user_p, size);
+ else
+ memcpy(local_p, user_p, size);
+
+ return rc;
+}
+
#endif
diff --git a/include/linux/hfi/hfidd_requests.h b/include/linux/hfi/hfidd_requests.h
index b6e255f..4f1c74d 100644
--- a/include/linux/hfi/hfidd_requests.h
+++ b/include/linux/hfi/hfidd_requests.h
@@ -33,6 +33,7 @@
#ifndef _HFIDD_REQUESTS_H_
#define _HFIDD_REQUESTS_H_
+#define HFIDD_REQ_OPEN_WINDOW 0x00000a01
#define HFIDD_REQ_QUERY_DD_INFO 0x00001004
#endif /* _HFIDD_REQUESTS_H_ */
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 02/27] HFI: Add HFI adapter control structure
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Alloc/free of hfidd_acs to track the state of each HFI
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/Makefile | 3 +-
drivers/net/hfi/core/hfidd_adpt.c | 58 ++++++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_init.c | 55 ++++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_proto.h | 39 ++++++++++++++++++++++++
include/linux/hfi/hfidd_adpt.h | 45 ++++++++++++++++++++++++++++
include/linux/hfi/hfidd_internal.h | 14 ++++++++
6 files changed, 213 insertions(+), 1 deletions(-)
create mode 100644 drivers/net/hfi/core/hfidd_adpt.c
create mode 100644 drivers/net/hfi/core/hfidd_proto.h
create mode 100644 include/linux/hfi/hfidd_adpt.h
diff --git a/drivers/net/hfi/core/Makefile b/drivers/net/hfi/core/Makefile
index 80790c6..6fe4e60 100644
--- a/drivers/net/hfi/core/Makefile
+++ b/drivers/net/hfi/core/Makefile
@@ -1,5 +1,6 @@
#
# Makefile for the HFI device driver for IBM eServer System p
#
-hfi_core-objs:= hfidd_init.o
+hfi_core-objs:= hfidd_adpt.o \
+ hfidd_init.o
obj-$(CONFIG_HFI) += hfi_core.o
diff --git a/drivers/net/hfi/core/hfidd_adpt.c b/drivers/net/hfi/core/hfidd_adpt.c
new file mode 100644
index 0000000..ec6a053
--- /dev/null
+++ b/drivers/net/hfi/core/hfidd_adpt.c
@@ -0,0 +1,58 @@
+/*
+ * hfidd_adpt.c
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/hfi/hfidd_internal.h>
+#include "hfidd_proto.h"
+
+int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t devno, void *uiop)
+{
+
+ struct hfidd_acs *p_acs = NULL;
+
+ p_acs = kzalloc(sizeof(*p_acs), GFP_KERNEL);
+ if (p_acs == NULL)
+ return -ENOMEM;
+
+ p_acs->dev_num = devno;
+ p_acs->index = MINOR(devno);
+ p_acs->state = HFI_INVALID;
+ snprintf(p_acs->name, HFI_DEVICE_NAME_MAX,
+ "%s%d", HFIDD_DEV_NAME, p_acs->index);
+
+ *adpt = p_acs;
+ return 0;
+}
+
+void hfidd_free_adapter(struct hfidd_acs *p_acs)
+{
+ kfree(p_acs);
+}
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
index 9498faf..61ed559 100644
--- a/drivers/net/hfi/core/hfidd_init.c
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -35,6 +35,7 @@
#include <linux/device.h>
#include <linux/hfi/hfidd_internal.h>
+#include "hfidd_proto.h"
MODULE_VERSION("1.0");
MODULE_DESCRIPTION("Device Driver for IBM eServer HFI for IBM System p");
@@ -117,10 +118,52 @@ hfidd_create_class_error1:
return rc;
}
+/* Free adapter resources and the devicese */
+static void hfidd_destroy_devices(void)
+{
+ int i;
+
+ for (i = 0; i < MAX_HFIS; i++) {
+ hfidd_free_adapter(hfidd_global.p_acs[i]);
+ hfidd_global.p_acs[i] = NULL;
+ hfidd_global.acs_cnt--;
+ }
+}
+
+/*
+ * Create the adapter structure, allocate resources and create
+ * the hfi devices
+ */
+static int hfidd_create_devices(void)
+{
+ int i, j;
+ int rc = 0;
+
+ for (i = 0; i < MAX_HFIS; i++) {
+ rc = hfidd_alloc_adapter(&(hfidd_global.p_acs[i]),
+ MKDEV(MAJOR(hfidd_dev), i), NULL);
+ if (rc) {
+ printk(KERN_ERR "%s: hfidd_create_devices: "
+ "hfidd_alloc_adapter fail rc = %d\n",
+ HFIDD_DEV_NAME, rc);
+ for (j = 0; j < i; j++) {
+ hfidd_free_adapter(hfidd_global.p_acs[j]);
+ hfidd_global.p_acs[j] = NULL;
+ hfidd_global.acs_cnt--;
+ }
+ return rc;
+ }
+ hfidd_global.acs_cnt++;
+ }
+ return rc;
+}
+
static int __init hfidd_mod_init(void)
{
int rc = 0;
+ hfidd_global.acs_cnt = 0;
+
rc = hfidd_create_class();
if (rc < 0) {
printk(KERN_ERR "%s: hfidd_mod_init: hfidd_create_class failed"
@@ -128,12 +171,24 @@ static int __init hfidd_mod_init(void)
return rc;
}
+ rc = hfidd_create_devices();
+ if (rc < 0) {
+ printk(KERN_ERR "%s: hfidd_mod_init: hfidd_create_devices"
+ " failed rc = %d\n", HFIDD_DEV_NAME, rc);
+ goto error1;
+ }
+
printk(KERN_INFO "IBM hfi device driver loaded sucessfully\n");
return 0;
+
+error1:
+ hfidd_destroy_class();
+ return rc;
}
static void __exit hfidd_mod_exit(void)
{
+ hfidd_destroy_devices();
hfidd_destroy_class();
}
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
new file mode 100644
index 0000000..01a5ba2
--- /dev/null
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -0,0 +1,39 @@
+/*
+ * hfidd_proto.h
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com)
+ *
+ * Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _HFIDD_PROTO_H_
+#define _HFIDD_PROTO_H_
+
+int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t, void *uiop);
+void hfidd_free_adapter(struct hfidd_acs *p_acs);
+
+#endif
diff --git a/include/linux/hfi/hfidd_adpt.h b/include/linux/hfi/hfidd_adpt.h
new file mode 100644
index 0000000..6b1432d
--- /dev/null
+++ b/include/linux/hfi/hfidd_adpt.h
@@ -0,0 +1,45 @@
+/*
+ * hfidd_adpt.h
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _HFIDD_ADPT_H_
+#define _HFIDD_ADPT_H_
+
+#include <linux/hfi/hfidd_client.h>
+
+
+/* Adpt state */
+#define HFI_INVALID 0
+#define HFI_AVAIL 1
+#define HFI_GOING_UNAVAIL 2
+#define HFI_UNAVAIL 3
+
+#endif /* _HFIDD_ADPT_H_ */
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index f5de1bb..66765a5 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -38,16 +38,30 @@
#include <linux/cdev.h>
#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/slab.h>
#include <linux/hfi/hfidd_client.h>
+#include <linux/hfi/hfidd_adpt.h>
#define HFIDD_DEV_NAME "hfi"
#define HFIDD_CLASS_NAME "hfi"
+#define HFI_DEVICE_NAME_MAX 8
+/* hfi global */
+struct hfidd_acs {
+ dev_t dev_num;
+ char name[HFI_DEVICE_NAME_MAX];
+ unsigned int index;
+ unsigned int acs_cnt;
+ unsigned int state;
+};
+
/* DD global */
struct hfidd_global {
struct cdev cdev;
struct class *class;
+ int acs_cnt;
+ struct hfidd_acs *p_acs[MAX_HFIS];
};
#endif
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 21/27] HFI: Add send and receive interrupts
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Each window has its own interrupt for send interrupts and another for receive
interrupts.
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/Makefile | 1 +
drivers/net/hfi/core/hfidd_intr.c | 127 +++++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_proto.h | 3 +
drivers/net/hfi/core/hfidd_window.c | 16 ++++-
include/linux/hfi/hfidd_client.h | 17 +++++
include/linux/hfi/hfidd_internal.h | 2 +
6 files changed, 165 insertions(+), 1 deletions(-)
create mode 100644 drivers/net/hfi/core/hfidd_intr.c
diff --git a/drivers/net/hfi/core/Makefile b/drivers/net/hfi/core/Makefile
index 3adf07e..d2ed86f 100644
--- a/drivers/net/hfi/core/Makefile
+++ b/drivers/net/hfi/core/Makefile
@@ -6,5 +6,6 @@ hfi_core-objs:= hfidd_adpt.o \
hfidd_init.o \
hfidd_xlat.o \
hfidd_map.o \
+ hfidd_intr.o \
hfidd_hcalls.o
obj-$(CONFIG_HFI) += hfi_core.o
diff --git a/drivers/net/hfi/core/hfidd_intr.c b/drivers/net/hfi/core/hfidd_intr.c
new file mode 100644
index 0000000..253de27
--- /dev/null
+++ b/drivers/net/hfi/core/hfidd_intr.c
@@ -0,0 +1,127 @@
+/*
+ * hfidd_intr.c
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/hfi/hfidd_internal.h>
+#include "hfidd_proto.h"
+
+static irqreturn_t send_intr_handler(int irq, void *data)
+{
+ struct hfidd_window *win_p = data;
+ struct hfidd_acs *p_acs;
+
+ p_acs = hfidd_global.p_acs[win_p->ai];
+ if (p_acs == NULL)
+ return IRQ_HANDLED;
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t recv_intr_handler(int irq, void *data)
+{
+ struct hfidd_window *win_p = data;
+ struct hfidd_acs *p_acs;
+
+ p_acs = hfidd_global.p_acs[win_p->ai];
+ if (p_acs == NULL)
+ return IRQ_HANDLED;
+
+ return IRQ_HANDLED;
+}
+
+static inline void hfidd_clear_interrupt(unsigned int int_level,
+ struct hfidd_window *win_p)
+{
+ ibmebus_free_irq(int_level, win_p);
+}
+
+static int hfidd_init_interrupt(struct hfidd_acs *p_acs,
+ struct hfidd_window *win_p ,
+ irqreturn_t (*handler)(int, void *),
+ const char *name,
+ unsigned int int_level)
+{
+ int rc;
+
+ rc = ibmebus_request_irq(int_level, handler, IRQF_DISABLED, name,
+ win_p);
+ if (rc != 0) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_init_interrupt: request_irq failed for "
+ "int_level 0x%x rc %d\n", int_level, rc);
+ return rc;
+ }
+ return rc;
+}
+
+int hfidd_init_win_interrupt(struct hfidd_acs *p_acs,
+ struct hfidd_window *win_p)
+{
+ int rc;
+
+ /* init send interrupt handler */
+ snprintf(win_p->send_name, IRQ_NAME_SIZE - 1, "%s%d-send%d",
+ HFIDD_DEV_NAME, p_acs->index, win_p->index);
+ rc = hfidd_init_interrupt(p_acs, win_p, send_intr_handler,
+ win_p->send_name, win_p->send_intr);
+ if (rc != 0) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_init_win_interrupt: send int failed, "
+ "rc = 0x%x\n", rc);
+ return rc;
+ }
+
+ /* init recv interrupt handler */
+ snprintf(win_p->recv_name, IRQ_NAME_SIZE - 1, "%s%d-recv%d",
+ HFIDD_DEV_NAME, p_acs->index, win_p->index);
+ rc = hfidd_init_interrupt(p_acs, win_p, recv_intr_handler,
+ win_p->recv_name, win_p->recv_intr);
+ if (rc != 0) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_init_win_interrupt: recv int failed, "
+ "rc = 0x%x\n", rc);
+ hfidd_clear_interrupt(win_p->send_intr, win_p);
+ return rc;
+ }
+ return 0;
+}
+
+void hfidd_clear_win_interrupt(struct hfidd_window *win_p)
+{
+ if (win_p->send_intr != 0) {
+ hfidd_clear_interrupt(win_p->send_intr, win_p);
+ win_p->send_intr = 0;
+ }
+ if (win_p->recv_intr != 0) {
+ hfidd_clear_interrupt(win_p->recv_intr, win_p);
+ win_p->recv_intr = 0;
+ }
+}
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
index f531dcd..af88f0b 100644
--- a/drivers/net/hfi/core/hfidd_proto.h
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -73,6 +73,9 @@ int hfidd_query_interface(struct hfidd_acs *p_acs, unsigned int subtype,
int hfidd_start_nmmu(struct hfidd_acs *p_acs);
int hfidd_start_interface(struct hfidd_acs *p_acs);
int hfidd_stop_interface(struct hfidd_acs *p_acs, unsigned int hfi_id);
+int hfidd_init_win_interrupt(struct hfidd_acs *p_acs,
+ struct hfidd_window *win_p);
+void hfidd_clear_win_interrupt(struct hfidd_window *win_p);
long long hfi_start_nmmu(u64 chip_id, void *nmmu_info);
long long hfi_stop_nmmu(u64 chip_id);
long long hfi_open_window(u64 unit_id, u64 win_id, u64 flag,
diff --git a/drivers/net/hfi/core/hfidd_window.c b/drivers/net/hfi/core/hfidd_window.c
index fd692eb..6864eae 100644
--- a/drivers/net/hfi/core/hfidd_window.c
+++ b/drivers/net/hfi/core/hfidd_window.c
@@ -1049,6 +1049,15 @@ int hfidd_open_window_func(struct hfidd_acs *p_acs, unsigned int is_userspace,
local_p->local_isrid = p_acs->isr;
win_p->client_info.local_isrid = p_acs->isr;
+ /* Init the send and recv interrupt handlers */
+ rc = hfidd_init_win_interrupt(p_acs, win_p);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_open_window_func: hfidd_init_win_interrupt "
+ "failed, rc = 0x%x\n", rc);
+ goto hfidd_open_window_func_err6;
+ }
+
/* Copy out the client info back to user */
rc = hfi_copy_to_user((void *)out_p, (void *)local_p,
is_userspace, sizeof(struct hfi_client_info));
@@ -1056,7 +1065,7 @@ int hfidd_open_window_func(struct hfidd_acs *p_acs, unsigned int is_userspace,
dev_printk(KERN_ERR, p_acs->hfidd_dev,
"hfidd_open_window_func: hfi_copy_to_user "
"failed, rc = 0x%x\n", rc);
- goto hfidd_open_window_func_err6;
+ goto hfidd_open_window_func_err7;
}
spin_lock(&(win_p->win_lock));
@@ -1068,6 +1077,8 @@ int hfidd_open_window_func(struct hfidd_acs *p_acs, unsigned int is_userspace,
kfree(local_p);
return rc;
+hfidd_open_window_func_err7:
+ hfidd_clear_win_interrupt(win_p);
hfidd_open_window_func_err6:
if (is_userspace)
hfidd_unmap(local_p->mmio_regs.use.kptr, PAGE_SIZE_64K);
@@ -1134,6 +1145,9 @@ int hfidd_close_window_internal(struct hfidd_acs *p_acs,
}
spin_unlock(&(win_p->win_lock));
+ /* Clear the send and recv interrupt handlers */
+ hfidd_clear_win_interrupt(win_p);
+
rc = hfi_unmap_mmio_regs(p_acs, win_p, is_userspace);
if (rc) {
dev_printk(KERN_ERR, p_acs->hfidd_dev,
diff --git a/include/linux/hfi/hfidd_client.h b/include/linux/hfi/hfidd_client.h
index 11c8973..3b2d032 100644
--- a/include/linux/hfi/hfidd_client.h
+++ b/include/linux/hfi/hfidd_client.h
@@ -121,6 +121,23 @@ struct hfi_window_info {
unsigned int window;
};
+/* Event Notification */
+enum hfi_event_type {
+ HFIDD_SEND = 0,
+ HFIDD_RECV = 1,
+ HFIDD_WIN_ERROR = 2,
+ HFIDD_HFI_ERROR = 3,
+ HFIDD_TERMINATE = 4,
+ HFIDD_RELEASE_WINDOW = 5,
+ HFIDD_CAU_ERROR = 6,
+ HFIDD_ICS_ERROR = 7,
+ HFIDD_HFI_READY_REG = 8,
+ HFIDD_ROUTE_CHANGE = 9,
+ HFIDD_IP_TRC_LVL = 10, /* IP Window only */
+ HFIDD_POOL_SIZE = 11, /* IP Window only */
+ HFIDD_NUM_EVENT_TYPES = 12
+};
+
#define MAX_TORRENTS 1
#define MAX_HFI_PER_TORRENT 2
#define MAX_HFIS (MAX_TORRENTS * MAX_HFI_PER_TORRENT)
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index 820df48..f82a626 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -145,6 +145,8 @@ struct hfidd_global {
struct hfidd_acs *p_acs[MAX_HFIS];
};
+extern struct hfidd_global hfidd_global;
+
static inline struct hfidd_window *hfi_window(struct hfidd_acs *p,
unsigned int idx)
{
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 23/27] HFI: Define packet header formats and window register offsets
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
include/linux/hfi/hfidd_pkt_formats.h | 338 +++++++++++++++++++++++++++++++++
include/linux/hfi/hfidd_regs.h | 212 +++++++++++++++++++++
2 files changed, 550 insertions(+), 0 deletions(-)
create mode 100644 include/linux/hfi/hfidd_pkt_formats.h
create mode 100644 include/linux/hfi/hfidd_regs.h
diff --git a/include/linux/hfi/hfidd_pkt_formats.h b/include/linux/hfi/hfidd_pkt_formats.h
new file mode 100644
index 0000000..ee8d385
--- /dev/null
+++ b/include/linux/hfi/hfidd_pkt_formats.h
@@ -0,0 +1,338 @@
+/*
+ * hfidd_pkt_formats.h
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _HFI_PKT_FORMATS_H
+#define _HFI_PKT_FORMATS_H
+
+#define HFI_HW_DIRECT_ROUTE 0
+#define HFI_SW_INDIRECT_ROUTE 1
+#define HW_DIRECT_STRIPING_ROUTE 2
+#define HW_INDIRECT_STRIPING_ROUTE 3
+
+/* HFI packet header format */
+
+struct immediate_send_hdr {
+ unsigned int reserved1:8;
+ unsigned int cop_type:8; /* HFI coprocessor type is 0x3A */
+ unsigned int reserved2:7;
+ unsigned int src_win:9; /* Hi bit is hfi# */
+} __packed;
+
+struct packet_type_hdr {
+ unsigned int header_type:7; /* See hfi_packet_type for types */
+ unsigned int send_origin:1; /* 0: from Send/RDMA FIFO */
+ /* 1: from Immediate Send */
+} __packed;
+
+struct base_hdr {
+ unsigned int reserve1:1;
+ unsigned int dst_isr:14; /* destination ISR */
+ unsigned int dst_win:9; /* destination window.
+ Hi bit is hfi num */
+ unsigned int reserve2:1;
+
+ unsigned int src_isr:14; /* src ISR, Set by hardware */
+ unsigned int src_win:9; /* src window, Set by hardware.
+ Hi bit is hfi num */
+ unsigned int src_cau:1;
+ unsigned int dst_cau:1;
+ unsigned int reserve3:2;
+
+ unsigned int pkt_len:4; /* In cache lines. 0 means 16 */
+ unsigned int reserve4:8;
+ unsigned int trc_enable:1; /* Request ISR trace info
+ send/recv, IP packest only */
+ unsigned int ctr_incr:1; /* Request send and receive
+ counter increments */
+ unsigned int sii:1; /* Source Side Immediate Int */
+ unsigned int dii:1; /* Dest Side Immediate Int */
+ unsigned int reserve5:3;
+ unsigned int pkt_valid:1; /* Set by hardware
+ Toggles when rFIFO wraps */
+ unsigned int status:5; /* Set by hardware completion status */
+ unsigned int route_control:2;/* ISR use only */
+ unsigned int ind_node:9; /* ISR use only */
+} __packed;
+
+struct hfi_rdma_extended_hdr { /* 48B */
+ unsigned long long source_ea; /* Full RDMA only, byte
+ boundary */
+ unsigned long long dest_ea; /* byte boundary, independent of
+ source data boundary */
+ unsigned int pkt_len:4; /* In cache lines, with
+ exceptions */
+ unsigned int reserved1:3;
+ unsigned int msg_len:25; /* In bytes.
+ FullRDMA: Max 32MB
+ (encoded as 0)
+ HalfRDMA: Max 2kB
+ SmallRDMA: Max 16B */
+ unsigned int reserved2:5;
+ unsigned int rcxt_offset:20; /* into window's rcxt area */
+ unsigned int reserved3:1;
+ unsigned int breakup:6; /* Message Breakup count */
+ unsigned int epoch:32;
+ unsigned int seq_num:14;
+ unsigned int pkt_cnt:18; /* FullRDMA only */
+ unsigned int reserved4:3;
+ unsigned int rcxt_index:5; /* 1-31 allowed */
+ unsigned int read_indicator:1; /* 1 for FULL RDMA reads */
+ unsigned int src_completion:1;
+ unsigned int src_completion_notify:1;
+ unsigned int dst_completion_notify:1;
+ unsigned int status:5; /* Notification packet only. */
+ unsigned int reserved6:3;
+ unsigned int fetch:1; /* SmallRDMA only. */
+ unsigned int opcode:3;
+ unsigned int reserved7:8;
+ unsigned int reserved8:32;
+ unsigned long long cookie; /* Protocol cookie */
+} __packed;
+
+struct gups_rdma_element { /* 32B. Used without Base
+ header */
+ unsigned int job_id:32;
+ unsigned int header_type:7; /* Use GUPS types only */
+ unsigned int reserved1:2;
+ unsigned int dst_isr:14; /* destination ISR */
+ unsigned int dst_win:9; /* destination window.
+ Hi bit is hfi# */
+ unsigned int reserved2:15;
+ unsigned int ctr_incr:1; /* Request send and receive
+ counter increments */
+ unsigned int isr_route_hdr:16; /* ISR use only */
+ unsigned int reserved3:32;
+
+ union {
+ unsigned long long addr;
+ struct {
+ unsigned int dest_ea_hi:32;
+ unsigned int dest_ea_lo:29; /* 8-byte align */
+ unsigned int opcode:3; /* Use HFI_OPCODE* */
+ } bits;
+ } dest_ea;
+
+ unsigned long long payload;
+} __packed;
+
+struct hfi_cau_extended_hdr { /* 32B */
+ unsigned int group_id:27;
+ unsigned int dst_sub_id:9;
+ unsigned int src_sub_id:9;
+ unsigned int reserved1:3;
+ unsigned int op_attr_unsigned:1; /* 0->Signed */
+ unsigned int op_attr_64bit:1; /* 0->32 bit */
+ unsigned int op_attr_float:1; /* 0->Fixed */
+ unsigned int function:5;
+ unsigned int payload_cnt:8; /* bitmask */
+ unsigned int seq_num:32;
+ unsigned int reserved2:6;
+ unsigned int entry:1; /* 0->A, 1->B */
+ unsigned int reserved3:25;
+ unsigned long long cookie_left; /* Protocol Cookie */
+ unsigned long long cookie_right;
+} __packed;
+
+struct hfi_hdr {
+ union {
+ struct immediate_send_hdr immediate_hdr;
+ unsigned int job_id;
+ } id;
+
+ struct packet_type_hdr type;
+ struct base_hdr base_hdr;
+} __packed;
+
+struct hfi_rdma_hdr {
+ struct hfi_hdr hfi_hdr;
+ struct hfi_rdma_extended_hdr rdma_ext;
+ /*
+ * Pad enough for the payload to be aligned with the dest address.
+ * SmallRDMA: no padding FullRDMA: packets 2-N pad 64 bytes
+ */
+} __packed;
+
+
+struct hfi_rdma_pkt {
+ struct hfi_hdr hfi_hdr;
+ struct hfi_rdma_extended_hdr rdma_ext;
+ /*
+ * Pad enough for the payload to be aligned with the dest address.
+ * SmallRDMA: no padding FullRDMA: packets 2-N pad 64 bytes
+ */
+ char padding_slash_payload[1984];
+} __packed;
+
+
+#define CACHE_LINE_SIZE 0x80
+#define CACHE_LINE_SHIFT 0x7
+/*
+ * Encode/Decode macros/inlines for bit fields
+ */
+static inline unsigned int hfi_bytes_to_cacheline(unsigned int bytes)
+{
+ return (bytes + (CACHE_LINE_SIZE - 1)) >> CACHE_LINE_SHIFT;
+}
+
+static inline unsigned int HFI_CACHELINES_TO_BYTES(unsigned int cache_lines)
+{
+ return cache_lines << CACHE_LINE_SHIFT;
+}
+
+static inline unsigned int hfi_cachelines_to_pktlen(unsigned int cachelines)
+{
+ return cachelines & 0xf; /* No overflow checking */
+}
+
+static inline unsigned int hfi_pktlen_to_cachelines(unsigned int pktlen)
+{
+ return pktlen ? pktlen : 16; /* 0 pktlen == 16 cache lines */
+}
+
+struct hfi_gups_rdma_pkt {
+ struct gups_rdma_element element[4];
+} __packed;
+
+struct hfi_collective_pkt {
+ struct hfi_hdr hfi_hdr;
+ struct hfi_cau_extended_hdr cau_ext;
+ char payload[64];
+ char pad[16];
+} __packed;
+
+/*
+ * Opcodes for RDMA Extended Headers and GUPS-RDMA Elements
+ */
+#define HFI_OPCODE_ADD 0x0
+#define HFI_OPCODE_AND 0x1
+#define HFI_OPCODE_OR 0x2
+#define HFI_OPCODE_XOR 0x3
+#define HFI_OPCODE_RESERVED 0x4
+#define HFI_OPCODE_CMP_SWAP_NOT_EQUAL 0x5
+#define HFI_OPCODE_CMP_SWAP_EQUAL 0x6
+#define HFI_OPCODE_SWAP 0x7
+/* Fetch can be OR'd with any of the above Opcodes (SmallRDMA only) */
+#define HFI_OPCODE_FETCH 0x8
+
+enum hfi_cau_type {
+ HFI_CAU_TYPE_FLOAT = 0x01,
+ HFI_CAU_TYPE_64BIT = 0x02,
+ HFI_CAU_TYPE_UNSIGNED = 0x04
+};
+
+enum hfi_cau_function {
+ HFI_CAU_FUNCTION_NOP = 0x00,
+ HFI_CAU_FUNCTION_SUM = 0x01,
+ HFI_CAU_FUNCTION_MIN = 0x02,
+ HFI_CAU_FUNCTION_MAX = 0x03,
+ HFI_CAU_FUNCTION_AND = 0x11,
+ HFI_CAU_FUNCTION_XOR = 0x16,
+ HFI_CAU_FUNCTION_OR = 0x17
+};
+
+enum hfi_pkt_status {
+ HFI_PKT_STATUS_GOOD = 0x0,
+ HFI_PKT_STATUS_DESCRIPTOR_FAILURE = 0x1,
+ HFI_PKT_STATUS_PACKET_KILLED = 0x2,
+ HFI_PKT_STATUS_UNEXPECTED_LAST_FLIT = 0x4,
+ HFI_PKT_STATUS_POWERBUS_MASTER = 0x8,
+ HFI_PKT_STATUS_TRANSLATION_FAULT = 0x10
+
+};
+
+enum hfi_rdma_pkt_status {
+ HFI_RDMA_PKT_STATUS_GOOD = 0x0,
+ HFI_RDMA_PKT_STATUS_MIGRATION_CONFLICT = 0x1,
+ HFI_RDMA_PKT_STATUS_PACKET_KILLED = 0x4,
+ HFI_RDMA_PKT_STATUS_POWERBUS_MASTER = 0x8,
+ HFI_RDMA_PKT_STATUS_TRANSLATION_FAULT = 0x10
+
+};
+
+enum hfi_packet_type {
+ HFI_SEND_RECEIVE = 0x00, /* send FIFO -> receive
+ FIFO */
+
+ HFI_IP_WITH_PAYLOAD = 0x08, /* send FIFO -> receive
+ FIFO for IP */
+ HFI_IP_MULTICAST_WITH_PAYLOAD = 0x09, /* ISR use only */
+ HFI_IP_WITH_DESCRIPTORS = 0x0C, /* IP send/recv with
+ indirection */
+ HFI_IP_MULTICAST_WITH_DESCRIPTORS = 0x0D, /* IP send/recv with
+ indirection */
+
+ HFI_FULL_RDMA_WRITE = 0x10,
+ HFI_FULL_RDMA_READ = 0x11,
+ HFI_FULL_RDMA_COMPLETION = 0x12, /* Completion
+ notification */
+ HFI_FULL_RDMA_PREFENCE = 0x13, /* Guarantee RDMA FIFO
+ processing is
+ complete */
+ HFI_FULL_RDMA_FENCE = 0x14, /* Guarantee RDMA FIFO
+ processing is
+ complete */
+ HFI_FULL_RMDA_WRITE_ALIAS = 0x15, /* HW use only */
+
+ HFI_HALF_RDMA_WRITE = 0x18, /* send FIFO to target
+ EA */
+ HFI_HALF_RDMA_READ = 0x19, /* target EA to receive
+ FIFO */
+ HFI_HALF_RDMA_COMPLETION = 0x1A, /* Completion
+ notification */
+ HFI_HALF_RDMA_READ_ALIAS = 0x1D, /* HW use only */
+
+ HFI_SMALL_RDMA_WRITE = 0x20, /* Remote atomic
+ operations */
+ HFI_SMALL_RDMA_COMPLETION = 0x22, /* Completion
+ notification */
+ HFI_SMALL_RDMA_COMPLETION_WITH_FETCH = 0x23, /* Completion
+ notification */
+
+ HFI_GUPS_RDMA_1ELEMENT = 0x28, /* GUPS-RDMA, 1
+ element */
+ HFI_GUPS_RDMA_2ELEMENT = 0x29, /* GUPS-RDMA,
+ 2 element */
+ HFI_GUPS_RDMA_3ELEMENT = 0x2A, /* GUPS-RDMA, 3
+ element */
+ HFI_GUPS_RDMA_4ELEMENT = 0x2B, /* GUPS-RDMA, 4
+ element */
+
+ HFI_CAU_REDUCE = 0x30, /* Collective Reduce */
+ HFI_CAU_MULTICAST = 0x31, /* Collective
+ Multicast */
+ HFI_CAU_ACK = 0x32, /* Collective Ack */
+ HFI_CAU_RETRANS_REQ = 0x33, /* Collective
+ Retransmit Req */
+ HFI_LAST_HEADER
+};
+
+#endif /* _HFI_PKT_FORMATS_H */
diff --git a/include/linux/hfi/hfidd_regs.h b/include/linux/hfi/hfidd_regs.h
new file mode 100644
index 0000000..864e0e6
--- /dev/null
+++ b/include/linux/hfi/hfidd_regs.h
@@ -0,0 +1,212 @@
+/*
+ * hfidd_regs.h
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef HFIDD_REGS_H
+#define HFIDD_REGS_H
+
+/* MMIO Registers */
+/* These are the registers with User Privilege Level */
+
+/* Window Control */
+#define HFI_JOB_ID_SEND 0x0000 /* 32: Send Side Job ID */
+#define HFI_JOB_ID_RECV 0x0008 /* 32: Send Side Job ID */
+#define HFI_WINDOW_STATE 0x0010 /* 1: 0=closed, 1=active */
+#define HFI_SEND_BUSY 0x0020 /* Send Window Busy */
+#define HFI_RECV_BUSY 0x0028 /* Rcv Window Busy */
+
+/* Addr Translation */
+#define HFI_LPAR_ID 0x0040 /* 10: Partition ID */
+#define HFI_PROTECTION_DOMAIN 0x0048 /* 32: used for addr xlat */
+#define HFI_XLAT_BYPASS 0x0050 /* 1: */
+
+/* Imm Send */
+#define HFI_IMM_SEND_BUF_ATTRBS 0x0080 /* 40: Immed Send Buffer Attributes */
+#define HFI_IMM_BUF_INUSE 0x0090 /* Immed Send Buffers In Use */
+#define HFI_IMM_FINI_COUNT 0x00A0 /* Immed Send Buffer Finished Count */
+#define HFI_IMM_FINI_FREQUENCY 0x00A8 /* Immed Send Finished Frequency */
+
+/* Send Fifo */
+#define HFI_SFIFO_DB_REG 0x0110 /* 16: Send Fifo Doorbell */
+#define HFI_SFIFO_BASE_ADDR 0x0120 /* 64: Send Fifo Effective Addr */
+#define HFI_SFIFO_LKEY 0x0128 /* 32: Send Fifo Local Key */
+#define HFI_SFIFO_PULL_OFF 0x0140 /* 64: Send Fifo Pull Offset */
+#define HFI_SFIFO_SIZE 0x0148 /* 4: size from 4K to 8M */
+#define HFI_SFIFO_PEND_COUNT 0x0150 /* 16: Send Fifo Pending Count */
+#define HFI_SFIFO_FINI_POLARITY 0x0158 /* 1: Send Fifo Finish Polarity Bit */
+#define HFI_SFIFO_FINI_ADDR 0x0180 /* 64: Send Fifo Finish Effective
+ Addr */
+#define HFI_IMM_FINI_ADDR 0x0188 /* Immed Send Finished Address */
+#define HFI_SFIFO_INTR_CNTL 0x01C8 /* xx: Send Fifo Interrupt Control */
+
+/* Full-RDMA Send Fifo */
+#define HFI_FRDMA_DB_REG 0x0210 /* Full-RDMA Send Fifo Doorbell */
+#define HFI_FRDMA_BASE_ADDR 0x0220 /* Full-RDMA Send Fifo Effective
+ Address */
+#define HFI_FRDMA_LKEY 0x0228 /* Full-RDMA Send Fifo Local Key */
+#define HFI_FRDMA_PULL_REG 0x0240 /* Full-RDMA Send Fifo Pull Offset */
+#define HFI_FRDMA_SIZE 0x0248 /* Full-RDMA Send Size */
+#define HFI_FRDMA_PEND_REG 0x0250 /* Full-RDMA Send Fifo Pending Count */
+#define HFI_FRDMA_FINI_POLARITY 0x0248 /* Full-RDMA Send Fifo Finished
+ Polarity */
+#define HFI_FRDMA_BREAKUP_REG 0x0260 /* Full-RDMA Send Fifo Breakup Count */
+#define HFI_FRDMA_FINI_ADDR 0x0280 /* Full-RDMA Send Fifo Finished
+ Address */
+#define HFI_FRDMA_INTR_REG 0x02C8 /* Full-RDMA Send Fifo Interrupt
+ Control */
+#define HFI_FRDMA_FENCE_CNT 0x0578 /* Full-RDMA Send Fifo Fence Count */
+
+/* Send Interrupts */
+#define HFI_SINTR_CONTROL_REG 0x02E0 /* Send Force Interrupt Control */
+#define HFI_SINTR_STATUS_REG 0x02E8 /* Send Intr Status */
+
+/* Receive Fifo */
+#define HFI_RFIFO_INC_FSLOT_REG 0x0310 /* Receive Fifo Inc Free Slot Count */
+#define HFI_RFIFO_BASE_ADDR 0x0320 /* Receive Fifo Effective Address */
+#define HFI_RFIFO_LKEY 0x0328 /* Receive Fifo Local Key */
+#define HFI_RFIFO_PUSH_REG 0x0340 /* Receive Fifo Push Offset */
+#define HFI_RFIFO_SIZE 0x0348 /* 4: range from 4K to 8M */
+#define HFI_RFIFO_FSLOT_CNT_REG 0x0350 /* Receive Fifo Free Slot Count */
+#define HFI_RFIFO_FINI_POLARITY 0x0358 /* Receive Fifo Finished Polarity */
+#define HFI_RFIFO_INJ_TH_REG 0x0360 /* Receive Fifo Cache Injection
+ Threshold */
+#define HFI_RFIFO_OUT_TH_REG 0x0368 /* Receive Fifo Out-of-Order
+ Threshold */
+#define HFI_RFIFO_OUT_EVENT_REG 0x03C0 /* Receive Fifo Out-of-Order Event
+ Control */
+#define HFI_RFIFO_INTR_REG 0x03C8 /* Receive Fifo Intr Control */
+
+/* Receive Interrupts */
+#define HFI_RINTR_CONTROL_REG 0x03E0 /* Receive Force Intr Control */
+#define HFI_RINTR_STATUS_REG 0x03E8 /* Receivce Intr Status */
+
+/* IP 2K Free Space Descriptor Fifo */
+#define HFI_IP2K_INC_AVAIL_REG 0x0410 /* IP 2k FSD Fifo Inc Avail Slot
+ Count */
+#define HFI_IP2K_BASE_ADDR 0x0420 /* IP 2k FSD Fifo Effective Address */
+#define HFI_IP2K_LKEY 0x0428 /* IP 2k FSD Fifo Local Key */
+#define HFI_IP2K_PULL_REG 0x0440 /* IP 2k FSD Fifo Pull Offset */
+#define HFI_IP2K_SIZE 0x0448 /* IP 2k FSD Fifo Size */
+#define HFI_IP2K_ASLOT_CNT_REG 0x0450 /* IP 2k FSD Fifo Avail Slot Count */
+
+/* RDMA Pending Fifo */
+#define HFI_RDMAP_BASE_ADDR 0x0520 /* RDMA Pending Fifo Efective Address */
+#define HFI_RDMAP_LKEY 0x0528 /* RDMA Pending Fifo Local Key */
+#define HFI_RDMAP_PULL_REG 0x0540 /* RDMA Pending Fifo Pull Offset */
+#define HFI_RDMAP_SIZE 0x0548 /* RDMA Pending Fifo Size */
+#define HFI_RDMAP_READ_TH_REG 0x0568 /* RDMA Pending Fifo Read Request
+ Threshold */
+#define HFI_RDMAP_PUSH_REG 0x0570 /* RDMA Pending Fifo Push Offset */
+#define HFI_RDMAP_PEND_REG 0x0550 /* RDMA Pending Fifo Pending Count */
+
+/* Send Special Fifo */
+#define HFI_SSFIFO_BASE_ADDR 0x0620 /* Send Special Fifo Effective
+ Address */
+#define HFI_SSFIFO_LKEY 0x0628 /* Send Special Fifo Local Key */
+#define HFI_SSFIFO_PULL_REG 0x0640 /* Send Special Fifo Pull Offset */
+#define HFI_SSFIFO_SIZE 0x0648 /* Send Special Fifo Size */
+#define HFI_SSFIFO_PUSH_REG 0x0670 /* Send Special Fifo Push Offset */
+#define HFI_SSFIFO_PENG_REG 0x0650 /* Send Special Fifo Pending Count */
+
+/* IP Context */
+#define HFI_IP_MCAST_ENABLE_REG 0x0820 /* IP Send - Multi-cast Enable */
+#define HFI_IP_DISABLE_ISR_REG 0x0828 /* IP Send - Disable Src_ISR_ID
+ Stamp */
+#define HFI_IP_PORT_VALID_REG 0x0830 /* IP Logical Port ID Valid */
+#define HFI_IP_PORT_REG 0x0838 /* IP Logical Port ID */
+#define HFI_IP_RECV_SIZE 0x0860 /* IP Recv with Payload Max Size */
+#define HFI_IP_RCV_IMM_REG 0x0868 /* IP RCV-Immediate Max Size */
+
+/* RDMA Context */
+#define HFI_RDMA_RCXT_BASE_ADDR 0x0920 /* RDMA Rcv RCxt Effective Address */
+#define HFI_RDMA_RCXT_LKEY 0x0928 /* RDMA RCxt Local Key */
+#define HFI_RDMA_RCXT_PAY_LKEY 0x0058 /* RDMA Payload Local Key
+ (no-sequential) */
+#define HFI_RDMA_RCXT_EPOCH 0x0980 /* RCxt Update Epoch */
+#define HFI_RDMA_RCXT_CACHE 0x0990 /* RCxt Cache Entry Flush Request */
+
+/* Counters */
+#define HFI_PACKETS_SENT_REG 0x0C00 /* Packets Sent */
+#define HFI_PSENT_DROP_REG 0x0C08 /* Packets Dropped from Sending */
+#define HFI_PIND_SENT_CNT_REG 0x0C10 /* Packet-Indicated Send Count */
+#define HFI_IMM_SEND_CNT_REG 0x0C18 /* Immed Send Packet Count */
+#define HFI_PACKETS_RCV_REG 0x0C40 /* Packets Received */
+#define HFI_PRCV_DROP_REG 0x0C48 /* Packets Dropped from Receiving */
+#define HFI_PIND_RCV_CNT_REG 0x0C50 /* Packet-Indicated Receive Count */
+#define HFI_SBIT_EEC_CNT_REG 0x0C60 /* Single-Bit ECC Count */
+#define HFI_SBIT_EEC_TH_REG 0x0C68 /* Single-Bit ECC Threshold for Error */
+#define HFI_ADDR_XLAT_CNT_REG 0x0C80 /* Addr Xlat Wait Count */
+
+/* Misc Non-Window Registers */
+#define HFI_NUM_WINDOWS_REG 0x0000 /* Number of Windows */
+#define HFI_AGGR_PSENT_CNT_REG 0x0100 /* Aggregate Packet Sent Count */
+#define HFI_AGGR_PSENT_DROP_REG 0x0108 /* Aggregate Packet Dropped from
+ Sending Count */
+#define HFI_AGGR_PRCV_CNT_REG 0x0110 /* Aggregate Packet Receive Count */
+#define HFI_AGGR_PRCV_DROP_REG 0x0118 /* Aggregate Packet Dropped from
+ Receive Count */
+#define HFI_AGGR_ISEND_CNT_REG 0x0120 /* Aggregate Immediate Send Packet
+ Sent Count */
+#define HFI_AGGR_SR_CNT_REG 0x0128 /* Aggregate Send/Rcv Packet Send
+ Count */
+#define HFI_AGGR_FRDMA_CNT_REG 0x0130 /* Aggregate Full-RDMA Packet Sent
+ Count */
+#define HFI_AGGR_HRDMA_CNT_REG 0x0138 /* Aggregate Half-RDMA Packet Sent
+ Count */
+#define HFI_AGGR_SRDMA_CNT_REG 0x0140 /* Aggregate Small-RDMA Packet Sent
+ Count */
+#define HFI_AGGR_IP_CNT_REG 0x0148 /* Aggregate IP Packet Sent Count */
+#define HFI_AGGR_CAU_CNT_REG 0x0150 /* Aggregate CAU Packet Sent Count */
+#define HFI_AGGR_GUPS_CNT_REG 0x0158 /* Aggregate GUPS Packet Sent Count */
+#define HFI_AGGR_NOTIFS_CNT_REG 0x0170 /* Aggregate Notifications Packet Sent
+ Count*/
+
+#define HFI_RCXT_FLUSH_REG 0x0600 /* RCxt Cache Window Flush Request */
+#define HFI_PG_MIGR1_REG 0x0708 /* Page Migration Register 1 */
+#define HFI_PG_MIGR2_REG 0x0710 /* Page Migration Register 2 */
+#define HFI_PG_MIGR3_REG 0x0718 /* Page Migration Register 3 */
+#define HFI_PG_MIGR4_REG 0x0720 /* Page Migration Register 4 */
+#define HFI_PG_MIGR5_REG 0x0728 /* Page Migration Register 5 */
+#define HFI_PG_MIGR6_REG 0x0730 /* Page Migration Register 6 */
+#define HFI_PG_MIGR7_REG 0x0738 /* Page Migration Register 7 */
+#define HFI_PG_MIGR1_RESV_REG 0x0808 /* Page Migration Reservation 1 */
+#define HFI_PG_MIGR2_RESV_REG 0x0810 /* Page Migration Reservation 2 */
+#define HFI_PG_MIGR3_RESV_REG 0x0818 /* Page Migration Reservation 3 */
+#define HFI_PG_MIGR4_RESV_REG 0x0820 /* Page Migration Reservation 4 */
+#define HFI_PG_MIGR5_RESV_REG 0x0828 /* Page Migration Reservation 5 */
+#define HFI_PG_MIGR6_RESV_REG 0x0830 /* Page Migration Reservation 6 */
+#define HFI_PG_MIGR7_RESV_REG 0x0838 /* Page Migration Reservation 7 */
+#define HFI_ADDR_XLAT_WCNT_REG 0x0A20 /* Addr Xlat Wait Count */
+
+#define MASK_56_BITS 0x00ffffffffffffff
+#define MASK_40_BITS 0x000000ffffffffff
+
+#endif /* HFIDD_REGS_H */
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 22/27] HFI: Add event notifications
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Interrupts and some error notifications get passed to window users through
events. User-space applications can register for a signal to be delivered
or can spawn a thread to call into the HFI DD and wait.
Kernel windows can register callbacks.
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/Makefile | 1 +
drivers/net/hfi/core/hfidd_adpt.c | 5 +
drivers/net/hfi/core/hfidd_events.c | 1098 +++++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_init.c | 35 ++
drivers/net/hfi/core/hfidd_intr.c | 40 ++-
drivers/net/hfi/core/hfidd_proto.h | 16 +-
drivers/net/hfi/core/hfidd_window.c | 24 +
include/linux/hfi/hfidd_client.h | 64 ++
include/linux/hfi/hfidd_internal.h | 69 +++
include/linux/hfi/hfidd_requests.h | 3 +
10 files changed, 1353 insertions(+), 2 deletions(-)
create mode 100644 drivers/net/hfi/core/hfidd_events.c
diff --git a/drivers/net/hfi/core/Makefile b/drivers/net/hfi/core/Makefile
index d2ed86f..da71824 100644
--- a/drivers/net/hfi/core/Makefile
+++ b/drivers/net/hfi/core/Makefile
@@ -3,6 +3,7 @@
#
hfi_core-objs:= hfidd_adpt.o \
hfidd_window.o \
+ hfidd_events.o \
hfidd_init.o \
hfidd_xlat.o \
hfidd_map.o \
diff --git a/drivers/net/hfi/core/hfidd_adpt.c b/drivers/net/hfi/core/hfidd_adpt.c
index 8e3f5af..1e92911 100644
--- a/drivers/net/hfi/core/hfidd_adpt.c
+++ b/drivers/net/hfi/core/hfidd_adpt.c
@@ -116,6 +116,7 @@ int hfidd_alloc_windows(struct hfidd_acs *p_acs)
/* Initialize window fields */
spin_lock_init(&(p_acs->win[i]->win_lock));
+ spin_lock_init(&(p_acs->win[i]->event_lock));
p_acs->win[i]->ai = p_acs->index;
p_acs->win[i]->index = p_acs->dds.window_start + i;
@@ -136,6 +137,8 @@ void hfidd_free_windows(struct hfidd_acs *p_acs)
int i;
for (i = 0; i < p_acs->dds.window_num; i++) {
+ if (p_acs->win[i])
+ hfidd_events_clean(p_acs, p_acs->win[i]);
kfree(p_acs->win[i]);
p_acs->win[i] = NULL;
}
@@ -208,6 +211,8 @@ int hfidd_query_interface(struct hfidd_acs *p_acs, unsigned int subtype,
if (p_acs->state != HFI_AVAIL) {
p_acs->isr = query_p->local_node_id;
p_acs->state = HFI_AVAIL;
+ /* Notify user that adapter is ready */
+ hfidd_notify_hfi_ready(p_acs);
}
} else {
p_acs->state = HFI_UNAVAIL;
diff --git a/drivers/net/hfi/core/hfidd_events.c b/drivers/net/hfi/core/hfidd_events.c
new file mode 100644
index 0000000..ff92306
--- /dev/null
+++ b/drivers/net/hfi/core/hfidd_events.c
@@ -0,0 +1,1098 @@
+/* hfidd_events.c
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/hfi/hfidd_internal.h>
+#include "hfidd_proto.h"
+
+static void rem_events(struct hfidd_acs *p_acs, struct hfidd_window *win,
+ struct hfidd_tid_info *tid_info, unsigned int events,
+ struct hfidd_win_event **event_list);
+static int hfidd_hfi_ready_registration(struct hfidd_acs *p_acs,
+ struct hfi_reg_events *reg);
+static void hfidd_hfi_ready_unregistration(struct hfidd_acs *p_acs,
+ struct hfi_reg_events *reg);
+
+static unsigned int event_mask[HFIDD_NUM_EVENT_TYPES] = {
+ HFIDD_SEND_EVENT,
+ HFIDD_RECV_EVENT,
+ HFIDD_WIN_ERROR_EVENT,
+ HFIDD_HFI_ERROR_EVENT,
+ HFIDD_TERMINATE_EVENT,
+ HFIDD_RELEASE_WINDOW_EVENT,
+ HFIDD_CAU_ERROR_EVENT,
+ HFIDD_ICS_ERROR_EVENT,
+ HFIDD_HFI_READY_REG_EVENT,
+ HFIDD_ROUTE_CHANGE_EVENT,
+ HFIDD_IP_TRC_LVL_EVENT,
+ HFIDD_POOL_SIZE_EVENT};
+
+
+static void hfidd_tid_info_init(struct hfidd_tid_info *tid_info)
+{
+ memset(tid_info, 0, sizeof(*tid_info));
+ sema_init(&(tid_info->tid_sem), 1);
+ INIT_LIST_HEAD(&(tid_info->event_list));
+ init_waitqueue_head(&(tid_info->event_wait));
+ tid_info->th = current;
+}
+
+static void hfidd_tid_info_end(struct hfidd_tid_info *tid_info,
+ struct hfidd_q_event **q_event_list)
+{
+ struct list_head *pos;
+ struct list_head *q;
+ struct hfidd_q_event *ev;
+
+ /* Clean up any remaining events. */
+ list_for_each_safe(pos, q, &(tid_info->event_list)) {
+ ev = list_entry(pos, struct hfidd_q_event, list);
+ list_del(pos);
+ ev->next = *q_event_list;
+ *q_event_list = ev;
+ }
+}
+
+static inline void hfidd_update_eb(struct hfidd_tid_info *tid_info,
+ struct hfi_reg_events *reg_events)
+{
+ tid_info->eb_xd = current->group_leader;
+ tid_info->eb = (struct hfi_event_buffer *)reg_events->info.eb.use.allu;
+}
+
+/* Post an event. The win->event_lock must be held before calling. */
+static int hfidd_post_event(struct hfidd_acs *p_acs,
+ struct hfidd_tid_info *tid_info, enum hfi_event_type type,
+ unsigned int event, struct hfidd_q_event **q_event_list)
+{
+ int rc = 0;
+ struct hfidd_q_event *ev;
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_post_event: event=0x%x tid=0x%llx\n",
+ event, tid_info->tid);
+
+ if (tid_info->type == WAIT_FOR_EVENTS) {
+ /* Allocate and fill in the structure for the event. */
+ if (*q_event_list == NULL) {
+ rc = -EFAULT;
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_post_event: internal error - "
+ "%d\n", rc);
+ } else {
+ ev = *q_event_list;
+ *q_event_list = (*q_event_list)->next;
+ ev->event = event;
+
+ /*
+ * Add the event to the event list and wake up any
+ * waiting thread.
+ */
+ list_add(&(ev->list), &(tid_info->event_list));
+ wake_up_interruptible(&(tid_info->event_wait));
+ }
+ }
+
+ return rc;
+}
+
+/*
+ * Wakeup waiting task if necessary. The win->event_lock must be held before
+ * calling.
+ */
+static int hfidd_events_wakeup(struct hfidd_acs *p_acs,
+ struct hfidd_tid_info *tid_info,
+ struct hfidd_q_event **q_event_list)
+{
+ int rc = 0;
+ struct list_head *pos;
+ struct list_head *q;
+ struct hfidd_q_event *ev;
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_events_wakeup: tid=0x%llx\n", tid_info->tid);
+ /*
+ * A well behaved thread will not be waiting for any events when
+ * wakeup is called. This code is to handle misbehaving threads.
+ */
+
+ /*
+ * Add an event that will cause any misbehaving waiting thread to
+ * wake up. Once it wakes up, it will see that we are cleaning up
+ * (because win->open_close_count has changed) and will end.
+ */
+ if (*q_event_list == NULL) {
+ rc = -EFAULT;
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_events_wakeup: internal error - "
+ "%d\n", rc);
+ goto hfidd_events_wakeup_error1;
+ }
+
+ ev = *q_event_list;
+ *q_event_list = (*q_event_list)->next;
+ ev->event = HFIDD_TERMINATE;
+ list_add(&(ev->list), &(tid_info->event_list));
+ wake_up_interruptible(&(tid_info->event_wait));
+
+ /* By getting this lock, we make sure that we don't delete tid_info */
+ /* until the thread is done using it. */
+ down(&(tid_info->tid_sem));
+
+ list_for_each_safe(pos, q, &(tid_info->event_list)) {
+ ev = list_entry(pos, struct hfidd_q_event, list);
+ list_del(pos);
+ ev->next = *q_event_list;
+ *q_event_list = ev;
+ }
+
+ up(&(tid_info->tid_sem));
+
+
+hfidd_events_wakeup_error1:
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_events_wakeup: rc=%d\n", rc);
+ return rc;
+}
+
+/*
+ * Preallocate a group of q events. We must preallocate because we are
+ * not allowed to use kzalloc once we have the event_lock.
+ */
+static struct hfidd_q_event *hfidd_prealloc_q_events(struct hfidd_acs *p_acs,
+ struct hfidd_window *win, int num_events)
+{
+ int i;
+ struct hfidd_q_event *q_event_list = NULL;
+ struct hfidd_q_event *q_event;
+
+ for (i = 0; i < num_events; i++) {
+ q_event = kzalloc(sizeof(*q_event), GFP_KERNEL);
+ if (q_event == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_prealloc_q_events: kzalloc failed, "
+ "num_events = %d\n", num_events);
+
+ while (q_event_list != NULL) {
+ q_event = q_event_list->next;
+ kfree(q_event_list);
+ q_event_list = q_event;
+ }
+ return NULL;
+ }
+ q_event->next = q_event_list;
+ q_event_list = q_event;
+ }
+
+ return q_event_list;
+}
+
+/* Return any queue events that haven't been used. */
+static void hfidd_return_q_events(struct hfidd_acs *p_acs,
+ struct hfidd_q_event **q_event_list)
+{
+ struct hfidd_q_event *q_event;
+
+ while (*q_event_list != NULL) {
+ q_event = (*q_event_list)->next;
+ kfree(*q_event_list);
+ *q_event_list = q_event;
+ }
+}
+/*
+ * Preallocate a tid_info structure. We must preallocate because we are
+ * not allowed to use kzalloc once we have the event_lock.
+ */
+static struct hfidd_tid_info *prealloc_tid_list(struct hfidd_acs *p_acs)
+{
+ struct hfidd_tid_info *tid_list;
+
+ tid_list = kzalloc(sizeof(*tid_list), GFP_KERNEL);
+ if (tid_list == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "prealloc_tid_list: kzalloc tid info failed\n");
+ } else {
+ hfidd_tid_info_init(tid_list);
+ tid_list->next = NULL;
+ }
+ return tid_list;
+}
+
+/* Return a list of hfidd_tid_info structures. */
+static void return_tid_list(struct hfidd_acs *p_acs,
+ struct hfidd_tid_info **tid_list,
+ struct hfidd_q_event **q_event_list)
+{
+ struct hfidd_tid_info *tid_info;
+
+ while (*tid_list != NULL) {
+ tid_info = *tid_list;
+ *tid_list = tid_info->next;
+ hfidd_tid_info_end(tid_info, q_event_list);
+ kfree(tid_info);
+ }
+}
+
+/*
+ * Preallocate a list of hfidd_win_event structures. We must preallocate
+ * because we are not allowed to use kzalloc once we have the event_lock.
+ */
+static struct hfidd_win_event *prealloc_event_list(struct hfidd_acs *p_acs,
+ unsigned int events)
+{
+ int i;
+ unsigned int test_bit = HFIDD_LOWEST_EVENT;
+ struct hfidd_win_event *win_event;
+ struct hfidd_win_event *event_list = NULL;
+
+ for (i = 0; i < HFIDD_NUM_EVENT_TYPES; i++) {
+ if (events & test_bit) {
+ win_event = kzalloc(sizeof(*win_event), GFP_KERNEL);
+ if (win_event == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "prealloc_event_list: kzalloc failed\n");
+
+ while (event_list != NULL) {
+ win_event = event_list;
+ event_list = event_list->next;
+ kfree(win_event);
+ }
+ return NULL;
+ }
+ win_event->next = event_list;
+ event_list = win_event;
+ }
+ test_bit <<= 1;
+ }
+ return event_list;
+}
+
+/* Return a list of hfidd_win_event structures. */
+static void return_event_list(struct hfidd_acs *p_acs,
+ struct hfidd_win_event **event_list)
+{
+ struct hfidd_win_event *win_event;
+
+ while (*event_list != NULL) {
+ win_event = *event_list;
+ *event_list = (*event_list)->next;
+ kfree(win_event);
+ }
+}
+
+/*
+ * Add a group of events to the event handling structures. The caller must
+ * hold win->event_lock.
+ */
+static int add_events(struct hfidd_acs *p_acs, struct hfidd_window *win,
+ struct hfidd_tid_info *tid_info, unsigned int events,
+ struct hfidd_win_event **event_list)
+{
+ int rc = 0;
+ int i;
+ unsigned int test_bit = HFIDD_LOWEST_EVENT;
+ struct hfidd_win_event *win_event;
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "add_events: enter win=0x%x events=0x%x\n",
+ win->index, events);
+
+ /* Add individual pointers from the window to the tid_info. */
+ for (i = 0; i < HFIDD_NUM_EVENT_TYPES; i++) {
+ if (events & test_bit) {
+ /* Add a pointer from the window to the events. */
+ if (*event_list == NULL) {
+ rc = -EFAULT;
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "add_events: internal error - "
+ "%d\n", rc);
+
+ goto add_events_err1;
+ }
+ win_event = *event_list;
+ *event_list = (*event_list)->next;
+ win_event->tid_info = tid_info;
+ win_event->next = win->events[i];
+ win->events[i] = win_event;
+ atomic_inc(&(win->num_events[i]));
+ }
+ test_bit <<= 1;
+ }
+ return rc;
+
+add_events_err1:
+ rem_events(p_acs, win, tid_info, events, event_list);
+ return rc;
+}
+
+/*
+ * Remove a group of events from the event handling structures. The caller
+ * must hold win->event_lock.
+ */
+static void rem_events(struct hfidd_acs *p_acs, struct hfidd_window *win,
+ struct hfidd_tid_info *tid_info, unsigned int events,
+ struct hfidd_win_event **event_list)
+{
+ int i;
+ unsigned int test_bit = HFIDD_LOWEST_EVENT;
+ struct hfidd_win_event *prev_win_event;
+ struct hfidd_win_event *win_event;
+ unsigned int temp_events = events;
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "rem_events: enter win=0x%x events=0x%x\n",
+ win->index, events);
+
+ for (i = 0; i < HFIDD_NUM_EVENT_TYPES; i++) {
+ if (temp_events & test_bit) {
+ /* Remove pointer from the window or p_acs to events. */
+ prev_win_event = NULL;
+ for (win_event = win->events[i]; win_event != NULL;
+ win_event = win_event->next) {
+ /* Search for this tid in list. */
+ if (win_event->tid_info == tid_info)
+ break;
+ else
+ prev_win_event = win_event;
+ }
+ if (win_event != NULL) {
+ /* Found tid. Remove it. */
+ if (prev_win_event == NULL)
+ win->events[i] = win_event->next;
+ else
+ prev_win_event->next = win_event->next;
+ win_event->next = *event_list;
+ *event_list = win_event;
+ atomic_dec(&(win->num_events[i]));
+ }
+ }
+ test_bit <<= 1;
+ }
+}
+
+/*
+ * Find a tid_info structure for a given tid and window. The caller must
+ * hold win->event_lock.
+ */
+static struct hfidd_tid_info *get_tid_info(struct hfidd_acs *p_acs,
+ struct hfidd_window *win, unsigned long long tid,
+ enum hfi_event_hndlr_type type,
+ struct hfidd_tid_info **prev_tid_info,
+ struct hfidd_tid_info **tid_list)
+{
+ struct hfidd_tid_info *tid_info;
+
+ *prev_tid_info = NULL;
+
+ /* See if it exists already. */
+ for (tid_info = win->tid_list; tid_info != NULL;
+ tid_info = tid_info->next) {
+ if (tid_info->tid == tid)
+ break;
+ *prev_tid_info = tid_info;
+ }
+
+ /* Allocate new structure if necessary. */
+ if (tid_info == NULL) {
+ *prev_tid_info = NULL;
+ if (*tid_list == NULL) {
+ tid_info = NULL;
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "get_tid_info: internal error\n");
+ } else {
+ tid_info = *tid_list; /* Set to NULL so caller knows the
+ preallocated tid_info
+ structure was used. */
+ *tid_list = (*tid_list)->next;
+ tid_info->tid = tid;
+ tid_info->type = type;
+ atomic_inc(&win->num_tids);
+ tid_info->next = win->tid_list;
+ win->tid_list = tid_info;
+ }
+ }
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "get_tid_info: exit reg_events=0x%x tid_info=%p\n",
+ tid_info->registered_events,
+ (void *) tid_info);
+
+ return tid_info;
+}
+
+/*
+ * Remove a tid_info structure for a given tid and window. The caller must
+ * hold win->event_lock.
+ */
+static void rem_tid_info(struct hfidd_acs *p_acs, struct hfidd_window *win,
+ struct hfidd_tid_info *prev_tid_info,
+ struct hfidd_tid_info *tid_info,
+ struct hfidd_tid_info **tid_list)
+{
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "rem_tid_info: remove tid_info for tid 0x%llx\n",
+ tid_info->tid);
+
+ if (prev_tid_info == NULL)
+ win->tid_list = tid_info->next;
+ else
+ prev_tid_info->next = tid_info->next;
+ if (atomic_read(&win->num_tids) > 0)
+ atomic_dec(&win->num_tids);
+ tid_info->next = *tid_list;
+ *tid_list = tid_info; /* Set up to free after releasing lock */
+}
+
+
+/* Register events. */
+int hfidd_events_register(struct hfidd_acs *p_acs, struct hfi_reg_events *arg)
+{
+ int rc = 0;
+ int got_lock = 0;
+ struct hfi_reg_events reg_events;
+ unsigned long long tid;
+ struct hfidd_tid_info *prev_tid_info;
+ struct hfidd_tid_info *tid_info = NULL;
+ struct hfidd_tid_info *tid_list = NULL;
+ unsigned int new_events;
+ struct hfidd_window *win = NULL;
+ struct hfidd_win_event *event_list = NULL;
+ unsigned long flags = 0;
+ struct hfidd_q_event *q_event_list = NULL;
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_events_register: enter p_acs=0x%p\n", (void *)p_acs);
+
+ /* Copy in client info from user */
+ rc = copy_from_user(®_events, arg, sizeof(reg_events));
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_events_register: copy_from_user failed, "
+ "rc=0x%x\n", rc);
+ return rc;
+ }
+
+ /* Verify inputs */
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_events_register: enter type=0x%x win=0x%x "
+ "events=0x%x\n", reg_events.type, reg_events.window,
+ reg_events.info.events);
+
+ if ((reg_events.type != WAIT_FOR_EVENTS) &&
+ (reg_events.type != SIGNAL_EVENTS)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_events_register: invalid type - "
+ "0x%x\n", reg_events.type);
+ return -EINVAL;
+ }
+ if ((reg_events.window < min_hfi_windows(p_acs)) ||
+ (reg_events.window >= max_hfi_windows(p_acs))) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_events_register: invalid win - "
+ "0x%x\n", reg_events.window);
+ return -EINVAL;
+ }
+ if ((reg_events.type == WAIT_FOR_EVENTS) &&
+ (reg_events.info.events & ~HFIDD_ALL_EVENTS)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_events_register: invalid events - "
+ "0x%x\n", reg_events.info.events & ~HFIDD_ALL_EVENTS);
+ return -EINVAL;
+ }
+ if ((reg_events.type == SIGNAL_EVENTS) &&
+ (reg_events.info.eb.use.kptr == NULL)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_events_register: invalid signal buffer\n");
+ return -EINVAL;
+ }
+
+ win = hfi_window(p_acs, reg_events.window);
+ /*
+ * Preallocate data structures. We must do this before the
+ * lock or it will cause errors.
+ */
+ tid_list = prealloc_tid_list(p_acs);
+ if (tid_list == NULL)
+ return -ENOMEM;
+ if (reg_events.type == WAIT_FOR_EVENTS)
+ event_list = prealloc_event_list(p_acs, reg_events.info.events);
+ else
+ event_list = prealloc_event_list(p_acs, HFIDD_ALL_EVENTS);
+ if (event_list == NULL) {
+ rc = -ENOMEM;
+ goto events_reg_err1;
+ }
+
+ spin_lock_irqsave(&(win->event_lock), flags);
+ got_lock = 1;
+ if (win->state == WIN_AVAILABLE) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_events_register: inv state wi=0x%x st=0x%x\n",
+ win->index, win->state);
+ rc = -EINVAL;
+ goto events_reg_err1;
+ }
+
+ /* Get the tid_info structure for this tid. */
+ tid = (current->pid);
+
+ tid_info = get_tid_info(p_acs, win, tid, reg_events.type,
+ &prev_tid_info, &tid_list);
+ if (tid_info == NULL)
+ goto events_reg_err1;
+ if (tid_info->type != reg_events.type) {
+ /* The user can't change types after first registration */
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_events_register: inv typ chg old=0x%x new=0x%x\n",
+ tid_info->type, reg_events.type);
+ rc = -EINVAL;
+ goto events_reg_err2;
+ }
+
+ /* Add new event entries. */
+ if (reg_events.type == WAIT_FOR_EVENTS) {
+ new_events = ~tid_info->registered_events &
+ reg_events.info.events;
+ } else {
+ /*
+ * If signal version is registered more than once, this will
+ * end up with no events. Otherwise, all events
+ */
+ new_events = (~tid_info->registered_events) &
+ HFIDD_ALL_EVENTS;
+ hfidd_update_eb(tid_info, ®_events);
+ }
+ rc = add_events(p_acs, win, tid_info, new_events, &event_list);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_events_register: failed to add events, "
+ "rc=%d\n", rc);
+ goto events_reg_err2;
+ }
+ tid_info->registered_events |= new_events;
+
+events_reg_err2:
+ /* Remove tid info if necessary */
+ if (!(tid_info->registered_events))
+ rem_tid_info(p_acs, win, prev_tid_info, tid_info, &tid_list);
+
+events_reg_err1:
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_events_register: rc=%d events=0x%x\n",
+ rc, (tid_info == NULL) ? 0 : tid_info->registered_events);
+
+ if (got_lock)
+ spin_unlock_irqrestore(&(win->event_lock), flags);
+ return_tid_list(p_acs, &tid_list, &q_event_list);
+ hfidd_return_q_events(p_acs, &q_event_list);
+ return_event_list(p_acs, &event_list);
+ return rc;
+}
+
+int hfidd_events_unregister(struct hfidd_acs *p_acs, struct hfi_reg_events *arg)
+{
+ int rc = 0;
+ int got_lock = 0;
+ struct hfi_reg_events unreg_events;
+ unsigned long long tid;
+ struct hfidd_tid_info *prev_tid_info;
+ struct hfidd_tid_info *tid_info = NULL;
+ struct hfidd_tid_info *tid_list = NULL;
+ struct hfidd_window *win = NULL;
+ struct hfidd_win_event *event_list = NULL;
+ unsigned long flags = 0;
+ struct hfidd_q_event *q_event_list = NULL;
+ unsigned int events_to_rem;
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_events_unregister: enter p_acs=0x%p\n", (void *)p_acs);
+
+ /* Copy in client info from user */
+ rc = copy_from_user(&unreg_events, arg, sizeof(unreg_events));
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_events_unregister: COPYIN err rc=0x%x\n", rc);
+ return rc;
+ }
+
+ /* Validate input */
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_events_unregister: enter win=0x%x events=0x%x\n",
+ unreg_events.window, unreg_events.info.events);
+
+ if ((unreg_events.type != WAIT_FOR_EVENTS) &&
+ (unreg_events.type != SIGNAL_EVENTS)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_events_unregister: invalid type - "
+ "0x%x\n", unreg_events.type);
+ return -EINVAL;
+ }
+
+ if ((unreg_events.window < min_hfi_windows(p_acs)) ||
+ (unreg_events.window >= max_hfi_windows(p_acs))) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_events_unregister: invalid win - "
+ "0x%x\n", unreg_events.window);
+ return -EINVAL;
+ }
+
+ if ((unreg_events.type == WAIT_FOR_EVENTS) &&
+ (unreg_events.info.events & ~HFIDD_ALL_EVENTS)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_events_unregister: invalid events - "
+ "0x%x\n", unreg_events.info.events & ~HFIDD_ALL_EVENTS);
+ return -EINVAL;
+ }
+ win = hfi_window(p_acs, unreg_events.window);
+
+ /*
+ * Preallocate data structures. We must do this before the
+ * lock or it will cause errors.
+ */
+ tid_list = prealloc_tid_list(p_acs);
+ if (tid_list == NULL)
+ return -ENOMEM;
+ spin_lock_irqsave(&(win->event_lock), flags);
+ got_lock = 1;
+
+ /* Get the tid_info structure for this tid. */
+ tid = (current->pid);
+
+ tid_info = get_tid_info(p_acs, win, tid, unreg_events.type,
+ &prev_tid_info, &tid_list);
+ if (tid_info == NULL)
+ goto events_unreg_err1;
+ if (tid_info->type != unreg_events.type) {
+ /* The user can't change types after first registration */
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_events_unregister: inv typ chg old=0x%x new=0x%x\n",
+ tid_info->type, unreg_events.type);
+ rc = -EINVAL;
+ goto events_unreg_err2;
+ }
+
+ /* Remove entries. */
+ if (unreg_events.type == WAIT_FOR_EVENTS)
+ events_to_rem = unreg_events.info.events;
+ else
+ events_to_rem = HFIDD_ALL_EVENTS;
+ rem_events(p_acs, win, tid_info, events_to_rem, &event_list);
+ tid_info->registered_events &= ~events_to_rem;
+
+events_unreg_err2:
+ /* Remove tid_info if necessary. */
+ if (!(tid_info->registered_events))
+ rem_tid_info(p_acs, win, prev_tid_info, tid_info, &tid_list);
+
+events_unreg_err1:
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_events_unregister: rc=%d events=0x%x\n",
+ rc, (tid_info == NULL) ? 0 : tid_info->registered_events);
+
+ if (got_lock)
+ spin_unlock_irqrestore(&(win->event_lock), flags);
+ return_tid_list(p_acs, &tid_list, &q_event_list);
+ hfidd_return_q_events(p_acs, &q_event_list);
+ return_event_list(p_acs, &event_list);
+ return rc;
+}
+
+/* Report that an event has occurred. */
+int hfidd_report_event(struct hfidd_acs *p_acs, struct hfidd_window *win,
+ enum hfi_event_type event)
+{
+ int rc = 0;
+ struct hfidd_win_event *win_event_p;
+ struct hfidd_q_event *q_event_list = NULL;
+ int num_events;
+ unsigned long flags;
+ int allocated = 0;
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_report_event: enter event=0x%x p_acs=0x%p\n",
+ event, (void *) p_acs);
+
+ /*
+ * Prealloc queue event entries. We must do this because we use a
+ * lock that keeps us from allocating storage.
+ */
+ while (!allocated) {
+ num_events = atomic_read(&(win->num_events[event]));
+ q_event_list = hfidd_prealloc_q_events(p_acs, win,
+ num_events);
+ if ((q_event_list == NULL) && num_events) {
+ rc = -ENOMEM;
+ return rc;
+ }
+ spin_lock_irqsave(&(win->event_lock), flags);
+ if (num_events == atomic_read(&(win->num_events[event]))) {
+ allocated = 1;
+ } else {
+ /*
+ * The number of events we allocated for does not
+ * match the current number of events. It must
+ * have changed between the allocation and the lock.
+ * We must keep trying until we get a match.
+ */
+ spin_unlock_irqrestore(&(win->event_lock), flags);
+ hfidd_return_q_events(p_acs, &q_event_list);
+ }
+ }
+
+ /* Mark that the event has occurred and awaken each tid. */
+ for (win_event_p = win->events[event]; win_event_p != NULL;
+ win_event_p = win_event_p->next) {
+ hfidd_post_event(p_acs, win_event_p->tid_info,
+ event, event_mask[event], &q_event_list);
+ }
+ spin_unlock_irqrestore(&(win->event_lock), flags);
+ hfidd_return_q_events(p_acs, &q_event_list);
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_report_event: type=0x%x rc=%d\n", event, rc);
+ return rc;
+}
+
+/* Clean up event handling when a window closes. */
+int hfidd_events_clean(struct hfidd_acs *p_acs, struct hfidd_window *win)
+{
+ int rc = 0;
+ int i;
+ struct hfidd_win_event *win_event_p;
+ struct hfidd_win_event *win_event_list = NULL;
+ struct hfidd_win_event *next_win_event_p;
+ struct hfidd_tid_info *tid_info;
+ struct hfidd_tid_info *next_tid_info;
+ struct hfidd_tid_info *tid_list = NULL;
+ int num_events;
+ unsigned long flags;
+ int allocated = 0;
+ struct hfidd_q_event *q_event_list = NULL;
+ int loop_count = 0;
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_events_clean: enter p_acs=0x%p\n", (void *)p_acs);
+
+ /*
+ * Prealloc queue event entries. We must do this because we use a
+ * ock that keeps us from allocating storage.
+ */
+ while (!allocated) {
+ num_events = atomic_read(&win->num_tids);
+ q_event_list = hfidd_prealloc_q_events(p_acs, win,
+ num_events);
+ if ((q_event_list == NULL) && num_events) {
+ rc = -ENOMEM;
+ return rc;
+ }
+ spin_lock_irqsave(&(win->event_lock), flags);
+ if (num_events == atomic_read(&win->num_tids)) {
+ allocated = 1;
+ } else {
+ /*
+ * The number of events we allocated for does not
+ * match the current number of tids. It must
+ * have changed between the allocation and the lock.
+ * We must keep trying until we get a match.
+ */
+ spin_unlock_irqrestore(&(win->event_lock), flags);
+ hfidd_return_q_events(p_acs, &q_event_list);
+ }
+ }
+
+ /* Return all of the win_info structures. */
+ for (i = 0; i < HFIDD_NUM_EVENT_TYPES; i++) {
+ for (win_event_p = win->events[i]; win_event_p != NULL;
+ win_event_p = next_win_event_p) {
+ next_win_event_p = win_event_p->next;
+ win_event_p->next = win_event_list;
+ win_event_list = win_event_p;
+ }
+ win->events[i] = NULL;
+ atomic_set(&win->num_events[i], 0);
+ }
+
+ /* Return tid_info structures. */
+ for (tid_info = win->tid_list; tid_info != NULL;
+ tid_info = next_tid_info) {
+ /* Wake up the waiting task if necessary. */
+ hfidd_events_wakeup(p_acs, tid_info, &q_event_list);
+ next_tid_info = tid_info->next;
+ if (atomic_read(&win->num_tids) > 0)
+ atomic_dec(&win->num_tids);
+ tid_info->next = tid_list;
+ tid_list = tid_info;
+ }
+ win->tid_list = NULL;
+ atomic_set(&win->num_tids, 0);
+ for (i = 0; i < HFIDD_NUM_EVENT_TYPES; i++) {
+ win->funcs[i].function_p.use.kptr = NULL;
+ win->funcs[i].parameter.use.kptr = NULL;
+ }
+
+ /* Wait for all threads to finish. */
+ spin_unlock_irqrestore(&(win->event_lock), flags); /* Must disable or
+ will hang */
+ while ((atomic_read(&win->event_wait_count) > 0) &&
+ (loop_count < HFIDD_EVENT_CLEANUP_LOOP_COUNT)) {
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(HFIDD_EVENT_CLEANUP_DELAY);
+ loop_count++;
+ }
+ atomic_set(&win->event_wait_count, 0);
+
+ return_event_list(p_acs, &win_event_list);
+ return_tid_list(p_acs, &tid_list, &q_event_list);
+ hfidd_return_q_events(p_acs, &q_event_list);
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_events_clean: rc=%d\n", rc);
+ return rc;
+}
+
+int hfidd_callback_register(struct hfidd_acs *p_acs, struct hfi_reg_events *arg)
+{
+ struct hfi_reg_events reg_events;
+ struct hfidd_window *win;
+ int rc;
+
+ /* Copy in client info from user */
+ memcpy(®_events, arg, sizeof(reg_events));
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_callback_register: enter type=0x%x win=0x%x "
+ "events=0x%x\n", reg_events.type, reg_events.window,
+ reg_events.info.func.index);
+
+ /* Verify inputs */
+ if (reg_events.type != FUNCTIONS_FOR_EVENTS) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_callback_register: invalid type = "
+ "0x%x\n", reg_events.type);
+ return -EINVAL;
+ }
+ if (reg_events.info.func.index == HFIDD_HFI_READY_REG) {
+ rc = hfidd_hfi_ready_registration(p_acs, ®_events);
+ return rc;
+ }
+
+ if ((reg_events.window < min_hfi_windows(p_acs)) ||
+ (reg_events.window >= max_hfi_windows(p_acs))) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_callback_register: invalid win = "
+ "0x%x\n", reg_events.window);
+ return -EINVAL;
+ }
+
+ if (reg_events.info.func.index >= HFIDD_NUM_EVENT_TYPES) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_callback_register: invalid events = "
+ "0x%x\n", reg_events.info.func.index);
+ return -EINVAL;
+ }
+
+ win = hfi_window(p_acs, reg_events.window);
+ spin_lock(&(win->win_lock));
+ if (win->state == WIN_AVAILABLE) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_callback_register: inv state "
+ "wi=0x%x st=0x%x\n",
+ win->index, win->state);
+ spin_unlock(&(win->win_lock));
+ return -EINVAL;
+ }
+ spin_unlock(&(win->win_lock));
+
+ /* fill in function pointer and parameter */
+ win->funcs[reg_events.info.func.index].function_p.use.kptr =
+ reg_events.info.func.function_p.use.kptr;
+ win->funcs[reg_events.info.func.index].parameter.use.kptr =
+ reg_events.info.func.parameter.use.kptr;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(hfidd_callback_register);
+
+int hfidd_callback_unregister(struct hfidd_acs *p_acs,
+ struct hfi_reg_events *arg)
+{
+ struct hfi_reg_events reg_events;
+ struct hfidd_window *win;
+
+ /* Copy in client info from user */
+ memcpy(®_events, arg, sizeof(reg_events));
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_callback_unregister: enter type=0x%x win=0x%x "
+ "events=0x%x\n", reg_events.type, reg_events.window,
+ reg_events.info.func.index);
+
+ /* Verify inputs */
+ if (reg_events.type != FUNCTIONS_FOR_EVENTS) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_callback_unregister: invalid type = "
+ "0x%x\n", reg_events.type);
+ return -EINVAL;
+ }
+ if (reg_events.info.func.index == HFIDD_HFI_READY_REG) {
+ hfidd_hfi_ready_unregistration(p_acs, ®_events);
+ return 0;
+ }
+
+ if ((reg_events.window < min_hfi_windows(p_acs)) ||
+ (reg_events.window >= max_hfi_windows(p_acs))) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_callback_unregister: invalid win = "
+ "0x%x\n", reg_events.window);
+ return -EINVAL;
+ }
+
+ if (reg_events.info.func.index >= HFIDD_NUM_EVENT_TYPES) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_callback_unregister: invalid events = "
+ "0x%x\n", reg_events.info.func.index);
+ return -EINVAL;
+ }
+
+ win = hfi_window(p_acs, reg_events.window);
+ spin_lock(&(win->win_lock));
+ if ((win->state != WIN_OPENED) &&
+ (win->state != WIN_ERROR) &&
+ (win->state != WIN_HERROR)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_callback_unregister: inv state "
+ "wi=0x%x st=0x%x\n",
+ win->index, win->state);
+ spin_unlock(&(win->win_lock));
+ return -EINVAL;
+ }
+ spin_unlock(&(win->win_lock));
+
+ win->funcs[reg_events.info.func.index].function_p.use.kptr = NULL;
+ win->funcs[reg_events.info.func.index].parameter.use.kptr = NULL;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(hfidd_callback_unregister);
+
+int hfidd_callback_event(struct hfidd_acs *p_acs, struct hfidd_window *win,
+ enum hfi_event_type event,
+ unsigned int data1,
+ unsigned int *data2_p)
+{
+ if (win->funcs[event].function_p.use.kptr == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_callback_event: NULL function ptr, "
+ "event=0x%x, win_p=0x%llx\n",
+ event, (unsigned long long)win);
+ return -EINVAL;
+ }
+
+ /* calling function */
+ ((hfi_event_func_ptr)win->funcs[event].function_p.use.kptr)
+ (win->funcs[event].parameter.use.kptr,
+ data1, data2_p);
+ return 0;
+}
+
+static int hfidd_hfi_ready_registration(struct hfidd_acs *p_acs,
+ struct hfi_reg_events *reg)
+{
+ struct hfidd_hfi_ready_req *req;
+
+ if (p_acs->state == HFI_AVAIL) {
+ /* notify kernel user */
+ return ((hfi_event_func_ptr)reg->info.func.function_p.use.kptr)
+ (reg->info.func.parameter.use.kptr, 0, 0);
+ } else {
+ /* Alloc entry */
+ req = kzalloc(sizeof(*req), GFP_KERNEL);
+ if (req == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_hfi_ready_registration: kzalloc failed\n");
+ return -ENOMEM;
+ }
+
+ /* Fill the entry for the list */
+ req->func.index = reg->info.func.index;
+ req->func.function_p.use.kptr =
+ reg->info.func.function_p.use.kptr;
+ req->func.parameter.use.kptr =
+ reg->info.func.parameter.use.kptr;
+ list_add(&(req->list), &(p_acs->hfi_ready_reg_list));
+ }
+
+ return 0;
+}
+
+static void hfidd_hfi_ready_unregistration(struct hfidd_acs *p_acs,
+ struct hfi_reg_events *reg)
+{
+ struct hfidd_hfi_ready_req *req;
+ struct list_head *q;
+ struct list_head *pos;
+
+ list_for_each_safe(pos, q, &p_acs->hfi_ready_reg_list) {
+ req = list_entry(pos,
+ struct hfidd_hfi_ready_req, list);
+ if ((req->func.function_p.use.kptr ==
+ reg->info.func.function_p.use.kptr) &&
+ (req->func.parameter.use.kptr ==
+ reg->info.func.parameter.use.kptr)) {
+ list_del(pos);
+ kfree(req);
+ break;
+ }
+ }
+
+}
+
+void hfidd_notify_hfi_ready(struct hfidd_acs *p_acs)
+{
+ struct hfidd_hfi_ready_req *req;
+ struct list_head *q;
+ struct list_head *pos;
+
+ list_for_each_safe(pos, q, &p_acs->hfi_ready_reg_list) {
+ req = list_entry(pos,
+ struct hfidd_hfi_ready_req, list);
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_notify_hfi_ready: Calling Kernel user\n");
+
+ /* Calling IP function */
+ ((hfi_event_func_ptr)req->func.function_p.use.kptr)
+ (req->func.parameter.use.kptr, 0, 0);
+ list_del(pos);
+ kfree(req);
+ }
+}
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
index 0d0ce69..eb6064e 100644
--- a/drivers/net/hfi/core/hfidd_init.c
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -179,6 +179,40 @@ static ssize_t hfidd_cmd_write(struct file *filep, const char __user *buf,
(struct hfi_window_info *) buf);
break;
+ case HFIDD_REQ_EVENT_REGISTER:
+ if (cmd.req_len != sizeof(struct hfi_reg_events)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_cmd_write: hdr.reqlen 0x%x expected "
+ "0x%lx for cmd req 0x%x\n",
+ cmd.req_len,
+ sizeof(struct hfi_reg_events), cmd.req);
+ return -EINVAL;
+ }
+ if (is_userspace)
+ rc = hfidd_events_register(p_acs,
+ (struct hfi_reg_events *) buf);
+ else
+ rc = hfidd_callback_register(p_acs,
+ (struct hfi_reg_events *) buf);
+ break;
+
+ case HFIDD_REQ_EVENT_UNREGISTER:
+ if (cmd.req_len != sizeof(struct hfi_reg_events)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_cmd_write: hdr.reqlen 0x%x expected "
+ "0x%lx for cmd req 0x%x\n",
+ cmd.req_len,
+ sizeof(struct hfi_reg_events), cmd.req);
+ return -EINVAL;
+ }
+ if (is_userspace)
+ rc = hfidd_events_unregister(p_acs,
+ (struct hfi_reg_events *) buf);
+ else
+ rc = hfidd_callback_unregister(p_acs,
+ (struct hfi_reg_events *) buf);
+ break;
+
case HFIDD_REQ_QUERY_DD_INFO:
if (cmd.req_len != sizeof(struct hfi_query_dd_info)) {
dev_printk(KERN_ERR, p_acs->hfidd_dev,
@@ -348,6 +382,7 @@ int hfidd_init_adapter(struct hfidd_acs *p_acs, void *uiop)
{
int rc = 0;
+ INIT_LIST_HEAD(&(p_acs->hfi_ready_reg_list));
rc = hfidd_dds_init(p_acs, &(p_acs->dds));
p_acs->dds.num_d_windows = HFI_DYN_WINS_DEFAULT;
return rc;
diff --git a/drivers/net/hfi/core/hfidd_intr.c b/drivers/net/hfi/core/hfidd_intr.c
index 253de27..38f35f5 100644
--- a/drivers/net/hfi/core/hfidd_intr.c
+++ b/drivers/net/hfi/core/hfidd_intr.c
@@ -33,15 +33,45 @@
#include <linux/hfi/hfidd_internal.h>
#include "hfidd_proto.h"
+/* Post window event */
+static int hfidd_post_window_event(struct hfidd_acs *p_acs,
+ struct hfidd_window *win_p, enum hfi_event_type event)
+{
+ int rc = 0;
+
+ if (win_p->state == WIN_OPENED) {
+ if (win_p->funcs[event].function_p.use.kptr != NULL) {
+ rc = hfidd_callback_event(p_acs, win_p, event,
+ win_p->index, 0);
+ } else {
+ rc = hfidd_report_event(p_acs, win_p, event);
+ }
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_post_window_event: failed to "
+ "post event %d win 0x%x rc 0x%x\n",
+ event, win_p->index, rc);
+ }
+ }
+ return rc;
+}
+
static irqreturn_t send_intr_handler(int irq, void *data)
{
struct hfidd_window *win_p = data;
struct hfidd_acs *p_acs;
+ int rc;
p_acs = hfidd_global.p_acs[win_p->ai];
if (p_acs == NULL)
return IRQ_HANDLED;
-
+ rc = hfidd_post_window_event(p_acs, win_p, HFIDD_SEND);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "send_intr_handler: failed post send event, "
+ "rc %d for win 0x%llx\n",
+ rc, (unsigned long long) win_p);
+ }
return IRQ_HANDLED;
}
@@ -49,11 +79,19 @@ static irqreturn_t recv_intr_handler(int irq, void *data)
{
struct hfidd_window *win_p = data;
struct hfidd_acs *p_acs;
+ int rc;
p_acs = hfidd_global.p_acs[win_p->ai];
if (p_acs == NULL)
return IRQ_HANDLED;
+ rc = hfidd_post_window_event(p_acs, win_p, HFIDD_RECV);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "recv_intr_handler: failed post recv event, "
+ "rc %d for win 0x%llx\n",
+ rc, (unsigned long long) win_p);
+ }
return IRQ_HANDLED;
}
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
index af88f0b..89f9639 100644
--- a/drivers/net/hfi/core/hfidd_proto.h
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -73,6 +73,20 @@ int hfidd_query_interface(struct hfidd_acs *p_acs, unsigned int subtype,
int hfidd_start_nmmu(struct hfidd_acs *p_acs);
int hfidd_start_interface(struct hfidd_acs *p_acs);
int hfidd_stop_interface(struct hfidd_acs *p_acs, unsigned int hfi_id);
+int hfidd_events_register(struct hfidd_acs *p_acs, struct hfi_reg_events *arg);
+int hfidd_events_unregister(struct hfidd_acs *p_acs,
+ struct hfi_reg_events *arg);
+int hfidd_callback_register(struct hfidd_acs *p_acs,
+ struct hfi_reg_events *arg);
+int hfidd_callback_unregister(struct hfidd_acs *p_acs,
+ struct hfi_reg_events *arg);
+int hfidd_report_event(struct hfidd_acs *p_acs, struct hfidd_window *win,
+ enum hfi_event_type event);
+int hfidd_callback_event(struct hfidd_acs *p_acs, struct hfidd_window *win,
+ enum hfi_event_type event, unsigned int data1,
+ unsigned int *data2_p);
+int hfidd_events_clean(struct hfidd_acs *p_acs, struct hfidd_window *win);
+void hfidd_notify_hfi_ready(struct hfidd_acs *p_acs);
int hfidd_init_win_interrupt(struct hfidd_acs *p_acs,
struct hfidd_window *win_p);
void hfidd_clear_win_interrupt(struct hfidd_window *win_p);
@@ -104,5 +118,5 @@ long long hfi_hquery_interface(u64 unit_id, u64 subtype, u64 query_p,
u64 *state);
long long hfi_start_interface(u64 unit_id);
long long hfi_stop_interface(u64 unit_id);
-
+long long hfi_query_window(u64 unit_id, u64 win_id, u64 *state);
#endif
diff --git a/drivers/net/hfi/core/hfidd_window.c b/drivers/net/hfi/core/hfidd_window.c
index 6864eae..1d7f2b1 100644
--- a/drivers/net/hfi/core/hfidd_window.c
+++ b/drivers/net/hfi/core/hfidd_window.c
@@ -314,6 +314,8 @@ static inline int hfi_validate_window_id(struct hfidd_acs *p_acs,
static inline void hfi_restore_window_parm(struct hfidd_acs *p_acs,
struct hfidd_window *win_p)
{
+ int i;
+
if (win_p->type != HFIDD_RESERVE_WIN) {
win_p->type = HFIDD_DYNAMIC_WIN;
win_p->job_id = 0;
@@ -325,6 +327,12 @@ static inline void hfi_restore_window_parm(struct hfidd_acs *p_acs,
}
win_p->pid = 0;
win_p->is_ip = 0;
+
+
+ for (i = 0; i < HFIDD_NUM_EVENT_TYPES; i++) {
+ win_p->funcs[i].function_p.use.kptr = NULL;
+ win_p->funcs[i].parameter.use.kptr = NULL;
+ }
}
/* Validate window number and type for open window request */
@@ -1074,6 +1082,13 @@ int hfidd_open_window_func(struct hfidd_acs *p_acs, unsigned int is_userspace,
win_p->state = WIN_OPENED;
spin_unlock(&(win_p->win_lock));
+ /*
+ * Increment so that any waiting threads that wake up realize
+ * they are dealing with a window that has been reopened
+ */
+ atomic_inc(&win_p->open_close_count);
+ hfidd_events_clean(p_acs, win_p);
+
kfree(local_p);
return rc;
@@ -1129,6 +1144,12 @@ int hfidd_close_window_internal(struct hfidd_acs *p_acs,
goto hfidd_close_window_internal_err0;
}
+ /* Wake up threads waiting for terminate event. */
+ rc = hfidd_report_event(p_acs, win_p, HFIDD_TERMINATE);
+ if (rc)
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "close_window_internal: report event failed "
+ "rc=0x%x\n", rc);
spin_lock(&(win_p->win_lock));
/* Make sure state is open or error state. */
@@ -1183,6 +1204,9 @@ int hfidd_close_window_internal(struct hfidd_acs *p_acs,
hfi_restore_window_parm(p_acs, win_p);
spin_unlock(&win_p->win_lock);
+ atomic_inc(&win_p->open_close_count);
+ hfidd_events_clean(p_acs, win_p);
+
dev_printk(KERN_INFO, p_acs->hfidd_dev,
"close_window_internal: type=0x%x state=0x%x JobID=0x%x\n",
win_p->type, win_p->state, win_p->job_id);
diff --git a/include/linux/hfi/hfidd_client.h b/include/linux/hfi/hfidd_client.h
index 3b2d032..7f87674 100644
--- a/include/linux/hfi/hfidd_client.h
+++ b/include/linux/hfi/hfidd_client.h
@@ -97,6 +97,9 @@ struct fifo_info {
#define HFIDD_RESERVE_WIN 3 /* Must be reserved by job scheduler */
#define HFIDD_DYNAMIC_WIN 4 /* First come, first served. Window# is
returned */
+#define HFIDD_DST_BCST_WIN 0
+#define HFIDD_DST_BCST_ISR 0x3FFF
+
struct hfi_client_info {
struct hfi_req_hdr hdr;
@@ -138,6 +141,67 @@ enum hfi_event_type {
HFIDD_NUM_EVENT_TYPES = 12
};
+#define HFIDD_SEND_EVENT 0x00000100
+#define HFIDD_RECV_EVENT 0x00000200
+#define HFIDD_WIN_ERROR_EVENT 0x00000400
+#define HFIDD_HFI_ERROR_EVENT 0x00000800
+#define HFIDD_TERMINATE_EVENT 0x00001000
+#define HFIDD_RELEASE_WINDOW_EVENT 0x00002000
+#define HFIDD_CAU_ERROR_EVENT 0x00004000
+#define HFIDD_ICS_ERROR_EVENT 0x00008000
+#define HFIDD_HFI_READY_REG_EVENT 0x00010000
+#define HFIDD_ROUTE_CHANGE_EVENT 0x00020000
+#define HFIDD_IP_TRC_LVL_EVENT 0x00040000
+#define HFIDD_POOL_SIZE_EVENT 0x00080000
+#define HFIDD_LOWEST_EVENT HFIDD_SEND_EVENT
+#define HFIDD_ALL_EVENTS 0x000FFF00
+
+enum hfi_event_hndlr_type {
+ WAIT_FOR_EVENTS = 1, /* Wait for events */
+ SIGNAL_EVENTS = 2, /* Event notification by signal */
+ FUNCTIONS_FOR_EVENTS = 3 /* Callback functions */
+};
+
+typedef int (*hfi_event_func_ptr)(void *parm, unsigned int win,
+ unsigned int *ext);
+
+struct hfi_callback_func { /* Callback funcs for kernel windows */
+ enum hfi_event_type index; /* index of callback type */
+ unsigned int pad;
+ struct hfi_64b function_p; /* function ptr */
+ struct hfi_64b parameter; /* parameter to pass in */
+};
+
+/*
+ * HFIDD_REQ_EVENT_REGISTER/HFIDD_REQ_EVENT_UNREGISTER: event
+ * registration/unregistration
+ */
+#define HFI_MAX_BUF_EVENTS 8 /* # event buffers for signal version */
+struct hfi_event_buffer { /* For reporting events with signals */
+ unsigned int tag;
+ enum hfi_event_type current_event;
+};
+
+struct hfi_reg_events {
+ struct hfi_req_hdr hdr;
+ unsigned int window;
+ enum hfi_event_hndlr_type type;
+ union {
+ unsigned int events;
+ struct hfi_callback_func func;
+ struct hfi_64b eb; /* Pointer to event buffer in
+ user space (signal only) */
+ } info;
+};
+
+/* HFIDD_REQ_EVENT_WAIT: wait on event */
+struct hfi_wait_events {
+ struct hfi_req_hdr hdr;
+ unsigned int window; /* Window for events */
+ unsigned int events; /* events to wait for */
+ unsigned int out_events; /* events received */
+};
+
#define MAX_TORRENTS 1
#define MAX_HFI_PER_TORRENT 2
#define MAX_HFIS (MAX_TORRENTS * MAX_HFI_PER_TORRENT)
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index f82a626..df67b89 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -72,6 +72,16 @@
#define HFIDD_DEV_NAME "hfi"
#define HFIDD_CLASS_NAME "hfi"
+#define HFIDD_EVENT_CLEANUP_LOOP_COUNT 1000
+#define HFIDD_EVENT_CLEANUP_DELAY 10
+
+/* window event */
+struct hfidd_q_event {
+ struct list_head list;
+ struct hfidd_q_event *next; /* For preallocation list */
+ unsigned int event;
+};
+
struct hfidd_dds {
unsigned int version; /* HFI adapter type */
unsigned long long misc_base_address; /* Misc user base address */
@@ -83,6 +93,33 @@ struct hfidd_dds {
unsigned long long fw_ec_level; /* Firmware Level */
};
+struct hfidd_tid_info {
+ struct hfidd_tid_info *next;
+ unsigned long long tid; /* Thread id */
+ struct semaphore tid_sem;
+ unsigned int registered_events;
+ unsigned int deferred_events;/* Events that have occurred
+ but have not yet been
+ reported */
+ enum hfi_event_hndlr_type type;
+ struct list_head event_list; /* List of hfidd_event */
+ wait_queue_head_t event_wait; /* Used to wait and post
+ threads */
+ unsigned int tag; /* Used with eb */
+ struct task_struct *eb_xd; /* For cross task write */
+ struct hfi_event_buffer *eb; /* Pointer to event
+ buffer location in
+ user space (for
+ signal handling) */
+ struct task_struct *th; /* task_struct associated with
+ tid */
+};
+
+struct hfidd_win_event {
+ struct hfidd_win_event *next;
+ struct hfidd_tid_info *tid_info;
+};
+
struct hfidd_fifo {
unsigned long long eaddr;
unsigned long long size;
@@ -92,6 +129,7 @@ struct hfidd_fifo {
struct hfidd_window {
spinlock_t win_lock; /* lock for window */
+ spinlock_t event_lock; /* lock for event handling */
int index;
unsigned int type; /* dynamic/scheduled */
int state;
@@ -117,10 +155,40 @@ struct hfidd_window {
OPEN_WINDOW hcall */
unsigned long long mmio_regs; /* logical addr from
OPEN WINDOW hcall */
+ atomic_t open_close_count; /*Incremented every time
+ a window is opened or
+ closed. This is used for
+ event handling to determine
+ if a close occurred while
+ waiting. */
+ struct hfi_callback_func funcs[HFIDD_NUM_EVENT_TYPES]; /* Callback
+ funcs for IP */
+ struct hfidd_win_event *events[HFIDD_NUM_EVENT_TYPES]; /* Each
+ array entry points to a
+ list. Each list entry
+ contains a tid that should
+ be posted when this event
+ occurs. */
+ atomic_t num_events[HFIDD_NUM_EVENT_TYPES]; /* Number
+ of elements in each of the
+ events lists */
+ struct hfidd_tid_info *tid_list; /* List of tids registered for
+ events on this window */
+ atomic_t num_tids; /* Number of tids in
+ tid_list */
+ atomic_t event_wait_count;/* Indicates how many
+ threads are waiting for
+ events on this window */
struct hfidd_vlxmem *sfifo_x_tab;
struct hfidd_vlxmem *rfifo_x_tab;
};
+struct hfidd_hfi_ready_req {
+ struct list_head list;
+ struct hfi_callback_func func;
+};
+
+
#define HFI_DEVICE_NAME_MAX 8
/* hfi global */
struct hfidd_acs {
@@ -131,6 +199,7 @@ struct hfidd_acs {
unsigned int state;
unsigned int isr;
+ struct list_head hfi_ready_reg_list;
struct hfidd_window **win;
struct device *hfidd_dev;
diff --git a/include/linux/hfi/hfidd_requests.h b/include/linux/hfi/hfidd_requests.h
index a7a38da..002ae7f 100644
--- a/include/linux/hfi/hfidd_requests.h
+++ b/include/linux/hfi/hfidd_requests.h
@@ -37,4 +37,7 @@
#define HFIDD_REQ_QUERY_DD_INFO 0x00001004
#define HFIDD_REQ_CLOSE_WINDOW 0x00000a02
+#define HFIDD_REQ_EVENT_REGISTER 0x00000702
+#define HFIDD_REQ_EVENT_UNREGISTER 0x00000703
+
#endif /* _HFIDD_REQUESTS_H_ */
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 26/27] HFI: hfi_ip fifo receive path
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/ip/hf_proto.h | 2 +
drivers/net/hfi/ip/hfi_ip_main.c | 326 +++++++++++++++++++++++++++++++++++++-
include/linux/hfi/hfi_ip.h | 26 +++-
3 files changed, 351 insertions(+), 3 deletions(-)
diff --git a/drivers/net/hfi/ip/hf_proto.h b/drivers/net/hfi/ip/hf_proto.h
index b0232ab..022512a 100644
--- a/drivers/net/hfi/ip/hf_proto.h
+++ b/drivers/net/hfi/ip/hf_proto.h
@@ -34,6 +34,8 @@
#define _HF_PROTO_H_
int hf_tx_check_avail(struct hf_net *net, u32 xmit_cls);
+void hf_construct_hwhdr(struct hf_if *net_if, struct sk_buff *skb,
+ struct base_hdr *b_hdr);
extern int hfidd_open_window_func(struct hfidd_acs *p_acs,
u32 is_userspace,
struct hfi_client_info *user_p,
diff --git a/drivers/net/hfi/ip/hfi_ip_main.c b/drivers/net/hfi/ip/hfi_ip_main.c
index 689f92e..6b2ec3f 100644
--- a/drivers/net/hfi/ip/hfi_ip_main.c
+++ b/drivers/net/hfi/ip/hfi_ip_main.c
@@ -154,6 +154,9 @@ static int hf_alloc_rx_resource(struct hf_net *net)
memset(net_if->rx_fifo.addr, 0, net_if->rx_fifo.size);
+ net_if->rx_fslot_debt = 0;
+ net_if->rx_pkt_valid = 1;
+
return 0;
}
@@ -209,8 +212,18 @@ static int hf_send_intr_callback(void *parm, u32 win, u32 ext)
return 0;
}
+static int hf_recv_intr_callback(void *parm, u32 win, u32 ext)
+{
+ struct hf_net *net = (struct hf_net *)parm;
+
+ napi_schedule(&(net->napi));
+
+ return 0;
+}
+
struct hf_events_cb hf_events[HF_EVENT_NUM] = {
{HFIDD_SEND, (void *)hf_send_intr_callback},
+ {HFIDD_RECV, (void *)hf_recv_intr_callback},
};
static int hf_register_ip_events(struct hf_net *net,
@@ -357,14 +370,50 @@ static int hf_set_mac_addr(struct net_device *netdev, void *p)
return 0;
}
+static void hf_set_recv_intr(struct hf_if *net_if)
+{
+ int offset;
+ struct hfi_hdr *rx_pkt;
+
+ /* enable recv intr and set threshold to next packet */
+ offset = net_if->rx_fifo.head;
+
+ hf_mmio_regs_write_then_read(net_if, HFI_RFIFO_INTR_REG,
+ (HF_ENA_RECV_INTR + (offset << HF_RECV_INTR_MATCH_SHIFT)));
+
+ /* check if there is packet received in the mean time */
+ rx_pkt = net_if->rx_fifo.addr + (offset << HFI_CACHE_LINE_SHIFT);
+
+ if ((rx_pkt->id.job_id == HF_IP_JOBID) &&
+ (rx_pkt->base_hdr.pkt_valid == net_if->rx_pkt_valid)) {
+
+ /* force an immediate recv intr */
+ hf_mmio_regs_write(net_if, HFI_RFIFO_INTR_REG,
+ (HF_IMM_RECV_INTR + (offset << HF_RECV_INTR_MATCH_SHIFT)));
+ }
+}
+
static void hf_init_hw_regs(struct hf_if *net_if)
{
/* setup IP with payload threshold in cache line size */
hf_mmio_regs_write(net_if, HFI_IP_RECV_SIZE,
(HF_PAYLOAD_RX_THRESHOLD << HF_PAYLOAD_RX_THRESH_SHIFT));
+ /* setup recv fifo out of order intr control to disable */
+ hf_mmio_regs_write(net_if, HFI_RFIFO_OUT_EVENT_REG,
+ HF_RFIFO_OUT_CNTL_REARM);
+
+ /* setup recv fifo out of order threshold */
+ hf_mmio_regs_write(net_if, HFI_RFIFO_OUT_TH_REG, HF_RFIFO_OUT_THRESH);
+
/* initialize SEND INTR STATUS */
hf_mmio_regs_write(net_if, HFI_SINTR_STATUS_REG, 0);
+
+ hf_mmio_regs_write(net_if, HFI_RFIFO_INJ_TH_REG,
+ (HF_RFIFO_CACHE_INJ_TH << HF_RFIFO_CACHE_INJ_TH_SHIFT));
+
+ /* enable and set receive intr */
+ hf_set_recv_intr(net_if);
}
static int hf_net_delayed_open(void *parm, u16 win, u16 ext)
@@ -402,6 +451,7 @@ static int hf_net_delayed_open(void *parm, u16 win, u16 ext)
net_if->state = HF_NET_OPEN;
spin_unlock(&(net_if->lock));
+ napi_enable(&net->napi);
netif_carrier_on(netdev);
netif_start_queue(netdev);
@@ -488,6 +538,7 @@ static int hf_net_close(struct net_device *netdev)
spin_lock(&(net_if->lock));
if (net_if->state == HF_NET_OPEN) {
+ napi_disable(&net->napi);
netif_stop_queue(netdev);
netif_carrier_off(netdev);
@@ -507,6 +558,245 @@ static int hf_net_close(struct net_device *netdev)
return 0;
}
+/* Invalidate the jobid field of each cache line before advancing head.
+ * The first cache line is protected by the valid bit, so we skip it. */
+static inline void hf_advance_rx_head(struct hf_if *net_if, u32 len)
+{
+ int i, h;
+ u32 *cache_p;
+
+ h = (net_if->rx_fifo.head + 1) & (net_if->rx_fifo.emax);
+
+ for (i = 1; i < len; i++) {
+ cache_p = (u32 *)((char *)(net_if->rx_fifo.addr) +
+ (h << HFI_CACHE_LINE_SHIFT));
+ if (*cache_p == HF_IP_JOBID)
+ *cache_p = 0;
+ h = (h + 1) & (net_if->rx_fifo.emax);
+ }
+
+ if (net_if->rx_fifo.head > h)
+ net_if->rx_pkt_valid ^= 0x1;
+
+ net_if->rx_fifo.head = h;
+}
+
+void hf_construct_hwhdr(struct hf_if *net_if,
+ struct sk_buff *skb,
+ struct base_hdr *b_hdr)
+{
+ struct ethhdr *hwhdr_p;
+
+ hwhdr_p = (struct ethhdr *)(skb->data);
+
+ /* MAC byte 1, bits6 = 1, locally admin MAC */
+ hwhdr_p->h_dest[0] = 0x2;
+ /* MAC byte 2, bits2-7 = cluster id */
+ hwhdr_p->h_dest[1] = 0x0;
+ *(u16 *)(&(hwhdr_p->h_dest[2])) = (u16)(b_hdr->dst_isr);
+ *(u16 *)(&(hwhdr_p->h_dest[4])) =
+ (u16)hf_get_mac(b_hdr->dst_win);
+
+ hwhdr_p->h_source[0] = 0x2;
+ hwhdr_p->h_source[1] = 0x0;
+ *(u16 *)(&(hwhdr_p->h_source[2])) = (u16)(b_hdr->src_isr);
+ *(u16 *)(&(hwhdr_p->h_source[4])) =
+ (u16)hf_get_mac(b_hdr->src_win);
+
+ hwhdr_p->h_proto = skb->protocol;
+}
+
+static inline int hf_check_hdr_version(struct hf_net *net,
+ struct hf_if_proto_hdr *hf_hdr)
+{
+ if (hf_hdr->version != HF_PROTO_HDR_VERSION) {
+ netdev_err(net->netdev,
+ "hf_check_hdr_version: hdr version 0x%x "
+ "does not match 0x%x\n",
+ hf_hdr->version, HF_PROTO_HDR_VERSION);
+ net->netdev->stats.rx_dropped++;
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static void hf_recv_ip_with_payload(struct hf_net *net,
+ struct hfi_ip_with_payload_pkt *pkt,
+ u32 pkt_len)
+{
+ u32 len, resid;
+ struct hf_if *net_if = &(net->hfif);
+ struct net_device *netdev = net->netdev;
+ struct hf_if_proto_hdr *hf_hdr;
+ struct sk_buff *skb;
+ void *src, *dst;
+ u32 cache_ln_num = 0;
+ u16 proto;
+
+ /* retrieve the protocol header pointer */
+ hf_hdr = (struct hf_if_proto_hdr *)(pkt->payload);
+
+ if (hf_check_hdr_version(net, hf_hdr) != 0)
+ return;
+
+ switch (hf_hdr->msg_type) {
+ case HF_IF_ARP:
+ proto = htons(ETH_P_ARP);
+ break;
+
+ case HF_IF_FIFO:
+ proto = htons(ETH_P_IP);
+ break;
+
+ default:
+ netdev_err(net->netdev,
+ "hf_recv_ip_with_payload: unknown msg_type 0x%x\n",
+ hf_hdr->msg_type);
+ netdev->stats.rx_dropped++;
+ return;
+ }
+
+ len = hf_hdr->msg_len - HF_PROTO_LEN;
+
+ skb = netdev_alloc_skb_ip_align(net->netdev,
+ len + ETH_HLEN + HF_ALIGN_PAD);
+ if (!skb) {
+ netdev_err(net->netdev, "hf_recv_ip_with_payload: "
+ "netdev_alloc_skb_ip_align fail\n");
+ netdev->stats.rx_dropped++;
+ BUG();
+ return;
+ }
+
+ skb_reserve(skb, HF_ALIGN_PAD);
+ skb->protocol = proto;
+
+ skb_put(skb, len + ETH_HLEN);
+
+ /* construct ethhdr from base hdr */
+ hf_construct_hwhdr(net_if, skb, &(pkt->hfi_hdr.base_hdr));
+
+ skb_reset_mac_header(skb);
+
+ skb_pull(skb, ETH_HLEN);
+
+ src = (void *)(hf_hdr + 1);
+ dst = (void *)skb->data;
+
+ /* check if the payload wrapped the rx_fifo */
+ if ((net_if->rx_fifo.head + (pkt_len - 1)) > net_if->rx_fifo.emax) {
+ /* Wrapped */
+ cache_ln_num = net_if->rx_fifo.emax - net_if->rx_fifo.head + 1;
+ resid = cache_ln_num << HFI_CACHE_LINE_SHIFT;
+ resid -= (HF_IP_HDR_LEN + HF_PROTO_LEN);
+
+ /* For netboot, pkt_len maybe larger than len */
+ if (resid > len)
+ resid = len;
+
+ memcpy(dst, src, resid);
+
+ src = (void *)net_if->rx_fifo.addr;
+ dst = (void *)skb->data + resid;
+ len -= resid;
+ }
+
+ /* copy the rest of payload */
+ if (len > 0)
+ memcpy(dst, src, len);
+
+ skb->ip_summed = CHECKSUM_NONE;
+
+ netdev->stats.rx_packets++;
+ netdev->stats.rx_bytes += skb->len;
+
+ netif_receive_skb(skb);
+}
+
+static void hf_recv_ip_good(struct hf_net *net,
+ struct hfi_hdr *rx_curr,
+ u32 pkt_len)
+{
+ switch (rx_curr->type.header_type) {
+
+ case HFI_IP_WITH_PAYLOAD:
+ case HFI_IP_MULTICAST_WITH_PAYLOAD:
+ hf_recv_ip_with_payload(net,
+ (struct hfi_ip_with_payload_pkt *)rx_curr, pkt_len);
+ break;
+
+ default:
+ netdev_err(net->netdev, "hf_rx: receive unknown "
+ "headerType = 0x%x, pkt_len = 0x%x\n",
+ rx_curr->type.header_type, pkt_len);
+
+ /* unknown packet, drop it */
+ net->netdev->stats.rx_dropped++;
+ break;
+ }
+}
+
+static int hf_rx(struct hf_net *net, int budget)
+{
+ int num = 0;
+ struct hf_if *net_if = &(net->hfif);
+ u32 pkt_len, status;
+ struct hfi_hdr *rx_curr;
+ u32 job_id, pkt_valid;
+
+ rx_curr = (struct hfi_hdr *) (net_if->rx_fifo.addr +
+ (net_if->rx_fifo.head << HFI_CACHE_LINE_SHIFT));
+
+ while (budget != 0) {
+ job_id = rx_curr->id.job_id;
+ pkt_valid = rx_curr->base_hdr.pkt_valid;
+
+ isync();
+ if ((job_id != HF_IP_JOBID) ||
+ (pkt_valid != net_if->rx_pkt_valid))
+ break;
+
+ pkt_len = hfi_pktlen_to_cachelines(rx_curr->base_hdr.pkt_len);
+
+ status = rx_curr->base_hdr.status;
+ if (status == HFI_PKT_STATUS_GOOD) {
+ hf_recv_ip_good(net, rx_curr, pkt_len);
+ } else {
+ /* bad packet */
+ netdev_err(net->netdev, "hf_rx: receive bad "
+ "status = 0x%x, pkt_len = 0x%x\n",
+ status, pkt_len);
+
+ net->netdev->stats.rx_dropped++;
+ }
+
+ net->netdev->last_rx = jiffies;
+
+ hf_advance_rx_head(net_if, pkt_len);
+
+ /* Make sure the jobid is invalidated before posting to hw */
+ wmb();
+
+ net_if->rx_fslot_debt += pkt_len;
+ if (net_if->rx_fslot_debt >= HF_INC_FSLOT_WATERMARK) {
+ hf_mmio_regs_write(net_if, HFI_RFIFO_INC_FSLOT_REG,
+ net_if->rx_fslot_debt);
+ net_if->rx_fslot_debt = 0;
+ }
+
+ budget--;
+ num++;
+ rx_curr = net_if->rx_fifo.addr +
+ (net_if->rx_fifo.head << HFI_CACHE_LINE_SHIFT);
+
+ }
+
+ netdev_dbg(net->netdev, "hf_rx: exit, head = 0x%x, recv 0x%x pkts\n",
+ net_if->rx_fifo.head, num);
+
+ return num;
+}
+
static void hf_tx_recycle(struct hf_if *net_if)
{
u32 head, head_idx, slots_per_blk;
@@ -906,6 +1196,30 @@ static void hf_if_setup(struct net_device *netdev)
memcpy(netdev->broadcast, hfi_bcast_addr, ETH_ALEN);
}
+static int hf_poll(struct napi_struct *napi, int budget)
+{
+ int work_done;
+ struct net_device *netdev;
+ struct hf_net *net;
+ struct hf_if *net_if;
+
+ net = container_of(napi, struct hf_net, napi);
+ net_if = &(net->hfif);
+ netdev = net->netdev;
+
+ work_done = hf_rx(net, budget);
+
+ /* Always assume we have received all available packets */
+ /* and set recv intr for next packet */
+ if (work_done < budget) {
+ napi_complete(napi);
+ isync();
+ hf_set_recv_intr(net_if);
+ }
+
+ return work_done;
+}
+
static struct hf_net *hf_init_netdev(int idx, int ai)
{
struct net_device *netdev;
@@ -924,6 +1238,7 @@ static struct hf_net *hf_init_netdev(int idx, int ai)
}
net = netdev_priv(netdev);
+ netif_napi_add(netdev, &(net->napi), hf_poll, HF_NAPI_WEIGHT);
net->netdev = netdev;
memset(&(net->hfif), 0, sizeof(struct hf_if));
@@ -939,11 +1254,16 @@ static struct hf_net *hf_init_netdev(int idx, int ai)
netdev_err(netdev, "hf_init_netdev: "
"failed to register netdev=hfi%d:hf%d, "
"rc = 0x%x\n", ai, idx, rc);
- free_netdev(netdev);
- return ERR_PTR(-ENODEV);
+ goto err_out1;
}
return net;
+
+err_out1:
+ netif_napi_del(&(net->napi));
+ free_netdev(netdev);
+
+ return ERR_PTR(-ENODEV);
}
static void hf_del_netdev(struct hf_net *net)
@@ -952,6 +1272,8 @@ static void hf_del_netdev(struct hf_net *net)
unregister_netdev(netdev);
+ netif_napi_del(&(net->napi));
+
free_netdev(netdev);
}
diff --git a/include/linux/hfi/hfi_ip.h b/include/linux/hfi/hfi_ip.h
index 4e70c14..ec87300 100644
--- a/include/linux/hfi/hfi_ip.h
+++ b/include/linux/hfi/hfi_ip.h
@@ -38,6 +38,7 @@
#include <linux/init.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
+#include <linux/etherdevice.h>
#include <net/arp.h>
#include <linux/hfi/hfidd_internal.h>
@@ -56,6 +57,12 @@
#define HF_NAPI_WEIGHT 256
#define HF_MAX_NAME_LEN 64
+/* rfifo intr */
+#define HF_RFIFO_OUT_CNTL_REARM 0 /* 0 to disable interrupt */
+#define HF_IMM_RECV_INTR 0xf0000000 /* bit 32-35 on */
+#define HF_ENA_RECV_INTR 0xc0000000 /* bit 32-33 on */
+#define HF_RECV_INTR_MATCH_SHIFT 7 /* bit 37-56 */
+
/* sfifo intr: bit 39-55 is threshold */
/* bit 34 enable, bit 35 unmask */
#define HF_SFIFO_INTR_ENABLE (0x3 << (63 - 35))
@@ -74,11 +81,17 @@
#define HF_FV_BIT_MAX 31
#define HF_SEND_ONE 1
+#define HF_RFIFO_CACHE_INJ_TH 7ULL
+#define HF_RFIFO_CACHE_INJ_TH_SHIFT 61
+#define HF_RFIFO_OUT_THRESH 0
+
#define HF_PAYLOAD_MAX (2048 - HF_IP_HDR_LEN - HF_PROTO_LEN)
#define HF_NET_MTU HF_PAYLOAD_MAX
#define HF_PAYLOAD_RX_THRESHOLD 0x10ULL
#define HF_PAYLOAD_RX_THRESH_SHIFT 59
+#define HF_INC_FSLOT_WATERMARK (HF_RFIFO_SLOTS >> 3)
+
struct hfi_ip_extended_hdr { /* 16B */
unsigned int immediate_len:7;/* In bytes */
unsigned int num_desc:3; /* number of descriptors */
@@ -99,7 +112,9 @@ struct hfi_ip_with_payload_pkt {
#define HF_IP_HDR_LEN ((sizeof(struct hfi_hdr) + \
sizeof(struct hfi_ip_extended_hdr)))
+
#define HF_ALIGN_PAD 2
+
#define HF_PROTO_HDR_VERSION 0x1
/* HFI protocol message type */
#define HF_IF_ARP 0xA0
@@ -146,7 +161,10 @@ struct hf_if {
u32 sfifo_fv_polarity;
u32 sfifo_slots_per_blk;
u32 sfifo_packets;
+ u32 rx_pkt_valid; /* Polarity of recv
+ packet valid bit */
u32 msg_id;
+ u32 rx_fslot_debt;
void __iomem *doorbell; /* mapped mmio_regs */
struct hf_fifo tx_fifo;
struct hf_fifo rx_fifo;
@@ -159,6 +177,7 @@ struct hf_if {
/* Private structure for HF inetrface */
struct hf_net {
struct net_device *netdev;
+ struct napi_struct napi;
struct hf_if hfif;
};
@@ -172,7 +191,7 @@ struct hf_global_info {
extern struct hf_global_info hf_ginfo;
-#define HF_EVENT_NUM 1
+#define HF_EVENT_NUM 2
struct hf_events_cb {
enum hfi_event_type type;
@@ -182,6 +201,11 @@ struct hf_events_cb {
#define HF_MAC_HFI_SHIFT 12
#define HF_HDR_HFI_SHIFT 8
+static inline u32 hf_get_mac(u32 w)
+{
+ return ((w >> HF_HDR_HFI_SHIFT) << HF_MAC_HFI_SHIFT) | (w & 0xFF);
+}
+
static inline u32 hf_get_win(u16 id)
{
return ((id >> HF_MAC_HFI_SHIFT) << HF_HDR_HFI_SHIFT) | (id & 0xFF);
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 16/27] HFI: Add window open hypervisor call
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/hfidd_hcalls.c | 50 +++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_proto.h | 6 +++
include/linux/hfi/hfidd_hcalls.h | 69 +++++++++++++++++++++++++++++++++++
3 files changed, 125 insertions(+), 0 deletions(-)
diff --git a/drivers/net/hfi/core/hfidd_hcalls.c b/drivers/net/hfi/core/hfidd_hcalls.c
index aabb2a8..1915336 100644
--- a/drivers/net/hfi/core/hfidd_hcalls.c
+++ b/drivers/net/hfi/core/hfidd_hcalls.c
@@ -131,6 +131,28 @@ static inline long long h_hfi_query_interface(int token,
return rc;
}
+static inline long long h_hfi_open_window(int token,
+ u64 HFI_chip_ID,
+ u64 win_num,
+ u64 flag,
+ u64 win_info_ptr,
+ u64 *user_mmio,
+ u64 *kernel_mmio,
+ u64 *send_int_num,
+ u64 *recv_int_num)
+{
+ long long rc;
+ u64 hyp_outputs[PLPAR_HCALL_BUFSIZE];
+
+ rc = plpar_hcall(token, (unsigned long *)hyp_outputs, HFI_chip_ID,
+ win_num, flag, win_info_ptr);
+ *user_mmio = hyp_outputs[0]; /* 1st ret value */
+ *kernel_mmio = hyp_outputs[1]; /* 2nd */
+ *send_int_num = hyp_outputs[2]; /* 3rd */
+ *recv_int_num = hyp_outputs[3]; /* 4th */
+ return rc;
+}
+
long long hfi_start_nmmu(u64 chip_id, void *nmmu_info)
{
return h_nmmu_start(H_NMMU_START, chip_id, nmmu_info);
@@ -152,6 +174,34 @@ long long hfi_stop_nmmu(u64 chip_id)
return hvrc;
}
+long long hfi_open_window(u64 unit_id, u64 win_id, u64 flag,
+ u64 win_info_p,
+ u64 *ummio_addr_p,
+ u64 *pmmio_addr_p,
+ u64 *send_intr,
+ u64 *recv_intr)
+{
+ long long hvrc;
+ u64 start_time = get_jiffies_64();
+
+ while (1) {
+ hvrc = h_hfi_open_window(H_HFI_OPEN_WINDOW,
+ unit_id,
+ win_id,
+ flag,
+ win_info_p,
+ ummio_addr_p,
+ pmmio_addr_p,
+ send_intr,
+ recv_intr);
+ if (hvrc != H_BUSY)
+ break;
+ if (hfidd_age_hcall(start_time))
+ break;
+ }
+ return hvrc;
+}
+
long long hfi_allocate_mr(u64 chip_id, u64 res, u64 addr, u64 mr_size,
u64 access,
u64 job_id,
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
index ff39a02..c4ed215 100644
--- a/drivers/net/hfi/core/hfidd_proto.h
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -67,6 +67,12 @@ int hfidd_start_interface(struct hfidd_acs *p_acs);
int hfidd_stop_interface(struct hfidd_acs *p_acs, unsigned int hfi_id);
long long hfi_start_nmmu(u64 chip_id, void *nmmu_info);
long long hfi_stop_nmmu(u64 chip_id);
+long long hfi_open_window(u64 unit_id, u64 win_id, u64 flag,
+ u64 win_info_p,
+ u64 *ummio_addr_p,
+ u64 *pmmio_addr_p,
+ u64 *send_intr,
+ u64 *recv_intr);
long long hfi_allocate_mr(u64 chip_id, u64 res, u64 addr,
u64 mr_size,
u64 access,
diff --git a/include/linux/hfi/hfidd_hcalls.h b/include/linux/hfi/hfidd_hcalls.h
index 3c9f556..a97bb5e 100644
--- a/include/linux/hfi/hfidd_hcalls.h
+++ b/include/linux/hfi/hfidd_hcalls.h
@@ -39,12 +39,19 @@
#define H_HFI_START_INTERFACE 0xF000
#define H_HFI_QUERY_INTERFACE 0xF004
#define H_HFI_STOP_INTERFACE 0xF008
+#define H_HFI_OPEN_WINDOW 0xF00C
#define H_NMMU_START 0xF028
#define H_NMMU_STOP 0xF02C
#define H_NMMU_ALLOCATE_RESOURCE 0xF030
#define H_NMMU_FREE_RESOURCE 0xF034
#define H_NMMU_MODIFY_RESOURCE 0xF03C
+#define H_OPEN 0x8000000000000000
+#define H_RESUME 0x0000000000000000
+#define H_SUSPEND 0x0000000000000000
+#define H_CLOSE 0x0000000000000001
+#define H_CHECK_CLOSED 0x0000000000000002
+
#define NMMU_MR 0
#define NMMU_MAP 1
@@ -63,6 +70,68 @@
#define HFI_ACCESS_CTL_SHIFT 32
+struct win_open_info {
+ /* Hyp Feedback */
+ unsigned long long hypervisor_capabilities;
+ unsigned int error_offset;
+
+ /* Window Control */
+ unsigned int job_id; /* send & recv jobid */
+ unsigned int protection_domain;
+
+ /* Immediate Send Context */
+ unsigned int immediate_send_pid;
+ unsigned int immediate_send_slots;
+ unsigned int immediate_send_update_freq;
+ unsigned long long immediate_send_finish_vec;
+
+ /* Send Fifo */
+ unsigned long long sfifo_base_eaddr;
+ unsigned int sfifo_lkey;
+ unsigned int sfifo_size; /* in bytes */
+ unsigned long long sfifo_finish_vec;
+
+ /* Full RDMA Send Fifo */
+ unsigned long long fullrdma_fifo_base_eaddr;
+ unsigned int fullrdma_fifo_lkey;
+ unsigned int fullrdma_fifo_size; /* in bytes */
+ unsigned int fullrdma_msg_breakup_count;
+ unsigned long long fullrdma_fifo_finish_vec;
+
+ /* Receive Fifo */
+ unsigned long long rfifo_base_eaddr;
+ unsigned int rfifo_lkey;
+ unsigned int rfifo_size; /* in bytes */
+
+ /* IP2k Free Space Decriptor Fifo */
+ unsigned long long ip2kfifo_base_eaddr;
+ unsigned int ip2kfifo_lkey;
+ unsigned int ip2kfifo_size; /* in bytes */
+
+ /* RDMA Pending Fifo */
+ unsigned long long rdmapending_base_eaddr;
+ unsigned int rdmapending_lkey;
+ unsigned int rdmapending_size; /* in bytes */
+ unsigned int rdmapending_read_req_thresh;
+
+ /* SendSpecial Fifo */
+ unsigned long long specialfifo_base_eaddr;
+ unsigned int specialfifo_lkey;
+ unsigned int specialfifo_size; /* in bytes */
+
+ /* IP Context */
+ unsigned int is_ip_window;
+ unsigned int multicast_enable;
+ unsigned int disable_src_isr_id_stamp;
+ unsigned int logical_port_id_valid;
+ unsigned int logical_port_id;
+
+ /* RDMA Context */
+ unsigned long long rcxt_base_eaddr;
+ unsigned int rcxt_lkey;
+ unsigned int rdma_payload_lkey;
+};
+
#define EEH_QUERY 1
#define COMP_QUERY 2
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 19/27] HFI: Add window close request
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/hfidd_init.c | 36 +++++++++
drivers/net/hfi/core/hfidd_proto.h | 4 +
drivers/net/hfi/core/hfidd_window.c | 148 +++++++++++++++++++++++++++++++++++
include/linux/hfi/hfidd_client.h | 8 ++
include/linux/hfi/hfidd_hcalls.h | 1 +
include/linux/hfi/hfidd_requests.h | 1 +
6 files changed, 198 insertions(+), 0 deletions(-)
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
index 49099ec..0d0ce69 100644
--- a/drivers/net/hfi/core/hfidd_init.c
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -78,6 +78,20 @@ static int hfidd_query_dd_info(struct hfidd_acs *p_acs,
return rc;
}
+/*
+ * This function is to check which command will be allowed after we got
+ * hfi error.
+ */
+static inline int valid_cmd_for_hfi_error(int cmd)
+{
+ switch (cmd) {
+ case HFIDD_REQ_CLOSE_WINDOW:
+ return 0;
+ default:
+ return -1;
+ }
+}
+
/* Entry point for user space to do driver requests. */
static ssize_t hfidd_cmd_write(struct file *filep, const char __user *buf,
size_t count, loff_t *pos)
@@ -128,6 +142,15 @@ static ssize_t hfidd_cmd_write(struct file *filep, const char __user *buf,
return -EINVAL;
}
+ if (p_acs->state != HFI_AVAIL) {
+ if (valid_cmd_for_hfi_error(cmd.req)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_write_cmd: hfi%d not avail, "
+ "state 0x%x for cmd 0x%x\n",
+ p_acs->index, p_acs->state, cmd.req);
+ return -EIO;
+ }
+ }
switch (cmd.req) {
case HFIDD_REQ_OPEN_WINDOW:
if (cmd.req_len != sizeof(struct hfi_client_info)) {
@@ -143,6 +166,19 @@ static ssize_t hfidd_cmd_write(struct file *filep, const char __user *buf,
(struct hfi_client_info *) cmd.result.use.kptr);
break;
+ case HFIDD_REQ_CLOSE_WINDOW:
+ if (cmd.req_len != sizeof(struct hfi_window_info)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_cmd_write: hdr.reqlen 0x%x expected "
+ "0x%lx for cmd req 0x%x\n",
+ cmd.req_len,
+ sizeof(struct hfi_window_info), cmd.req);
+ return -EINVAL;
+ }
+ rc = hfidd_close_window_func(p_acs, is_userspace,
+ (struct hfi_window_info *) buf);
+ break;
+
case HFIDD_REQ_QUERY_DD_INFO:
if (cmd.req_len != sizeof(struct hfi_query_dd_info)) {
dev_printk(KERN_ERR, p_acs->hfidd_dev,
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
index 1f7fe80..e065d56 100644
--- a/drivers/net/hfi/core/hfidd_proto.h
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -54,6 +54,10 @@ int hfidd_get_page_num(struct hfidd_acs *p_acs, void *start_addr,
int hfidd_open_window_func(struct hfidd_acs *p_acs, unsigned int is_userspace,
struct hfi_client_info *user_p,
struct hfi_client_info *out_p);
+int hfidd_close_window_internal(struct hfidd_acs *p_acs,
+ unsigned int is_userspace, unsigned int win_num);
+int hfidd_close_window_func(struct hfidd_acs *p_acs, unsigned int is_userspace,
+ struct hfi_window_info *user_p);
int hfi_register_rpages(struct hfidd_acs *p_acs, unsigned long long mr_handle,
unsigned int submr, struct hfidd_vlxmem *xtab_p,
unsigned int *mapped_pages);
diff --git a/drivers/net/hfi/core/hfidd_window.c b/drivers/net/hfi/core/hfidd_window.c
index 5d319a1..3cfe5c3 100644
--- a/drivers/net/hfi/core/hfidd_window.c
+++ b/drivers/net/hfi/core/hfidd_window.c
@@ -874,6 +874,28 @@ setup_window_parm_err1:
return rc;
}
+/* Unmap the window mmio registers - only user space window */
+static int hfi_unmap_mmio_regs(struct hfidd_acs *p_acs,
+ struct hfidd_window *win_p,
+ unsigned int is_userspace)
+{
+ int rc = 0;
+
+ if (is_userspace) {
+ rc = hfidd_unmap((void *)
+ (win_p->client_info.mmio_regs.use.kptr),
+ PAGE_SIZE_64K);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_unmap_mmio_regs: hfidd_unmap failed "
+ "rc = 0x%x\n", rc);
+ return rc;
+ }
+ win_p->client_info.mmio_regs.use.kptr = NULL;
+ }
+ return 0;
+}
+
/* Map the window mmio registers - only user space window */
static int hfi_map_mmio_regs(struct hfidd_acs *p_acs,
unsigned int is_userspace,
@@ -1023,3 +1045,129 @@ hfidd_open_window_func_err1:
return rc;
}
EXPORT_SYMBOL_GPL(hfidd_open_window_func);
+
+/*
+ * Close an user/kernel window to stop send/receive network traffic thru
+ * HFI adapter. This function will call PHYP to close the window and
+ * release the system resources allocated during open time. This function
+ * is called by hfidd_close_window_func or by abnormal end handler when
+ * the process goes away.
+ */
+int hfidd_close_window_internal(struct hfidd_acs *p_acs,
+ unsigned int is_userspace, unsigned int win_num)
+{
+ struct hfidd_window *win_p;
+ int rc = 0;
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "close_window_internal: win_num=0x%x\n", win_num);
+
+ if ((win_num < min_hfi_windows(p_acs)) ||
+ (win_num >= max_hfi_windows(p_acs))) {
+ rc = -EINVAL;
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "close_window_internal: window too large - "
+ "0x%x rc = 0x%x\n", win_num, rc);
+ goto hfidd_close_window_internal_err0;
+ }
+
+ win_p = hfi_window(p_acs, win_num);
+ if (win_p == NULL) {
+ rc = -ENOENT;
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "close_window_internal: win_p is NULL rc=0x%x\n", rc);
+ goto hfidd_close_window_internal_err0;
+ }
+
+ spin_lock(&(win_p->win_lock));
+
+ /* Make sure state is open or error state. */
+ if ((win_p->state != WIN_OPENED) &&
+ (win_p->state != WIN_SUSPENDED) &&
+ (win_p->state != WIN_ERROR) &&
+ (win_p->state != WIN_HERROR)) {
+ rc = -EFAULT;
+ spin_unlock(&(win_p->win_lock));
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_close_window_internal: bad window state=0x%x, "
+ "rc = 0x%x\n", win_p->state, rc);
+ goto hfidd_close_window_internal_err0;
+ }
+ spin_unlock(&(win_p->win_lock));
+
+ rc = hfi_unmap_mmio_regs(p_acs, win_p, is_userspace);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_close_window_internal: hfi_unmap_mmio_regs "
+ "failed, rc = 0x%x\n", rc);
+ goto hfidd_close_window_internal_err0;
+ }
+
+ hfi_destroy_window_info(p_acs, win_p);
+
+ /* Call hcall to unregister MR in the MMU */
+ rc = hfi_takedown_window_in_MMU(p_acs, is_userspace, win_p);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_close_window_internal: hfi_takedown_window_in_MMU "
+ "failed, rc = 0x%x\n", rc);
+ goto hfidd_close_window_internal_err0;
+ }
+
+ hfi_free_win_resource(p_acs, is_userspace, win_p,
+ &(win_p->client_info));
+
+ spin_lock(&win_p->win_lock);
+ /* Update the window information */
+ hfi_restore_window_parm(p_acs, win_p);
+ spin_unlock(&win_p->win_lock);
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "close_window_internal: type=0x%x state=0x%x JobID=0x%x\n",
+ win_p->type, win_p->state, win_p->job_id);
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "close_window_internal: rc=0x%x\n", rc);
+ return rc;
+
+hfidd_close_window_internal_err0:
+ return rc;
+}
+
+/*
+ * This function is called by the kernel users directly or a write
+ * system call by the kernel users. It will call hfidd_close_window_internal
+ * to close a specific window.
+ */
+int hfidd_close_window_func(struct hfidd_acs *p_acs, unsigned int is_userspace,
+ struct hfi_window_info *user_p)
+{
+ unsigned int win_num;
+ int rc = 0;
+ struct hfi_window_info win_info;
+
+ /* Copy in win num from user */
+ rc = hfi_copy_from_user(&win_info, user_p,
+ is_userspace, sizeof(struct hfi_window_info));
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_close_window_func: hfi_copy_from_user "
+ "failed, rc = 0x%x\n", rc);
+ return rc;
+ }
+
+ win_num = win_info.window;
+
+ rc = hfidd_close_window_internal(p_acs, is_userspace, win_num);
+ if (rc) {
+ rc = -EINVAL;
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_close_window_func: close_window_internal "
+ "failed, win=0x%x rc=0x%x\n", win_num, rc);
+ return rc;
+ }
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "close_window_func: rc=0x%x\n", rc);
+ return rc;
+}
+EXPORT_SYMBOL_GPL(hfidd_close_window_func);
diff --git a/include/linux/hfi/hfidd_client.h b/include/linux/hfi/hfidd_client.h
index 7e4c1a7..11c8973 100644
--- a/include/linux/hfi/hfidd_client.h
+++ b/include/linux/hfi/hfidd_client.h
@@ -113,6 +113,14 @@ struct hfi_client_info {
struct hfi_64b mmio_regs; /* Output */
};
+/*
+ * HFIDD_REQ_CLOSE_WINDOW: close window
+ */
+struct hfi_window_info {
+ struct hfi_req_hdr hdr;
+ unsigned int window;
+};
+
#define MAX_TORRENTS 1
#define MAX_HFI_PER_TORRENT 2
#define MAX_HFIS (MAX_TORRENTS * MAX_HFI_PER_TORRENT)
diff --git a/include/linux/hfi/hfidd_hcalls.h b/include/linux/hfi/hfidd_hcalls.h
index 1e007c5..777de8f 100644
--- a/include/linux/hfi/hfidd_hcalls.h
+++ b/include/linux/hfi/hfidd_hcalls.h
@@ -40,6 +40,7 @@
#define H_HFI_QUERY_INTERFACE 0xF004
#define H_HFI_STOP_INTERFACE 0xF008
#define H_HFI_OPEN_WINDOW 0xF00C
+#define H_HFI_CLOSE_WINDOW 0xF014
#define H_NMMU_START 0xF028
#define H_NMMU_STOP 0xF02C
#define H_NMMU_ALLOCATE_RESOURCE 0xF030
diff --git a/include/linux/hfi/hfidd_requests.h b/include/linux/hfi/hfidd_requests.h
index 4f1c74d..a7a38da 100644
--- a/include/linux/hfi/hfidd_requests.h
+++ b/include/linux/hfi/hfidd_requests.h
@@ -35,5 +35,6 @@
#define HFIDD_REQ_OPEN_WINDOW 0x00000a01
#define HFIDD_REQ_QUERY_DD_INFO 0x00001004
+#define HFIDD_REQ_CLOSE_WINDOW 0x00000a02
#endif /* _HFIDD_REQUESTS_H_ */
--
1.7.3.5
^ permalink raw reply related
* [PATCH v3 04/27] HFI: Find HFI devices in the device tree
From: dykmanj @ 2011-04-21 21:38 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303421937-2325-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/hfidd_adpt.c | 10 +++
drivers/net/hfi/core/hfidd_init.c | 108 ++++++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_proto.h | 1 +
include/linux/hfi/hfidd_adpt.h | 5 ++
include/linux/hfi/hfidd_client.h | 3 +
include/linux/hfi/hfidd_internal.h | 12 ++++
6 files changed, 139 insertions(+), 0 deletions(-)
diff --git a/drivers/net/hfi/core/hfidd_adpt.c b/drivers/net/hfi/core/hfidd_adpt.c
index ec6a053..f309a02 100644
--- a/drivers/net/hfi/core/hfidd_adpt.c
+++ b/drivers/net/hfi/core/hfidd_adpt.c
@@ -36,6 +36,7 @@
int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t devno, void *uiop)
{
+ int ret = 0;
struct hfidd_acs *p_acs = NULL;
p_acs = kzalloc(sizeof(*p_acs), GFP_KERNEL);
@@ -48,8 +49,17 @@ int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t devno, void *uiop)
snprintf(p_acs->name, HFI_DEVICE_NAME_MAX,
"%s%d", HFIDD_DEV_NAME, p_acs->index);
+ ret = hfidd_init_adapter(p_acs, uiop);
+ if (ret)
+ goto err_exit0;
+
*adpt = p_acs;
return 0;
+
+err_exit0:
+ kfree(p_acs);
+ p_acs = NULL;
+ return ret;
}
void hfidd_free_adapter(struct hfidd_acs *p_acs)
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
index 40d5aaf..d181d97 100644
--- a/drivers/net/hfi/core/hfidd_init.c
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -33,6 +33,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/device.h>
+#include <linux/of.h>
#include <linux/hfi/hfidd_internal.h>
#include "hfidd_proto.h"
@@ -103,6 +104,113 @@ static void hfidd_rmdev(int ai)
device_destroy(hfidd_global.class, MKDEV(MAJOR(hfidd_dev), ai));
}
+/*
+ * Read the hfi device tree attributes and
+ * fill the hfidd_dds structure to be used by the driver
+ */
+static int hfidd_dds_init(struct hfidd_acs *p_acs, struct hfidd_dds *pdds)
+{
+ struct device_node *node;
+ struct device_node *child_node = NULL;
+ unsigned long long *lp;
+ int *p;
+ unsigned char octant;
+ unsigned char id;
+ int found = 0;
+
+ node = of_find_node_by_name(NULL, "hfi-iohub");
+ if (!node) {
+ printk(KERN_ERR "%s: hfidd_dds_init: of_find_node_by_name"
+ " 'hfi-iohub' failed\n", p_acs->name);
+ return -EINVAL;
+ }
+
+ lp = (unsigned long long *)of_get_property(node, "reg", NULL);
+ if (!lp) {
+ printk(KERN_ERR "%s: hfidd_dds_init: of_get_property"
+ " 'hfi-iohub/reg' failed\n", p_acs->name);
+ return -EINVAL;
+ }
+ pdds->torr_id = *lp;
+
+ lp = (unsigned long long *)of_get_property(node,
+ "ibm,fw-ec-level", NULL);
+ if (!lp) {
+ printk(KERN_ERR "%s: hfidd_dds_init: of_get_property"
+ " 'ibm,fw-ec-level' failed\n", p_acs->name);
+ return -EINVAL;
+ }
+ pdds->fw_ec_level = *lp;
+
+ octant = (node->full_name[strlen(node->full_name) - 1] - '0');
+ if (octant > HFI_MAX_OCTANT) {
+ printk(KERN_ERR "%s: hfidd_dds_init: invalid hfi-iohub octant"
+ " '%s'\n", node->full_name, p_acs->name);
+ return -EINVAL;
+ }
+
+ id = ((octant << HFI_SHIFT_OCTANT) | p_acs->index);
+
+ while ((child_node = of_get_next_child(node, child_node))) {
+ p = (int *)of_get_property(child_node, "reg", NULL);
+ if (!p) {
+ printk(KERN_ERR "%s: hfidd_dds_init: of_get_property "
+ "'reg' failed\n", p_acs->name);
+ return -EINVAL;
+ }
+
+ if (id == *p) {
+ pdds->hfi_id = *p;
+ found = 1;
+ break;
+ }
+ }
+
+ if (found == 0) {
+ printk(KERN_ERR "%s: hfidd_dds_init: can not find child\n",
+ p_acs->name);
+ return -EINVAL;
+ }
+
+ lp = (unsigned long long *)of_get_property(child_node,
+ "ibm,hfi-windows", NULL);
+ if (!lp) {
+ printk(KERN_ERR "%s: hfidd_dds_init: of_get_property"
+ " 'ibm,hfi-windows' failed\n", p_acs->name);
+ return -EINVAL;
+ }
+
+ pdds->window_num = (int) (*lp >> HFI_WNUM_SHIFT);
+ pdds->window_start = (int) *lp;
+
+ if (pdds->window_num > MAX_WIN_PER_HFI) {
+ printk(KERN_ERR "%s: hfidd_dds_init: Max windows exceeded,"
+ " windows=%d\n", p_acs->name, pdds->window_num);
+ return -EINVAL;
+ }
+
+ lp = (unsigned long long *)of_get_property(child_node,
+ "ibm,hfi-misc-user-base-addr", NULL);
+ if (!lp) {
+ printk(KERN_ERR "%s: hfidd_dds_init: of_get_property"
+ " 'ibm,hfi-misc-user-base-addr' failed\n", p_acs->name);
+ return -EINVAL;
+ }
+ pdds->misc_base_address = *lp;
+
+ return 0;
+}
+
+/* Initialize adapter structure */
+int hfidd_init_adapter(struct hfidd_acs *p_acs, void *uiop)
+{
+ int rc = 0;
+
+ rc = hfidd_dds_init(p_acs, &(p_acs->dds));
+ p_acs->dds.num_d_windows = HFI_DYN_WINS_DEFAULT;
+ return rc;
+}
+
/* Destroy the HFI class */
static inline void hfidd_destroy_class(void)
{
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
index 01a5ba2..e2ed4c9 100644
--- a/drivers/net/hfi/core/hfidd_proto.h
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -35,5 +35,6 @@
int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t, void *uiop);
void hfidd_free_adapter(struct hfidd_acs *p_acs);
+int hfidd_init_adapter(struct hfidd_acs *p_acs, void *uiop);
#endif
diff --git a/include/linux/hfi/hfidd_adpt.h b/include/linux/hfi/hfidd_adpt.h
index 6b1432d..e3271e9 100644
--- a/include/linux/hfi/hfidd_adpt.h
+++ b/include/linux/hfi/hfidd_adpt.h
@@ -36,6 +36,11 @@
#include <linux/hfi/hfidd_client.h>
+#define HFI_WNUM_SHIFT 32
+#define HFI_CAUNUM_SHIFT 32
+#define HFI_SHIFT_OCTANT 3
+#define HFI_MAX_OCTANT 7
+
/* Adpt state */
#define HFI_INVALID 0
#define HFI_AVAIL 1
diff --git a/include/linux/hfi/hfidd_client.h b/include/linux/hfi/hfidd_client.h
index b738f4b..28f1693 100644
--- a/include/linux/hfi/hfidd_client.h
+++ b/include/linux/hfi/hfidd_client.h
@@ -36,5 +36,8 @@
#define MAX_TORRENTS 1
#define MAX_HFI_PER_TORRENT 2
#define MAX_HFIS (MAX_TORRENTS * MAX_HFI_PER_TORRENT)
+#define MAX_WIN_PER_HFI 256
+
+#define HFI_DYN_WINS_DEFAULT 32
#endif /* _HFIDD_CLIENT_H_ */
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index 956e6b2..78a5763 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -46,6 +46,17 @@
#define HFIDD_DEV_NAME "hfi"
#define HFIDD_CLASS_NAME "hfi"
+struct hfidd_dds {
+ unsigned int version; /* HFI adapter type */
+ unsigned long long misc_base_address; /* Misc user base address */
+ int window_start; /* window start for this HFI */
+ int window_num; /* window count for this HFI */
+ unsigned int num_d_windows; /* number of dynamic windows */
+ unsigned long long torr_id; /* torrent chip id */
+ unsigned int hfi_id; /* HFI Unit Id */
+ unsigned long long fw_ec_level; /* Firmware Level */
+};
+
#define HFI_DEVICE_NAME_MAX 8
/* hfi global */
struct hfidd_acs {
@@ -55,6 +66,7 @@ struct hfidd_acs {
unsigned int acs_cnt;
unsigned int state;
struct device *hfidd_dev;
+ struct hfidd_dds dds;
};
/* DD global */
--
1.7.3.5
^ permalink raw reply related
* Strange igb bug, out-of-tree driver seems to work fine.
From: Ben Greear @ 2011-04-21 21:39 UTC (permalink / raw)
To: netdev
We have a 4-port NIC using the igb driver in a couple of systems,
and saw some strange issues (mostly rx CRC errors). We tried 2.6.34,
2.6.36, and 2.6.38 based kernels and all showed issues. The NICs
are from two different vendors, though both use the igb driver.
We then tried 2.6.36.3 with the out-of-tree igb-2.4.13.tar.gz
driver. And everything seems to run clean.
My kernels are somewhat hacked and tainted, and this testing
is using my tainting module, but since changing only the driver
seems to fix things, it's _probably_ not my fault this time!
I am running a small hack to make igb work better with VLANs
in my 2.6.36 and .38 kernel, though not in the .34. Here is the .36 diff:
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 9b4e589..86aa89c 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -2265,7 +2265,8 @@ static int __devinit igb_sw_init(struct igb_adapter *adapter)
adapter->rx_itr_setting = IGB_DEFAULT_ITR;
adapter->tx_itr_setting = IGB_DEFAULT_ITR;
- adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
+ adapter->max_frame_size = (netdev->mtu + ETH_HLEN + ETH_FCS_LEN
+ + VLAN_HLEN);
adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
#ifdef CONFIG_PCI_IOV
@@ -4230,7 +4231,7 @@ static int igb_change_mtu(struct net_device *netdev, int new_mtu)
{
struct igb_adapter *adapter = netdev_priv(netdev);
struct pci_dev *pdev = adapter->pdev;
- int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
+ int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
u32 rx_buffer_len, i;
if ((new_mtu < 68) || (max_frame > MAX_JUMBO_FRAME_SIZE)) {
Verbose lspci output for this system is below.
00:00.0 Host bridge: Intel Corporation Mobile 945GM/PM/GMS, 943/940GML and 945GT Express Memory Controller Hub (rev 03)
Subsystem: Intel Corporation Mobile 945GM/PM/GMS, 943/940GML and 945GT Express Memory Controller Hub
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort+ >SERR- <PERR- INTx-
Latency: 0
Capabilities: [e0] Vendor Specific Information: Len=09 <?>
Kernel driver in use: agpgart-intel
00:01.0 PCI bridge: Intel Corporation Mobile 945GM/PM/GMS, 943/940GML and 945GT Express PCI Express Root Port (rev 03) (prog-if 00 [Normal decode])
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Bus: primary=00, secondary=01, subordinate=06, sec-latency=0
I/O behind bridge: 00008000-0000bfff
Memory behind bridge: fd400000-fd8fffff
Prefetchable memory behind bridge: 00000000fcf00000-00000000fd2fffff
Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [88] Subsystem: Intel Corporation Device 0000
Capabilities: [80] Power Management version 2
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
Address: fee0300c Data: 4159
Capabilities: [a0] Express (v1) Root Port (Slot+), MSI 00
DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- RBE- FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #2, Speed 2.5GT/s, Width x16, ASPM L0s L1, Latency L0 <1us, L1 <4us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x4, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
SltCap: AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug- Surprise-
Slot #0, PowerLimit 0.000W; Interlock- NoCompl-
SltCtl: Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
Control: AttnInd Off, PwrInd On, Power- Interlock-
SltSta: Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet+ Interlock-
Changed: MRL- PresDet+ LinkState-
RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal- PMEIntEna- CRSVisible-
RootCap: CRSVisible-
RootSta: PME ReqID 0000, PMEStatus- PMEPending-
Capabilities: [100 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed+ WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=01
Status: NegoPending- InProgress-
Capabilities: [140 v1] Root Complex Link
Desc: PortNumber=02 ComponentID=00 EltType=Config
Link0: Desc: TargetPort=00 TargetComponent=00 AssocRCRB- LinkType=MemMapped LinkValid+
Addr: 00000000fed19000
Kernel driver in use: pcieport
00:02.0 VGA compatible controller: Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller (rev 03) (prog-if 00 [VGA controller])
Subsystem: Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Interrupt: pin A routed to IRQ 16
Region 0: Memory at fdf00000 (32-bit, non-prefetchable) [size=512K]
Region 1: I/O ports at ff00 [size=8]
Region 2: Memory at b0000000 (32-bit, prefetchable) [size=256M]
Region 3: Memory at fdf80000 (32-bit, non-prefetchable) [size=256K]
Expansion ROM at <unassigned> [disabled]
Capabilities: [90] MSI: Enable- Count=1/1 Maskable- 64bit-
Address: 00000000 Data: 0000
Capabilities: [d0] Power Management version 2
Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Kernel driver in use: i915
Kernel modules: intelfb, i915
00:1c.0 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 1 (rev 02) (prog-if 00 [Normal decode])
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Bus: primary=00, secondary=07, subordinate=07, sec-latency=0
I/O behind bridge: 00007000-00007fff
Memory behind bridge: fce00000-fcefffff
Prefetchable memory behind bridge: 00000000fcd00000-00000000fcdfffff
Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [40] Express (v1) Root Port (Slot+), MSI 00
DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s unlimited, L1 unlimited
ExtTag- RBE- FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal+ Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
LnkCap: Port #1, Speed 2.5GT/s, Width x1, ASPM L0s L1, Latency L0 <256ns, L1 <4us
ClockPM- Surprise- LLActRep+ BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive+ BWMgmt- ABWMgmt-
SltCap: AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug+ Surprise+
Slot #16, PowerLimit 10.000W; Interlock- NoCompl-
SltCtl: Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
Control: AttnInd Unknown, PwrInd Unknown, Power- Interlock-
SltSta: Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet+ Interlock-
Changed: MRL- PresDet+ LinkState+
RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal+ PMEIntEna- CRSVisible-
RootCap: CRSVisible-
RootSta: PME ReqID 0000, PMEStatus- PMEPending-
Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
Address: fee0300c Data: 4161
Capabilities: [90] Subsystem: Intel Corporation N10/ICH 7 Family PCI Express Port 1
Capabilities: [a0] Power Management version 2
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [100 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed+ WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed+ WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=01
Status: NegoPending- InProgress-
VC1: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed+ WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable- ID=0 ArbSelect=Fixed TC/VC=00
Status: NegoPending- InProgress-
Capabilities: [180 v1] Root Complex Link
Desc: PortNumber=01 ComponentID=02 EltType=Config
Link0: Desc: TargetPort=00 TargetComponent=02 AssocRCRB- LinkType=MemMapped LinkValid+
Addr: 00000000fed1c001
Kernel driver in use: pcieport
00:1c.1 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 2 (rev 02) (prog-if 00 [Normal decode])
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Bus: primary=00, secondary=08, subordinate=08, sec-latency=0
I/O behind bridge: 00006000-00006fff
Memory behind bridge: fde00000-fdefffff
Prefetchable memory behind bridge: 00000000fdd00000-00000000fddfffff
Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [40] Express (v1) Root Port (Slot+), MSI 00
DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s unlimited, L1 unlimited
ExtTag- RBE- FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal+ Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
LnkCap: Port #2, Speed 2.5GT/s, Width x1, ASPM L0s L1, Latency L0 <256ns, L1 <4us
ClockPM- Surprise- LLActRep+ BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive+ BWMgmt- ABWMgmt-
SltCap: AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug+ Surprise+
Slot #17, PowerLimit 10.000W; Interlock- NoCompl-
SltCtl: Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
Control: AttnInd Unknown, PwrInd Unknown, Power- Interlock-
SltSta: Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet+ Interlock-
Changed: MRL- PresDet+ LinkState+
RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal+ PMEIntEna- CRSVisible-
RootCap: CRSVisible-
RootSta: PME ReqID 0000, PMEStatus- PMEPending-
Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
Address: fee0300c Data: 4169
Capabilities: [90] Subsystem: Intel Corporation N10/ICH 7 Family PCI Express Port 2
Capabilities: [a0] Power Management version 2
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [100 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed+ WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed+ WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=01
Status: NegoPending- InProgress-
VC1: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed+ WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable- ID=0 ArbSelect=Fixed TC/VC=00
Status: NegoPending- InProgress-
Capabilities: [180 v1] Root Complex Link
Desc: PortNumber=02 ComponentID=02 EltType=Config
Link0: Desc: TargetPort=00 TargetComponent=02 AssocRCRB- LinkType=MemMapped LinkValid+
Addr: 00000000fed1c001
Kernel driver in use: pcieport
00:1c.2 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 3 (rev 02) (prog-if 00 [Normal decode])
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Bus: primary=00, secondary=09, subordinate=09, sec-latency=0
I/O behind bridge: 00005000-00005fff
Memory behind bridge: fdc00000-fdcfffff
Prefetchable memory behind bridge: 00000000fdb00000-00000000fdbfffff
Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort+ <SERR- <PERR-
BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [40] Express (v1) Root Port (Slot+), MSI 00
DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s unlimited, L1 unlimited
ExtTag- RBE- FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal+ Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
LnkCap: Port #3, Speed 2.5GT/s, Width x1, ASPM L0s L1, Latency L0 <1us, L1 <4us
ClockPM- Surprise- LLActRep+ BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x0, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
SltCap: AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug+ Surprise+
Slot #18, PowerLimit 10.000W; Interlock- NoCompl-
SltCtl: Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
Control: AttnInd Unknown, PwrInd Unknown, Power- Interlock-
SltSta: Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet- Interlock-
Changed: MRL- PresDet- LinkState-
RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal+ PMEIntEna- CRSVisible-
RootCap: CRSVisible-
RootSta: PME ReqID 0000, PMEStatus- PMEPending-
Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
Address: fee0300c Data: 4171
Capabilities: [90] Subsystem: Intel Corporation N10/ICH 7 Family PCI Express Port 3
Capabilities: [a0] Power Management version 2
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [100 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed+ WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed+ WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=01
Status: NegoPending- InProgress-
VC1: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed+ WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable- ID=0 ArbSelect=Fixed TC/VC=00
Status: NegoPending- InProgress-
Capabilities: [180 v1] Root Complex Link
Desc: PortNumber=03 ComponentID=02 EltType=Config
Link0: Desc: TargetPort=00 TargetComponent=02 AssocRCRB- LinkType=MemMapped LinkValid+
Addr: 00000000fed1c001
Kernel driver in use: pcieport
00:1c.3 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 4 (rev 02) (prog-if 00 [Normal decode])
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Bus: primary=00, secondary=0a, subordinate=0a, sec-latency=0
I/O behind bridge: 0000c000-0000cfff
Memory behind bridge: fda00000-fdafffff
Prefetchable memory behind bridge: 00000000fd900000-00000000fd9fffff
Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [40] Express (v1) Root Port (Slot+), MSI 00
DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s unlimited, L1 unlimited
ExtTag- RBE- FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal+ Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
LnkCap: Port #4, Speed 2.5GT/s, Width x1, ASPM L0s L1, Latency L0 <1us, L1 <4us
ClockPM- Surprise- LLActRep+ BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x0, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
SltCap: AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug+ Surprise+
Slot #19, PowerLimit 10.000W; Interlock- NoCompl-
SltCtl: Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
Control: AttnInd Unknown, PwrInd Unknown, Power- Interlock-
SltSta: Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet- Interlock-
Changed: MRL- PresDet- LinkState-
RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal+ PMEIntEna- CRSVisible-
RootCap: CRSVisible-
RootSta: PME ReqID 0000, PMEStatus- PMEPending-
Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
Address: fee0300c Data: 4179
Capabilities: [90] Subsystem: Intel Corporation N10/ICH 7 Family PCI Express Port 4
Capabilities: [a0] Power Management version 2
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [100 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed+ WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed+ WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=01
Status: NegoPending- InProgress-
VC1: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed+ WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable- ID=0 ArbSelect=Fixed TC/VC=00
Status: NegoPending- InProgress-
Capabilities: [180 v1] Root Complex Link
Desc: PortNumber=04 ComponentID=02 EltType=Config
Link0: Desc: TargetPort=00 TargetComponent=02 AssocRCRB- LinkType=MemMapped LinkValid+
Addr: 00000000fed1c001
Kernel driver in use: pcieport
00:1d.0 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #1 (rev 02) (prog-if 00 [UHCI])
Subsystem: Intel Corporation N10/ICH 7 Family USB UHCI Controller #1
Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Interrupt: pin A routed to IRQ 23
Region 4: I/O ports at fe00 [size=32]
Kernel driver in use: uhci_hcd
00:1d.1 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #2 (rev 02) (prog-if 00 [UHCI])
Subsystem: Intel Corporation N10/ICH 7 Family USB UHCI Controller #2
Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Interrupt: pin B routed to IRQ 19
Region 4: I/O ports at fd00 [size=32]
Kernel driver in use: uhci_hcd
00:1d.2 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #3 (rev 02) (prog-if 00 [UHCI])
Subsystem: Intel Corporation N10/ICH 7 Family USB UHCI Controller #3
Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Interrupt: pin C routed to IRQ 18
Region 4: I/O ports at fc00 [size=32]
Kernel driver in use: uhci_hcd
00:1d.3 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #4 (rev 02) (prog-if 00 [UHCI])
Subsystem: Intel Corporation Device 27ca
Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Interrupt: pin D routed to IRQ 16
Region 4: I/O ports at fb00 [size=32]
Kernel driver in use: uhci_hcd
00:1d.7 USB Controller: Intel Corporation N10/ICH 7 Family USB2 EHCI Controller (rev 02) (prog-if 20 [EHCI])
Subsystem: Intel Corporation N10/ICH 7 Family USB2 EHCI Controller
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Interrupt: pin A routed to IRQ 23
Region 0: Memory at fdfff000 (32-bit, non-prefetchable) [size=1K]
Capabilities: [50] Power Management version 2
Flags: PMEClk- DSI- D1- D2- AuxCurrent=375mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Kernel driver in use: ehci_hcd
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev e2) (prog-if 01 [Subtractive decode])
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Bus: primary=00, secondary=0b, subordinate=10, sec-latency=32
I/O behind bridge: 0000d000-0000dfff
Memory behind bridge: cc000000-d7ffffff
Prefetchable memory behind bridge: 00000000fd300000-00000000fd3fffff
Secondary status: 66MHz- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort+ <SERR- <PERR-
BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [50] Subsystem: Intel Corporation 82801 Mobile PCI Bridge
00:1e.2 Multimedia audio controller: Intel Corporation 82801G (ICH7 Family) AC'97 Audio Controller (rev 02)
Subsystem: Device 414c:4760
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Interrupt: pin A routed to IRQ 17
Region 0: I/O ports at f000 [size=256]
Region 1: I/O ports at fa00 [size=64]
Region 2: Memory at fdffe000 (32-bit, non-prefetchable) [size=512]
Region 3: Memory at fdffd000 (32-bit, non-prefetchable) [size=256]
Capabilities: [50] Power Management version 2
Flags: PMEClk- DSI- D1- D2- AuxCurrent=375mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Kernel driver in use: Intel ICH
Kernel modules: snd-intel8x0
00:1f.0 ISA bridge: Intel Corporation 82801GBM (ICH7-M) LPC Interface Bridge (rev 02)
Subsystem: Intel Corporation 82801GBM (ICH7-M) LPC Interface Bridge
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Capabilities: [e0] Vendor Specific Information: Len=0c <?>
Kernel modules: leds-ss4200, iTCO_wdt, intel-rng
00:1f.1 IDE interface: Intel Corporation 82801G (ICH7 Family) IDE Controller (rev 02) (prog-if 8a [Master SecP PriP])
Subsystem: Intel Corporation 82801G (ICH7 Family) IDE Controller
Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx+
Latency: 0
Interrupt: pin A routed to IRQ 18
Region 0: I/O ports at 01f0 [size=8]
Region 1: I/O ports at 03f4 [size=1]
Region 2: I/O ports at 0170 [size=8]
Region 3: I/O ports at 0374 [size=1]
Region 4: I/O ports at f800 [size=16]
Kernel driver in use: ata_piix
00:1f.2 IDE interface: Intel Corporation 82801GBM/GHM (ICH7 Family) SATA IDE Controller (rev 02) (prog-if 8f [Master SecP SecO PriP PriO])
Subsystem: Intel Corporation 82801GBM/GHM (ICH7 Family) SATA IDE Controller
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Interrupt: pin B routed to IRQ 19
Region 0: I/O ports at f700 [size=8]
Region 1: I/O ports at f600 [size=4]
Region 2: I/O ports at f500 [size=8]
Region 3: I/O ports at f400 [size=4]
Region 4: I/O ports at f300 [size=16]
Region 5: Memory at fdffc000 (32-bit, non-prefetchable) [size=1K]
Capabilities: [70] Power Management version 2
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot+,D3cold-)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Kernel driver in use: ata_piix
00:1f.3 SMBus: Intel Corporation N10/ICH 7 Family SMBus Controller (rev 02)
Subsystem: Intel Corporation N10/ICH 7 Family SMBus Controller
Control: I/O+ Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Interrupt: pin B routed to IRQ 19
Region 4: I/O ports at 0500 [size=32]
Kernel driver in use: i801_smbus
Kernel modules: i2c-i801
01:00.0 PCI bridge: PLX Technology, Inc. PEX 8616 16-lane, 4-Port PCI Express Gen 2 (5.0 GT/s) Switch (rev bb) (prog-if 00 [Normal decode])
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Region 0: Memory at fd8e0000 (32-bit, non-prefetchable) [size=128K]
Bus: primary=01, secondary=02, subordinate=06, sec-latency=0
I/O behind bridge: 00008000-0000bfff
Memory behind bridge: fd400000-fd7fffff
Prefetchable memory behind bridge: 00000000fcf00000-00000000fd2fffff
Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [48] MSI: Enable+ Count=1/4 Maskable+ 64bit+
Address: 00000000fee0300c Data: 4181
Masking: 0000000f Pending: 00000000
Capabilities: [68] Express (v2) Upstream Port, MSI 00
DevCap: MaxPayload 2048 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset-SlotPowerLimit 0.000W
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr- TransPend-
LnkCap: Port #6, Speed 5GT/s, Width x4, ASPM L0s L1, Latency L0 <2us, L1 <4us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x4, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Not Supported, TimeoutDis-
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-
LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB
Capabilities: [a4] Subsystem: PLX Technology, Inc. PEX 8616 16-lane, 4-Port PCI Express Gen 2 (5.0 GT/s) Switch
Capabilities: [100 v1] Device Serial Number aa-86-00-10-b5-df-0e-00
Capabilities: [fb4 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 1f, GenCap+ CGenEn- ChkCap+ ChkEn-
Capabilities: [138 v1] Power Budgeting <?>
Capabilities: [148 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed- WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed+ WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=ff
Status: NegoPending- InProgress-
Capabilities: [950 v1] Vendor Specific Information: ID=0001 Rev=0 Len=010 <?>
Kernel driver in use: pcieport
02:00.0 PCI bridge: PLX Technology, Inc. PEX 8616 16-lane, 4-Port PCI Express Gen 2 (5.0 GT/s) Switch (rev bb) (prog-if 00 [Normal decode])
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Bus: primary=02, secondary=03, subordinate=03, sec-latency=0
I/O behind bridge: 0000b000-0000bfff
Memory behind bridge: fd700000-fd7fffff
Prefetchable memory behind bridge: 00000000fd200000-00000000fd2fffff
Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [48] MSI: Enable+ Count=1/4 Maskable+ 64bit+
Address: 00000000fee0300c Data: 4189
Masking: 0000000f Pending: 00000000
Capabilities: [68] Express (v2) Downstream Port (Slot+), MSI 00
DevCap: MaxPayload 2048 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- RBE+ FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr- TransPend-
LnkCap: Port #0, Speed 5GT/s, Width x4, ASPM L0s L1, Latency L0 <2us, L1 <4us
ClockPM- Surprise+ LLActRep+ BwNot+
LnkCtl: ASPM Disabled; Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x4, TrErr- Train- SlotClk- DLActive+ BWMgmt+ ABWMgmt-
SltCap: AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug- Surprise-
Slot #0, PowerLimit 25.000W; Interlock- NoCompl-
SltCtl: Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
Control: AttnInd Unknown, PwrInd Unknown, Power- Interlock-
SltSta: Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet+ Interlock-
Changed: MRL- PresDet+ LinkState+
DevCap2: Completion Timeout: Not Supported, TimeoutDis- ARIFwd+
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- ARIFwd+
LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB
Capabilities: [a4] Subsystem: PLX Technology, Inc. PEX 8616 16-lane, 4-Port PCI Express Gen 2 (5.0 GT/s) Switch
Capabilities: [100 v1] Device Serial Number aa-86-00-10-b5-df-0e-00
Capabilities: [fb4 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 1f, GenCap+ CGenEn- ChkCap+ ChkEn-
Capabilities: [148 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=4
Arb: Fixed- WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=06 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed- WRR32+ WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=WRR32 TC/VC=ff
Status: NegoPending- InProgress-
Port Arbitration Table <?>
Capabilities: [448 v1] Vendor Specific Information: ID=0000 Rev=0 Len=0cc <?>
Capabilities: [520 v1] Access Control Services
ACSCap: SrcValid+ TransBlk+ ReqRedir+ CmpltRedir+ UpstreamFwd+ EgressCtrl+ DirectTrans+
ACSCtl: SrcValid- TransBlk- ReqRedir- CmpltRedir- UpstreamFwd- EgressCtrl- DirectTrans-
Capabilities: [950 v1] Vendor Specific Information: ID=0001 Rev=0 Len=010 <?>
Kernel driver in use: pcieport
02:01.0 PCI bridge: PLX Technology, Inc. PEX 8616 16-lane, 4-Port PCI Express Gen 2 (5.0 GT/s) Switch (rev bb) (prog-if 00 [Normal decode])
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Bus: primary=02, secondary=04, subordinate=04, sec-latency=0
I/O behind bridge: 0000a000-0000afff
Memory behind bridge: fd600000-fd6fffff
Prefetchable memory behind bridge: 00000000fd100000-00000000fd1fffff
Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [48] MSI: Enable+ Count=1/4 Maskable+ 64bit+
Address: 00000000fee0300c Data: 4191
Masking: 0000000f Pending: 00000000
Capabilities: [68] Express (v2) Downstream Port (Slot+), MSI 00
DevCap: MaxPayload 2048 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- RBE+ FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr- TransPend-
LnkCap: Port #1, Speed 5GT/s, Width x4, ASPM L0s L1, Latency L0 <2us, L1 <4us
ClockPM- Surprise+ LLActRep+ BwNot+
LnkCtl: ASPM Disabled; Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x4, TrErr- Train- SlotClk- DLActive+ BWMgmt+ ABWMgmt-
SltCap: AttnBtn+ PwrCtrl+ MRL+ AttnInd+ PwrInd+ HotPlug+ Surprise-
Slot #1, PowerLimit 25.000W; Interlock- NoCompl-
SltCtl: Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
Control: AttnInd Unknown, PwrInd Unknown, Power+ Interlock-
SltSta: Status: AttnBtn- PowerFlt- MRL+ CmdCplt- PresDet+ Interlock-
Changed: MRL- PresDet+ LinkState+
DevCap2: Completion Timeout: Not Supported, TimeoutDis- ARIFwd+
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- ARIFwd+
LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB
Capabilities: [a4] Subsystem: PLX Technology, Inc. PEX 8616 16-lane, 4-Port PCI Express Gen 2 (5.0 GT/s) Switch
Capabilities: [100 v1] Device Serial Number aa-86-00-10-b5-df-0e-00
Capabilities: [fb4 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 1f, GenCap+ CGenEn- ChkCap+ ChkEn-
Capabilities: [148 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed- WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed+ WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=ff
Status: NegoPending- InProgress-
Capabilities: [520 v1] Access Control Services
ACSCap: SrcValid+ TransBlk+ ReqRedir+ CmpltRedir+ UpstreamFwd+ EgressCtrl+ DirectTrans+
ACSCtl: SrcValid- TransBlk- ReqRedir- CmpltRedir- UpstreamFwd- EgressCtrl- DirectTrans-
Capabilities: [950 v1] Vendor Specific Information: ID=0001 Rev=0 Len=010 <?>
Kernel driver in use: pcieport
02:04.0 PCI bridge: PLX Technology, Inc. PEX 8616 16-lane, 4-Port PCI Express Gen 2 (5.0 GT/s) Switch (rev bb) (prog-if 00 [Normal decode])
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Bus: primary=02, secondary=05, subordinate=05, sec-latency=0
I/O behind bridge: 00009000-00009fff
Memory behind bridge: fd500000-fd5fffff
Prefetchable memory behind bridge: 00000000fd000000-00000000fd0fffff
Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [48] MSI: Enable+ Count=1/4 Maskable+ 64bit+
Address: 00000000fee0300c Data: 4199
Masking: 0000000f Pending: 00000000
Capabilities: [68] Express (v2) Downstream Port (Slot+), MSI 00
DevCap: MaxPayload 2048 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- RBE+ FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr- TransPend-
LnkCap: Port #4, Speed 5GT/s, Width x8, ASPM L0s L1, Latency L0 <2us, L1 <4us
ClockPM- Surprise+ LLActRep+ BwNot+
LnkCtl: ASPM Disabled; Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x0, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
SltCap: AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug- Surprise-
Slot #4, PowerLimit 25.000W; Interlock- NoCompl-
SltCtl: Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
Control: AttnInd Unknown, PwrInd Unknown, Power- Interlock-
SltSta: Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet- Interlock-
Changed: MRL- PresDet- LinkState-
DevCap2: Completion Timeout: Not Supported, TimeoutDis- ARIFwd+
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- ARIFwd-
LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB
Capabilities: [a4] Subsystem: PLX Technology, Inc. PEX 8616 16-lane, 4-Port PCI Express Gen 2 (5.0 GT/s) Switch
Capabilities: [100 v1] Device Serial Number aa-86-00-10-b5-df-0e-00
Capabilities: [fb4 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 1f, GenCap+ CGenEn- ChkCap+ ChkEn-
Capabilities: [148 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed- WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed+ WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=ff
Status: NegoPending- InProgress-
Capabilities: [520 v1] Access Control Services
ACSCap: SrcValid+ TransBlk+ ReqRedir+ CmpltRedir+ UpstreamFwd+ EgressCtrl+ DirectTrans+
ACSCtl: SrcValid- TransBlk- ReqRedir- CmpltRedir- UpstreamFwd- EgressCtrl- DirectTrans-
Capabilities: [950 v1] Vendor Specific Information: ID=0001 Rev=0 Len=010 <?>
Kernel driver in use: pcieport
02:05.0 PCI bridge: PLX Technology, Inc. PEX 8616 16-lane, 4-Port PCI Express Gen 2 (5.0 GT/s) Switch (rev bb) (prog-if 00 [Normal decode])
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Bus: primary=02, secondary=06, subordinate=06, sec-latency=0
I/O behind bridge: 00008000-00008fff
Memory behind bridge: fd400000-fd4fffff
Prefetchable memory behind bridge: 00000000fcf00000-00000000fcffffff
Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [48] MSI: Enable+ Count=1/4 Maskable+ 64bit+
Address: 00000000fee0300c Data: 41a1
Masking: 0000000f Pending: 00000000
Capabilities: [68] Express (v2) Downstream Port (Slot+), MSI 00
DevCap: MaxPayload 2048 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- RBE+ FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr- TransPend-
LnkCap: Port #5, Speed 5GT/s, Width x4, ASPM L0s L1, Latency L0 <2us, L1 <4us
ClockPM- Surprise+ LLActRep+ BwNot+
LnkCtl: ASPM Disabled; Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x0, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
SltCap: AttnBtn+ PwrCtrl+ MRL+ AttnInd+ PwrInd+ HotPlug+ Surprise-
Slot #5, PowerLimit 25.000W; Interlock- NoCompl-
SltCtl: Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
Control: AttnInd Unknown, PwrInd Unknown, Power+ Interlock-
SltSta: Status: AttnBtn- PowerFlt- MRL+ CmdCplt- PresDet- Interlock-
Changed: MRL- PresDet- LinkState-
DevCap2: Completion Timeout: Not Supported, TimeoutDis- ARIFwd+
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- ARIFwd-
LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB
Capabilities: [a4] Subsystem: PLX Technology, Inc. PEX 8616 16-lane, 4-Port PCI Express Gen 2 (5.0 GT/s) Switch
Capabilities: [100 v1] Device Serial Number aa-86-00-10-b5-df-0e-00
Capabilities: [fb4 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 1f, GenCap+ CGenEn- ChkCap+ ChkEn-
Capabilities: [148 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed- WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed+ WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=ff
Status: NegoPending- InProgress-
Capabilities: [520 v1] Access Control Services
ACSCap: SrcValid+ TransBlk+ ReqRedir+ CmpltRedir+ UpstreamFwd+ EgressCtrl+ DirectTrans+
ACSCtl: SrcValid- TransBlk- ReqRedir- CmpltRedir- UpstreamFwd- EgressCtrl- DirectTrans-
Capabilities: [950 v1] Vendor Specific Information: ID=0001 Rev=0 Len=010 <?>
Kernel driver in use: pcieport
03:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
Subsystem: QLogic, Corp. Device 0080
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin B routed to IRQ 17
Region 0: Memory at fd7c0000 (32-bit, non-prefetchable) [size=128K]
Region 1: Memory at fd760000 (32-bit, non-prefetchable) [size=128K]
Region 2: I/O ports at bf00 [size=32]
Region 3: Memory at fd7fc000 (32-bit, non-prefetchable) [size=16K]
[virtual] Expansion ROM at fd200000 [disabled] [size=128K]
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=1 PME-
Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
Address: 0000000000000000 Data: 0000
Masking: 00000000 Pending: 00000000
Capabilities: [70] MSI-X: Enable+ Count=10 Masked-
Vector table: BAR=3 offset=00000000
PBA: BAR=3 offset=00002000
Capabilities: [a0] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 512 bytes, PhantFunc 0, Latency L0s <512ns, L1 <64us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset+
DevCtl: Report errors: Correctable+ Non-Fatal+ Fatal+ Unsupported+
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+ FLReset-
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr+ TransPend-
LnkCap: Port #0, Speed 2.5GT/s, Width x4, ASPM L0s L1, Latency L0 <4us, L1 <64us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x4, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
DevCtl2: Completion Timeout: 16ms to 55ms, TimeoutDis-
LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB
Capabilities: [100 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES- TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-
Capabilities: [140 v1] Device Serial Number 00-0c-bd-ff-ff-00-94-6c
Capabilities: [150 v1] Alternative Routing-ID Interpretation (ARI)
ARICap: MFVC- ACS-, Next Function: 1
ARICtl: MFVC- ACS-, Function Group: 0
Capabilities: [160 v1] Single Root I/O Virtualization (SR-IOV)
IOVCap: Migration-, Interrupt Message Number: 000
IOVCtl: Enable- Migration- Interrupt- MSE- ARIHierarchy+
IOVSta: Migration-
Initial VFs: 8, Total VFs: 8, Number of VFs: 8, Function Dependency Link: 00
VF offset: 128, stride: 2, Device ID: 10ca
Supported Page Size: 00000553, System Page Size: 00000001
Region 0: Memory at 00000000fd700000 (64-bit, non-prefetchable)
Region 3: Memory at 00000000fd720000 (64-bit, non-prefetchable)
VF Migration: offset: 00000000, BIR: 0
Kernel driver in use: igb
Kernel modules: igb
03:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
Subsystem: QLogic, Corp. Device 0080
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 16
Region 0: Memory at fd7a0000 (32-bit, non-prefetchable) [size=128K]
Region 1: Memory at fd780000 (32-bit, non-prefetchable) [size=128K]
Region 2: I/O ports at be00 [size=32]
Region 3: Memory at fd7f8000 (32-bit, non-prefetchable) [size=16K]
[virtual] Expansion ROM at fd220000 [disabled] [size=128K]
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=1 PME-
Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
Address: 0000000000000000 Data: 0000
Masking: 00000000 Pending: 00000000
Capabilities: [70] MSI-X: Enable+ Count=10 Masked-
Vector table: BAR=3 offset=00000000
PBA: BAR=3 offset=00002000
Capabilities: [a0] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 512 bytes, PhantFunc 0, Latency L0s <512ns, L1 <64us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset+
DevCtl: Report errors: Correctable+ Non-Fatal+ Fatal+ Unsupported+
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+ FLReset-
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr+ TransPend-
LnkCap: Port #0, Speed 2.5GT/s, Width x4, ASPM L0s L1, Latency L0 <4us, L1 <64us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x4, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
DevCtl2: Completion Timeout: 16ms to 55ms, TimeoutDis-
LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB
Capabilities: [100 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES- TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-
Capabilities: [140 v1] Device Serial Number 00-0c-bd-ff-ff-00-94-6c
Capabilities: [150 v1] Alternative Routing-ID Interpretation (ARI)
ARICap: MFVC- ACS-, Next Function: 0
ARICtl: MFVC- ACS-, Function Group: 0
Capabilities: [160 v1] Single Root I/O Virtualization (SR-IOV)
IOVCap: Migration-, Interrupt Message Number: 000
IOVCtl: Enable- Migration- Interrupt- MSE- ARIHierarchy-
IOVSta: Migration-
Initial VFs: 8, Total VFs: 8, Number of VFs: 8, Function Dependency Link: 01
VF offset: 128, stride: 2, Device ID: 10ca
Supported Page Size: 00000553, System Page Size: 00000001
Region 0: Memory at 00000000fd740000 (64-bit, non-prefetchable)
Region 3: Memory at 0000000000000000 (64-bit, non-prefetchable)
VF Migration: offset: 00000000, BIR: 0
Kernel driver in use: igb
Kernel modules: igb
04:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
Subsystem: QLogic, Corp. Device 0080
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin B routed to IRQ 18
Region 0: Memory at fd6c0000 (32-bit, non-prefetchable) [size=128K]
Region 1: Memory at fd660000 (32-bit, non-prefetchable) [size=128K]
Region 2: I/O ports at af00 [size=32]
Region 3: Memory at fd6fc000 (32-bit, non-prefetchable) [size=16K]
[virtual] Expansion ROM at fd100000 [disabled] [size=128K]
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=1 PME-
Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
Address: 0000000000000000 Data: 0000
Masking: 00000000 Pending: 00000000
Capabilities: [70] MSI-X: Enable+ Count=10 Masked-
Vector table: BAR=3 offset=00000000
PBA: BAR=3 offset=00002000
Capabilities: [a0] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 512 bytes, PhantFunc 0, Latency L0s <512ns, L1 <64us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset+
DevCtl: Report errors: Correctable+ Non-Fatal+ Fatal+ Unsupported+
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+ FLReset-
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr+ TransPend-
LnkCap: Port #1, Speed 2.5GT/s, Width x4, ASPM L0s L1, Latency L0 <4us, L1 <64us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x4, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
DevCtl2: Completion Timeout: 16ms to 55ms, TimeoutDis-
LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB
Capabilities: [100 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES- TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-
Capabilities: [140 v1] Device Serial Number 00-0c-bd-ff-ff-00-94-6e
Capabilities: [150 v1] Alternative Routing-ID Interpretation (ARI)
ARICap: MFVC- ACS-, Next Function: 1
ARICtl: MFVC- ACS-, Function Group: 0
Capabilities: [160 v1] Single Root I/O Virtualization (SR-IOV)
IOVCap: Migration-, Interrupt Message Number: 000
IOVCtl: Enable- Migration- Interrupt- MSE- ARIHierarchy+
IOVSta: Migration-
Initial VFs: 8, Total VFs: 8, Number of VFs: 8, Function Dependency Link: 00
VF offset: 128, stride: 2, Device ID: 10ca
Supported Page Size: 00000553, System Page Size: 00000001
Region 0: Memory at 00000000fd600000 (64-bit, non-prefetchable)
Region 3: Memory at 00000000fd620000 (64-bit, non-prefetchable)
VF Migration: offset: 00000000, BIR: 0
Kernel driver in use: igb
Kernel modules: igb
04:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
Subsystem: QLogic, Corp. Device 0080
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 17
Region 0: Memory at fd6a0000 (32-bit, non-prefetchable) [size=128K]
Region 1: Memory at fd680000 (32-bit, non-prefetchable) [size=128K]
Region 2: I/O ports at ae00 [size=32]
Region 3: Memory at fd6f8000 (32-bit, non-prefetchable) [size=16K]
[virtual] Expansion ROM at fd120000 [disabled] [size=128K]
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=1 PME-
Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
Address: 0000000000000000 Data: 0000
Masking: 00000000 Pending: 00000000
Capabilities: [70] MSI-X: Enable+ Count=10 Masked-
Vector table: BAR=3 offset=00000000
PBA: BAR=3 offset=00002000
Capabilities: [a0] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 512 bytes, PhantFunc 0, Latency L0s <512ns, L1 <64us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset+
DevCtl: Report errors: Correctable+ Non-Fatal+ Fatal+ Unsupported+
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+ FLReset-
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr+ TransPend-
LnkCap: Port #1, Speed 2.5GT/s, Width x4, ASPM L0s L1, Latency L0 <4us, L1 <64us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x4, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
DevCtl2: Completion Timeout: 16ms to 55ms, TimeoutDis-
LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB
Capabilities: [100 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES- TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-
Capabilities: [140 v1] Device Serial Number 00-0c-bd-ff-ff-00-94-6e
Capabilities: [150 v1] Alternative Routing-ID Interpretation (ARI)
ARICap: MFVC- ACS-, Next Function: 0
ARICtl: MFVC- ACS-, Function Group: 0
Capabilities: [160 v1] Single Root I/O Virtualization (SR-IOV)
IOVCap: Migration-, Interrupt Message Number: 000
IOVCtl: Enable- Migration- Interrupt- MSE- ARIHierarchy-
IOVSta: Migration-
Initial VFs: 8, Total VFs: 8, Number of VFs: 8, Function Dependency Link: 01
VF offset: 128, stride: 2, Device ID: 10ca
Supported Page Size: 00000553, System Page Size: 00000001
Region 0: Memory at 00000000fd640000 (64-bit, non-prefetchable)
Region 3: Memory at 0000000000000000 (64-bit, non-prefetchable)
VF Migration: offset: 00000000, BIR: 0
Kernel driver in use: igb
Kernel modules: igb
07:00.0 Ethernet controller: Intel Corporation 82573L Gigabit Ethernet Controller
Subsystem: Intel Corporation Device 0000
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 55
Region 0: Memory at fcee0000 (32-bit, non-prefetchable) [size=128K]
Region 2: I/O ports at 7f00 [size=32]
Capabilities: [c8] Power Management version 2
Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=1 PME-
Capabilities: [d0] MSI: Enable+ Count=1/1 Maskable- 64bit+
Address: 00000000fee0100c Data: 41aa
Capabilities: [e0] Express (v1) Endpoint, MSI 00
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <512ns, L1 <64us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset-
DevCtl: Report errors: Correctable+ Non-Fatal+ Fatal+ Unsupported+
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
LnkCap: Port #0, Speed 2.5GT/s, Width x1, ASPM unknown, Latency L0 <128ns, L1 <64us
ClockPM+ Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
Capabilities: [100 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES- TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
AERCap: First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-
Capabilities: [140 v1] Device Serial Number 00-07-32-ff-ff-13-f0-5b
Kernel driver in use: e1000e
Kernel modules: e1000e
08:00.0 Ethernet controller: Intel Corporation 82573L Gigabit Ethernet Controller
Subsystem: Intel Corporation Device 0000
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 61
Region 0: Memory at fdee0000 (32-bit, non-prefetchable) [size=128K]
Region 2: I/O ports at 6f00 [size=32]
Capabilities: [c8] Power Management version 2
Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=1 PME-
Capabilities: [d0] MSI: Enable+ Count=1/1 Maskable- 64bit+
Address: 00000000fee0200c Data: 41ba
Capabilities: [e0] Express (v1) Endpoint, MSI 00
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <512ns, L1 <64us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset-
DevCtl: Report errors: Correctable+ Non-Fatal+ Fatal+ Unsupported+
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
LnkCap: Port #0, Speed 2.5GT/s, Width x1, ASPM unknown, Latency L0 <128ns, L1 <64us
ClockPM+ Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
Capabilities: [100 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES- TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr+ BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
AERCap: First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-
Capabilities: [140 v1] Device Serial Number 00-07-32-ff-ff-15-d1-fc
Kernel driver in use: e1000e
Kernel modules: e1000e
0b:0b.0 CardBus bridge: Texas Instruments PCI1520 PC card Cardbus Controller (rev 01)
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 168, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 16
Region 0: Memory at d7fff000 (32-bit, non-prefetchable) [size=4K]
Bus: primary=0b, secondary=0c, subordinate=0c, sec-latency=176
Memory window 0: cc000000-cffff000 (prefetchable)
Memory window 1: d0000000-d3fff000
I/O window 0: 0000d000-0000d0ff
I/O window 1: 0000d400-0000d4ff
BridgeCtl: Parity- SERR- ISA- VGA- MAbort- >Reset+ 16bInt+ PostWrite+
16-bit legacy interface ports at 0001
Kernel driver in use: yenta_cardbus
Kernel modules: yenta_socket
0b:0b.1 CardBus bridge: Texas Instruments PCI1520 PC card Cardbus Controller (rev 01)
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 168, Cache Line Size: 64 bytes
Interrupt: pin B routed to IRQ 17
Region 0: Memory at d7ffd000 (32-bit, non-prefetchable) [size=4K]
Bus: primary=0b, secondary=0d, subordinate=10, sec-latency=176
Memory window 0: 80000000-83fff000 (prefetchable)
Memory window 1: 84000000-87fff000
I/O window 0: 0000d800-0000d8ff
I/O window 1: 0000dc00-0000dcff
BridgeCtl: Parity- SERR- ISA- VGA- MAbort- >Reset+ 16bInt+ PostWrite+
16-bit legacy interface ports at 0001
Kernel driver in use: yenta_cardbus
Kernel modules: yenta_socket
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply related
* Re: [ethtool PATCH 0/6] Network flow classifier
From: Alexander Duyck @ 2011-04-21 21:11 UTC (permalink / raw)
To: Ben Hutchings
Cc: davem@davemloft.net, Kirsher, Jeffrey T, netdev@vger.kernel.org
In-Reply-To: <1303419093.3165.57.camel@bwh-desktop>
On 4/21/2011 1:51 PM, Ben Hutchings wrote:
> On Thu, 2011-04-21 at 13:40 -0700, Alexander Duyck wrote:
>> The following patches are meant to add support for the network flow classifier
>> interface built into the ethtool_rxnfc.
>>
>> Once this has been accepted I plan to submit the kernel portion to Jeff
>> Kirsher as it is almost all ixgbe code changes with the exception of the
>> removal of support for ethtool_get_rx_ntuple from the kernel.
> [...]
>
> This is the start of a 4-way weekend in the UK, so don't be surprised if
> I take a while to review these changes.
>
> Ben.
>
I'm fine with that. I wasn't in any big hurry. I was mostly just
getting them out there for review so that I can probably see about
polishing them up and submitting the final version for them next week.
Thanks,
Alex
^ permalink raw reply
* Re: [PATCH] bonding: fix bridged bonds in 802.3ad mode
From: Stephen Hemminger @ 2011-04-21 21:08 UTC (permalink / raw)
To: Benjamin Poirier
Cc: Ben Hutchings, Jiri Bohac, netdev, Jay Vosburgh, Andy Gospodarek
In-Reply-To: <4DB096E0.4010407@polymtl.ca>
On Thu, 21 Apr 2011 16:43:12 -0400
Benjamin Poirier <benjamin.poirier@polymtl.ca> wrote:
> On 21/04/11 03:08 PM, Ben Hutchings wrote:
> > On Thu, 2011-04-21 at 20:47 +0200, Jiri Bohac wrote:
> >> 802.3ad bonding inside a bridge is broken again. Originally fixed by
> >> 43aa1920117801fe9ae3d1fad886b62511e09bee, the bug was re-introduced by
> >> 1e253c3b8a1aeed51eef6fc366812f219b97de65.
> >>
> >> LACP frames must not have their skb->dev changed by the bridging hook.
> >>
> >> Signed-off-by: Jiri Bohac <jbohac@suse.cz>
> >>
> >> --- a/drivers/net/bonding/bond_main.c
> >> +++ b/drivers/net/bonding/bond_main.c
> >> @@ -1514,6 +1514,11 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
> >> memcpy(eth_hdr(skb)->h_dest, bond->dev->dev_addr, ETH_ALEN);
> >> }
> >>
> >> + /* prevent bridging code from mangling and forwarding LACP frames */
> >> + if (bond->params.mode == BOND_MODE_8023AD &&
> >> + skb->protocol == htons(ETH_P_SLOW))
> >> + return RX_HANDLER_PASS;
> >> +
> >> return RX_HANDLER_ANOTHER;
> >> }
> >>
> >
> > It seems to me that 1e253c3b8a1aeed51eef6fc366812f219b97de65 is bogus
>
> You bet, it's rubbish ;)
>
> Any thoughts on how we could support a transparent bridging
> configuration without repurposing br->stp_enabled or adding another
> option to bridge-utils?
>
> btw, the particular scenario I was trying to address is a virtual
> machine bridged to an ethernet interface connected to a switch port with
> 802.1x enabled.
>
> -Benjamin
>
> > and should be reverted, rather than worked around by other drivers. We
> > shouldn't enable non-conformant forwarding behaviour by default just
> > because some people find it useful. The administrator should have to
> > explicitly enable it.
> >
> > Ben.
> >
>
The IEEE standard says bridge's shouldn't forward link-local addresses.
The problem is that people expect it to.
--
^ permalink raw reply
* Re: [ethtool PATCH 0/6] Network flow classifier
From: Ben Hutchings @ 2011-04-21 20:51 UTC (permalink / raw)
To: Alexander Duyck; +Cc: davem, jeffrey.t.kirsher, netdev
In-Reply-To: <20110421202857.23054.63316.stgit@gitlad.jf.intel.com>
On Thu, 2011-04-21 at 13:40 -0700, Alexander Duyck wrote:
> The following patches are meant to add support for the network flow classifier
> interface built into the ethtool_rxnfc.
>
> Once this has been accepted I plan to submit the kernel portion to Jeff
> Kirsher as it is almost all ixgbe code changes with the exception of the
> removal of support for ethtool_get_rx_ntuple from the kernel.
[...]
This is the start of a 4-way weekend in the UK, so don't be surprised if
I take a while to review these changes.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* Re: [PATCH] bonding: fix bridged bonds in 802.3ad mode
From: Benjamin Poirier @ 2011-04-21 20:43 UTC (permalink / raw)
To: Ben Hutchings
Cc: Jiri Bohac, netdev, Stephen Hemminger, Jay Vosburgh,
Andy Gospodarek
In-Reply-To: <1303412899.3165.47.camel@bwh-desktop>
On 21/04/11 03:08 PM, Ben Hutchings wrote:
> On Thu, 2011-04-21 at 20:47 +0200, Jiri Bohac wrote:
>> 802.3ad bonding inside a bridge is broken again. Originally fixed by
>> 43aa1920117801fe9ae3d1fad886b62511e09bee, the bug was re-introduced by
>> 1e253c3b8a1aeed51eef6fc366812f219b97de65.
>>
>> LACP frames must not have their skb->dev changed by the bridging hook.
>>
>> Signed-off-by: Jiri Bohac <jbohac@suse.cz>
>>
>> --- a/drivers/net/bonding/bond_main.c
>> +++ b/drivers/net/bonding/bond_main.c
>> @@ -1514,6 +1514,11 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
>> memcpy(eth_hdr(skb)->h_dest, bond->dev->dev_addr, ETH_ALEN);
>> }
>>
>> + /* prevent bridging code from mangling and forwarding LACP frames */
>> + if (bond->params.mode == BOND_MODE_8023AD &&
>> + skb->protocol == htons(ETH_P_SLOW))
>> + return RX_HANDLER_PASS;
>> +
>> return RX_HANDLER_ANOTHER;
>> }
>>
>
> It seems to me that 1e253c3b8a1aeed51eef6fc366812f219b97de65 is bogus
You bet, it's rubbish ;)
Any thoughts on how we could support a transparent bridging
configuration without repurposing br->stp_enabled or adding another
option to bridge-utils?
btw, the particular scenario I was trying to address is a virtual
machine bridged to an ethernet interface connected to a switch port with
802.1x enabled.
-Benjamin
> and should be reverted, rather than worked around by other drivers. We
> shouldn't enable non-conformant forwarding behaviour by default just
> because some people find it useful. The administrator should have to
> explicitly enable it.
>
> Ben.
>
^ permalink raw reply
* [ethtool PATCH 6/6] Update documentation for -u/-U operations
From: Alexander Duyck @ 2011-04-21 20:40 UTC (permalink / raw)
To: davem, jeffrey.t.kirsher, bhutchings; +Cc: netdev
In-Reply-To: <20110421202857.23054.63316.stgit@gitlad.jf.intel.com>
This patch updates the documentation for the -u/-U operations to include
the recent changes made to support addition/deletion/display of network
flow classifier rules.
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
---
ethtool.8.in | 185 +++++++++++++++++++++++++++++-----------------------------
ethtool.c | 32 ++++++----
2 files changed, 111 insertions(+), 106 deletions(-)
diff --git a/ethtool.8.in b/ethtool.8.in
index 12a1d1d..8908351 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -42,10 +42,20 @@
[\\fB\\$1\\fP\ \\fIN\\fP]
..
.\"
+.\" .BM - same as above but has a mask field for format "[value N [value-mask N]]"
+.\"
+.de BM
+[\\fB\\$1\\fP\ \\fIN\\fP\ [\\fB\\$1\-mask\\fP\ \\fIN\\fP]]
+..
+.\"
.\" \(*MA - mac address
.\"
.ds MA \fIxx\fP\fB:\fP\fIyy\fP\fB:\fP\fIzz\fP\fB:\fP\fIaa\fP\fB:\fP\fIbb\fP\fB:\fP\fIcc\fP
.\"
+.\" \(*PA - IP address
+.\"
+.ds PA \fIx\fP\fB.\fP\fIx\fP\fB.\fP\fIx\fP\fB.\fP\fIx\fP
+.\"
.\" \(*WO - wol flags
.\"
.ds WO \fBp\fP|\fBu\fP|\fBm\fP|\fBb\fP|\fBa\fP|\fBg\fP|\fBs\fP|\fBd\fP...
@@ -57,6 +67,12 @@
.\" \(*HO - hash options
.\"
.ds HO \fBm\fP|\fBv\fP|\fBt\fP|\fBs\fP|\fBd\fP|\fBf\fP|\fBn\fP|\fBr\fP...
+.\"
+.\" \(*NC - Network Classifier type values
+.\"
+.ds NC \fBether\fP|\fBip4\fP|\fBtcp4\fP|\fBudp4\fP|\fBsctp4\fP|\fBah4\fP|\fBesp4\fP
+
+.\"
.\" Start URL.
.de UR
. ds m1 \\$1\"
@@ -236,9 +252,9 @@ ethtool \- query or control network driver and hardware settings
.HP
.B ethtool \-N
.I ethX
-.RB [ rx\-flow\-hash \ \*(FL
-.RB \ \*(HO]
+.RB [ rx-flow-hash \ \*(FL \ \*(HO]
.HP
+
.B ethtool \-x|\-\-show\-rxfh\-indir
.I ethX
.HP
@@ -257,54 +273,28 @@ ethtool \- query or control network driver and hardware settings
.HP
.B ethtool \-u|\-\-show\-ntuple
.I ethX
-.TP
+.BN class-rule
+.HP
+
.BI ethtool\ \-U|\-\-config\-ntuple \ ethX
-.RB {
-.A3 flow\-type tcp4 udp4 sctp4
-.RB [ src\-ip
-.IR addr
-.RB [ src\-ip\-mask
-.IR mask ]]
-.RB [ dst\-ip
-.IR addr
-.RB [ dst\-ip\-mask
-.IR mask ]]
-.RB [ src\-port
-.IR port
-.RB [ src\-port\-mask
-.IR mask ]]
-.RB [ dst\-port
-.IR port
-.RB [ dst\-port\-mask
-.IR mask ]]
-.br
-.RB | \ flow\-type\ ether
-.RB [ src
-.IR mac\-addr
-.RB [ src\-mask
-.IR mask ]]
-.RB [ dst
-.IR mac\-addr
-.RB [ dst\-mask
-.IR mask ]]
-.RB [ proto
-.IR N
-.RB [ proto\-mask
-.IR mask ]]\ }
-.br
-.RB [ vlan
-.IR VLAN\-tag
-.RB [ vlan\-mask
-.IR mask ]]
-.RB [ user\-def
-.IR data
-.RB [ user\-def\-mask
-.IR mask ]]
-.RI action \ N
-.
-.\" Adjust lines (i.e. full justification) and hyphenate.
-.ad
-.hy
+.BN class-rule-del
+.RB [\ flow-type \ \*(NC
+.RB [ src \ \*(MA\ [ src-mask \ \*(MA]]
+.RB [ dst \ \*(MA\ [ dst-mask \ \*(MA]]
+.BM proto
+.RB [ src-ip \ \*(PA\ [ src-ip-mask \ \*(PA]]
+.RB [ dst-ip \ \*(PA\ [ dst-ip-mask \ \*(PA]]
+.BM tos
+.BM l4proto
+.BM src-port
+.BM dst-port
+.BM spi
+.BM vlan-etype
+.BM vlan
+.BM user-def
+.BN action
+.BN loc
+.RB ]
.SH DESCRIPTION
.BI ethtool
@@ -630,12 +620,18 @@ Default region is 0 which denotes all regions in the flash.
.TP
.B \-u \-\-show\-ntuple
Get Rx ntuple filters and actions, then display them to the user.
+.TP
+.BI class-rule \ N
+Retrieves the RX classification rule with the given ID.
.PD
.RE
.TP
.B \-U \-\-config\-ntuple
Configure Rx ntuple filters and actions
.TP
+.BI class-rule-del \ N
+Deletes the RX classification rule with the given ID.
+.TP
.B flow\-type tcp4|udp4|sctp4|ether
.TS
nokeep;
@@ -643,64 +639,61 @@ lB l.
tcp4 TCP over IPv4
udp4 UDP over IPv4
sctp4 SCTP over IPv4
+ah4 IPSEC AH over IPv4
+esp4 IPSEC ESP over IPv4
+ip4 Raw IPv4
ether Ethernet
.TE
.TP
-.BI src\-ip \ addr
-Includes the source IP address, specified using dotted-quad notation
-or as a single 32-bit number.
-.TP
-.BI src\-ip\-mask \ mask
-Specify a mask for the source IP address.
-.TP
-.BI dst\-ip \ addr
-Includes the destination IP address.
-.TP
-.BI dst\-ip\-mask \ mask
-Specify a mask for the destination IP address.
-.TP
-.BI src\-port \ port
-Includes the source port.
-.TP
-.BI src\-port\-mask \ mask
-Specify a mask for the source port.
+.BR src \ \*(MA\ [ src-mask \ \*(MA]
+Includes the source MAC address, specified as 6 bytes in hexadecimal
+separated by colons, along with an optional mask.
.TP
-.BI dst\-port \ port
-Includes the destination port.
+.BR dst \ \*(MA\ [ src-mask \ \*(MA]
+Includes the destination MAC address, specified as 6 bytes in hexadecimal
+separated by colons, along with an optional mask.
.TP
-.BI dst\-port\-mask \ mask
-Specify a mask for the destination port.
+.BI proto \ N \\fR\ [\\fPproto-mask \ N \\fR]\\fP
+Includes the Ethernet protocol number (ethertype) and an optional mask.
.TP
-.BI src \ mac\-addr
-Includes the source MAC address, specified as 6 bytes in hexadecimal
-separated by colons.
+.BR src-ip \ \*(PA\ [ src-ip-mask \ \*(PA]
+Specify the source IP address of the incoming packet to
+match along with an optional mask.
.TP
-.BI src\-mask \ mask
-Specify a mask for the source MAC address.
+.BR dst-ip \ \*(PA\ [ dst-ip-mask \ \*(PA]
+Specify the destination IP address of the incoming packet to
+match along with an optional mask.
.TP
-.BI dst \ mac\-addr
-Includes the destination MAC address.
+.BI tos \ N \\fR\ [\\fPtos-mask \ N \\fR]\\fP
+Specify the value of the Type of Service field in the incoming packet to
+match along with an optional mask.
.TP
-.BI dst\-mask \ mask
-Specify a mask for the destination MAC address.
+.BI l4proto \ N \\fR\ [\\fPl4proto-mask \ N \\fR]\\fP
+Includes the layer 4 protocol number and optional mask.
.TP
-.BI proto \ N
-Includes the Ethernet protocol number (ethertype).
+.BI src-port \ N \\fR\ [\\fPsrc-port-mask \ N \\fR]\\fP
+Specify the value of the source port field (applicable to
+TCP/UDP packets)in the incoming packet to match along with an
+optional mask.
.TP
-.BI proto\-mask \ mask
-Specify a mask for the Ethernet protocol number.
+.BI dst-port \ N \\fR\ [\\fPdst-port-mask \ N \\fR]\\fP
+Specify the value of the destination port field (applicable to
+TCP/UDP packets)in the incoming packet to match along with an
+optional mask.
.TP
-.BI vlan \ VLAN\-tag
-Includes the VLAN tag.
+.BI spi \ N \\fR\ [\\fPspi-mask \ N \\fR]\\fP
+Specify the value of the security parameter index field (applicable to
+AH/ESP packets)in the incoming packet to match along with an
+optional mask.
.TP
-.BI vlan\-mask \ mask
-Specify a mask for the VLAN tag.
+.BI vlan-etype \ N \\fR\ [\\fPvlan-etype-mask \ N \\fR]\\fP
+Includes the VLAN tag Ethertype and an optional mask.
.TP
-.BI user\-def \ data
-Includes 64-bits of user-specific data.
+.BI vlan \ N \\fR\ [\\fPvlan-mask \ N \\fR]\\fP
+Includes the VLAN tag and an optional mask.
.TP
-.BI user\-def\-mask \ mask
-Specify a mask for the user-specific data.
+.BI user-def \ N \\fR\ [\\fPuser-def-mask \ N \\fR]\\fP
+Includes 64-bits of user-specific data and an optional mask.
.TP
.BI action \ N
Specifies the Rx queue to send packets to, or some other action.
@@ -711,6 +704,11 @@ lB l.
-1 Drop the matched flow
0 or higher Rx queue to route the flow
.TE
+.TP
+.BI loc \ N
+Specify the location/ID to insert the rule. This will overwrite
+any rule present in that location and will not go through any
+of the rule ordering process.
.SH BUGS
Not supported (in part or whole) on all network drivers.
.SH AUTHOR
@@ -724,7 +722,8 @@ Jakub Jelinek,
Andre Majorel,
Eli Kupermann,
Scott Feldman,
-Andi Kleen.
+Andi Kleen,
+Alexander Duyck.
.SH AVAILABILITY
.B ethtool
is available from
diff --git a/ethtool.c b/ethtool.c
index 421fe20..e65979d 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -243,20 +243,26 @@ static struct option {
" equal N | weight W0 W1 ...\n" },
{ "-U", "--config-ntuple", MODE_SCLSRULE, "Configure Rx ntuple filters "
"and actions",
- " { flow-type tcp4|udp4|sctp4\n"
- " [ src-ip ADDR [src-ip-mask MASK] ]\n"
- " [ dst-ip ADDR [dst-ip-mask MASK] ]\n"
- " [ src-port PORT [src-port-mask MASK] ]\n"
- " [ dst-port PORT [dst-port-mask MASK] ]\n"
- " | flow-type ether\n"
- " [ src MAC-ADDR [src-mask MASK] ]\n"
- " [ dst MAC-ADDR [dst-mask MASK] ]\n"
- " [ proto N [proto-mask MASK] ] }\n"
- " [ vlan VLAN-TAG [vlan-mask MASK] ]\n"
- " [ user-def DATA [user-def-mask MASK] ]\n"
- " action N\n" },
+ " [ class-rule-del %d ] |\n"
+ " [ flow-type ether|ip4|tcp4|udp4|sctp4|ah4|esp4\n"
+ " [ src %x:%x:%x:%x:%x:%x [src-mask %x:%x:%x:%x:%x:%x] ]\n"
+ " [ dst %x:%x:%x:%x:%x:%x [dst-mask %x:%x:%x:%x:%x:%x] ]\n"
+ " [ proto %d [proto-mask MASK] ]\n"
+ " [ src-ip %d.%d.%d.%d [src-ip-mask %d.%d.%d.%d] ]\n"
+ " [ dst-ip %d.%d.%d.%d [dst-ip-mask %d.%d.%d.%d] ]\n"
+ " [ tos %d [tos-mask %x] ]\n"
+ " [ l4proto %d [l4proto-mask MASK] ]\n"
+ " [ src-port %d [src-port-mask %x] ]\n"
+ " [ dst-port %d [dst-port-mask %x] ]\n"
+ " [ spi %d [spi-mask %x] ]\n"
+ " [ vlan-etype %x [vlan-etype-mask %x] ]\n"
+ " [ vlan %x [vlan-mask %x] ]\n"
+ " [ user-def %x [user-def-mask %x] ]\n"
+ " [ action %d ]\n"
+ " [ loc %d]]\n" },
{ "-u", "--show-ntuple", MODE_GCLSRULE,
- "Get Rx ntuple filters and actions\n" },
+ "Get Rx ntuple filters and actions",
+ " [ class-rule %d ]\n"},
{ "-P", "--show-permaddr", MODE_PERMADDR,
"Show permanent hardware address" },
{ "-h", "--help", MODE_HELP, "Show this help" },
^ permalink raw reply related
* [ethtool PATCH 5/6] v4 Add RX packet classification interface
From: Alexander Duyck @ 2011-04-21 20:40 UTC (permalink / raw)
To: davem, jeffrey.t.kirsher, bhutchings; +Cc: netdev
In-Reply-To: <20110421202857.23054.63316.stgit@gitlad.jf.intel.com>
From: Santwona Behera <santwona.behera@sun.com>
This patch was originally introduced as:
[PATCH 1/3] [ethtool] Add rx pkt classification interface
Signed-off-by: Santwona Behera <santwona.behera@sun.com>
http://patchwork.ozlabs.org/patch/23223/
v2:
I have updated it to address a number of issues. As a result I removed the
local caching of rules due to the fact that there were memory leaks in this
code and the rule manager would consume over 1Mb of space for an 8K table
when all that was needed was 1K in order to store which rules were active
and which were not.
In addition I dropped the use of regions as there were multiple issue found
including the fact that the regions were not properly expanding beyond 2
and the fact that the regions required reading all of the rules in order to
correctly expand beyond 2. By dropping the regions from the rule manager
it is possible to write a much cleaner interface leaving region management
to be done by either the driver or by external management scripts.
v3:
The latest update to this patch now inverts the masks to match the mask
types used for n-tuple. As such a network flow classifier is defined using
the exact same syntax as n-tuple, and the tool will correct for the fact
that NFC uses the 1's compliment of the n-tuple mask.
I also updated the ordering of new rules being added. All new rules will
take the highest numbered open rule when no location is specified.
Since NFC now uses the same syntax as n-tuple I added code such that now
when location is not specified the -U option will first try to add a new
n-tuple rule, and if that fails with a ENOTSUPP it will then try to add the
rule via the NFC interface.
Finally I split out the addition of bitops and the updates to documentation
into separate patches. This makes the total patch size a bit more
manageable since the addition of NFC and the merging of it with n-tuple were
combined into this patch.
v4:
This change merges the ntuple and network flow classifier rules so that if
we setup a rule and the device has the NTUPLE flag set we will first try to
use set_rx_ntuple. If that fails with EOPNOTSUPP we then will attempt to
use the network flow classifier rule insertion. This way we can support
legacy configurations such as niu on kernels prior to 2.6.40 that support
network flow classifier but not ntuple, but for drivers such as ixgbe we
can test for ntuple first, and then network flow classifier.
This patch has also updated the output to make use of the updated network
flow classifier extensions that have been accepted into the kernel.
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
---
Makefile.am | 3
ethtool-util.h | 14 +
ethtool.c | 357 ++++++++++--------
rxclass.c | 1106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 1318 insertions(+), 162 deletions(-)
create mode 100644 rxclass.c
diff --git a/Makefile.am b/Makefile.am
index a0d2116..0262c31 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,7 +8,8 @@ ethtool_SOURCES = ethtool.c ethtool-copy.h ethtool-util.h \
amd8111e.c de2104x.c e100.c e1000.c igb.c \
fec_8xx.c ibm_emac.c ixgb.c ixgbe.c natsemi.c \
pcnet32.c realtek.c tg3.c marvell.c vioc.c \
- smsc911x.c at76c50x-usb.c sfc.c stmmac.c
+ smsc911x.c at76c50x-usb.c sfc.c stmmac.c \
+ rxclass.c
dist-hook:
cp $(top_srcdir)/ethtool.spec $(distdir)
diff --git a/ethtool-util.h b/ethtool-util.h
index 3d46faf..adf8fcc 100644
--- a/ethtool-util.h
+++ b/ethtool-util.h
@@ -62,6 +62,8 @@ static inline u64 cpu_to_be64(u64 value)
#define SIOCETHTOOL 0x8946
#endif
+#define RX_CLS_LOC_UNSPEC 0xffffffffUL
+
/* National Semiconductor DP83815, DP83816 */
int natsemi_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
int natsemi_dump_eeprom(struct ethtool_drvinfo *info,
@@ -125,4 +127,14 @@ int sfc_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
int st_mac100_dump_regs(struct ethtool_drvinfo *info,
struct ethtool_regs *regs);
int st_gmac_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
-#endif
+
+/* Rx flow classification */
+int rxclass_parse_ruleopts(char **optstr, int opt_cnt,
+ struct ethtool_rx_flow_spec *fsp);
+int rxclass_rule_getall(int fd, struct ifreq *ifr);
+int rxclass_rule_get(int fd, struct ifreq *ifr, __u32 loc);
+int rxclass_rule_ins(int fd, struct ifreq *ifr,
+ struct ethtool_rx_flow_spec *fsp);
+int rxclass_rule_del(int fd, struct ifreq *ifr, __u32 loc);
+
+#endif /* ETHTOOL_UTIL_H__ */
diff --git a/ethtool.c b/ethtool.c
index 15af86a..421fe20 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -6,6 +6,7 @@
* Kernel 2.4 update Copyright 2001 Jeff Garzik <jgarzik@mandrakesoft.com>
* Wake-on-LAN,natsemi,misc support by Tim Hockin <thockin@sun.com>
* Portions Copyright 2002 Intel
+ * Portions Copyright (C) Sun Microsystems 2008
* do_test support by Eli Kupermann <eli.kupermann@intel.com>
* ETHTOOL_PHYS_ID support by Chris Leech <christopher.leech@intel.com>
* e1000 support by Scott Feldman <scott.feldman@intel.com>
@@ -14,6 +15,7 @@
* amd8111e support by Reeja John <reeja.john@amd.com>
* long arguments by Andi Kleen.
* SMSC LAN911x support by Steve Glendinning <steve.glendinning@smsc.com>
+ * Rx Network Flow Control configuration support <santwona.behera@sun.com>
* Various features by Ben Hutchings <bhutchings@solarflare.com>;
* Copyright 2009, 2010 Solarflare Communications
*
@@ -43,6 +45,8 @@
#include <arpa/inet.h>
#include <linux/sockios.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
#include "ethtool-util.h"
#ifndef MAX_ADDR_LEN
@@ -93,14 +97,13 @@ static int do_gstats(int fd, struct ifreq *ifr);
static int rxflow_str_to_type(const char *str);
static int parse_rxfhashopts(char *optstr, u32 *data);
static char *unparse_rxfhashopts(u64 opts);
-static void parse_rxntupleopts(int argc, char **argp, int first_arg);
static int dump_rxfhash(int fhash, u64 val);
static int do_srxclass(int fd, struct ifreq *ifr);
static int do_grxclass(int fd, struct ifreq *ifr);
static int do_grxfhindir(int fd, struct ifreq *ifr);
static int do_srxfhindir(int fd, struct ifreq *ifr);
-static int do_srxntuple(int fd, struct ifreq *ifr);
-static int do_grxntuple(int fd, struct ifreq *ifr);
+static int do_srxclsrule(int fd, struct ifreq *ifr);
+static int do_grxclsrule(int fd, struct ifreq *ifr);
static int do_flash(int fd, struct ifreq *ifr);
static int do_permaddr(int fd, struct ifreq *ifr);
@@ -131,8 +134,8 @@ static enum {
MODE_SNFC,
MODE_GRXFHINDIR,
MODE_SRXFHINDIR,
- MODE_SNTUPLE,
- MODE_GNTUPLE,
+ MODE_SCLSRULE,
+ MODE_GCLSRULE,
MODE_FLASHDEV,
MODE_PERMADDR,
} mode = MODE_GSET;
@@ -238,7 +241,7 @@ static struct option {
"indirection" },
{ "-X", "--set-rxfh-indir", MODE_SRXFHINDIR, "Set Rx flow hash indirection",
" equal N | weight W0 W1 ...\n" },
- { "-U", "--config-ntuple", MODE_SNTUPLE, "Configure Rx ntuple filters "
+ { "-U", "--config-ntuple", MODE_SCLSRULE, "Configure Rx ntuple filters "
"and actions",
" { flow-type tcp4|udp4|sctp4\n"
" [ src-ip ADDR [src-ip-mask MASK] ]\n"
@@ -252,7 +255,7 @@ static struct option {
" [ vlan VLAN-TAG [vlan-mask MASK] ]\n"
" [ user-def DATA [user-def-mask MASK] ]\n"
" action N\n" },
- { "-u", "--show-ntuple", MODE_GNTUPLE,
+ { "-u", "--show-ntuple", MODE_GCLSRULE,
"Get Rx ntuple filters and actions\n" },
{ "-P", "--show-permaddr", MODE_PERMADDR,
"Show permanent hardware address" },
@@ -379,26 +382,6 @@ static u32 rx_fhash_val = 0;
static int rx_fhash_changed = 0;
static int rxfhindir_equal = 0;
static char **rxfhindir_weight = NULL;
-static int sntuple_changed = 0;
-static struct ethtool_rx_ntuple_flow_spec ntuple_fs;
-static int ntuple_ip4src_seen = 0;
-static int ntuple_ip4src_mask_seen = 0;
-static int ntuple_ip4dst_seen = 0;
-static int ntuple_ip4dst_mask_seen = 0;
-static int ntuple_psrc_seen = 0;
-static int ntuple_psrc_mask_seen = 0;
-static int ntuple_pdst_seen = 0;
-static int ntuple_pdst_mask_seen = 0;
-static int ntuple_ether_dst_seen = 0;
-static int ntuple_ether_dst_mask_seen = 0;
-static int ntuple_ether_src_seen = 0;
-static int ntuple_ether_src_mask_seen = 0;
-static int ntuple_ether_proto_seen = 0;
-static int ntuple_ether_proto_mask_seen = 0;
-static int ntuple_vlan_tag_seen = 0;
-static int ntuple_vlan_tag_mask_seen = 0;
-static int ntuple_user_def_seen = 0;
-static int ntuple_user_def_mask_seen = 0;
static char *flash_file = NULL;
static int flash = -1;
static int flash_region = -1;
@@ -407,6 +390,11 @@ static int msglvl_changed;
static u32 msglvl_wanted = 0;
static u32 msglvl_mask = 0;
+static int rx_class_rule_get = -1;
+static int rx_class_rule_del = -1;
+static int rx_class_rule_added = 0;
+static struct ethtool_rx_flow_spec rx_rule_fs;
+
static enum {
ONLINE=0,
OFFLINE,
@@ -519,58 +507,6 @@ static struct cmdline_info cmdline_coalesce[] = {
{ "tx-frames-high", CMDL_S32, &coal_tx_frames_high_wanted, &ecoal.tx_max_coalesced_frames_high },
};
-static struct cmdline_info cmdline_ntuple_tcp_ip4[] = {
- { "src-ip", CMDL_IP4, &ntuple_fs.h_u.tcp_ip4_spec.ip4src, NULL,
- 0, &ntuple_ip4src_seen },
- { "src-ip-mask", CMDL_IP4, &ntuple_fs.m_u.tcp_ip4_spec.ip4src, NULL,
- 0, &ntuple_ip4src_mask_seen },
- { "dst-ip", CMDL_IP4, &ntuple_fs.h_u.tcp_ip4_spec.ip4dst, NULL,
- 0, &ntuple_ip4dst_seen },
- { "dst-ip-mask", CMDL_IP4, &ntuple_fs.m_u.tcp_ip4_spec.ip4dst, NULL,
- 0, &ntuple_ip4dst_mask_seen },
- { "src-port", CMDL_BE16, &ntuple_fs.h_u.tcp_ip4_spec.psrc, NULL,
- 0, &ntuple_psrc_seen },
- { "src-port-mask", CMDL_BE16, &ntuple_fs.m_u.tcp_ip4_spec.psrc, NULL,
- 0, &ntuple_psrc_mask_seen },
- { "dst-port", CMDL_BE16, &ntuple_fs.h_u.tcp_ip4_spec.pdst, NULL,
- 0, &ntuple_pdst_seen },
- { "dst-port-mask", CMDL_BE16, &ntuple_fs.m_u.tcp_ip4_spec.pdst, NULL,
- 0, &ntuple_pdst_mask_seen },
- { "vlan", CMDL_U16, &ntuple_fs.vlan_tag, NULL,
- 0, &ntuple_vlan_tag_seen },
- { "vlan-mask", CMDL_U16, &ntuple_fs.vlan_tag_mask, NULL,
- 0, &ntuple_vlan_tag_mask_seen },
- { "user-def", CMDL_U64, &ntuple_fs.data, NULL,
- 0, &ntuple_user_def_seen },
- { "user-def-mask", CMDL_U64, &ntuple_fs.data_mask, NULL,
- 0, &ntuple_user_def_mask_seen },
- { "action", CMDL_S32, &ntuple_fs.action, NULL },
-};
-
-static struct cmdline_info cmdline_ntuple_ether[] = {
- { "dst", CMDL_MAC, ntuple_fs.h_u.ether_spec.h_dest, NULL,
- 0, &ntuple_ether_dst_seen },
- { "dst-mask", CMDL_MAC, ntuple_fs.m_u.ether_spec.h_dest, NULL,
- 0, &ntuple_ether_dst_mask_seen },
- { "src", CMDL_MAC, ntuple_fs.h_u.ether_spec.h_source, NULL,
- 0, &ntuple_ether_src_seen },
- { "src-mask", CMDL_MAC, ntuple_fs.m_u.ether_spec.h_source, NULL,
- 0, &ntuple_ether_src_mask_seen },
- { "proto", CMDL_BE16, &ntuple_fs.h_u.ether_spec.h_proto, NULL,
- 0, &ntuple_ether_proto_seen },
- { "proto-mask", CMDL_BE16, &ntuple_fs.m_u.ether_spec.h_proto, NULL,
- 0, &ntuple_ether_proto_mask_seen },
- { "vlan", CMDL_U16, &ntuple_fs.vlan_tag, NULL,
- 0, &ntuple_vlan_tag_seen },
- { "vlan-mask", CMDL_U16, &ntuple_fs.vlan_tag_mask, NULL,
- 0, &ntuple_vlan_tag_mask_seen },
- { "user-def", CMDL_U64, &ntuple_fs.data, NULL,
- 0, &ntuple_user_def_seen },
- { "user-def-mask", CMDL_U64, &ntuple_fs.data_mask, NULL,
- 0, &ntuple_user_def_mask_seen },
- { "action", CMDL_S32, &ntuple_fs.action, NULL },
-};
-
static struct cmdline_info cmdline_msglvl[] = {
{ "drv", CMDL_FLAG, &msglvl_wanted, NULL,
NETIF_MSG_DRV, &msglvl_mask },
@@ -841,8 +777,8 @@ static void parse_cmdline(int argc, char **argp)
(mode == MODE_SNFC) ||
(mode == MODE_GRXFHINDIR) ||
(mode == MODE_SRXFHINDIR) ||
- (mode == MODE_SNTUPLE) ||
- (mode == MODE_GNTUPLE) ||
+ (mode == MODE_SCLSRULE) ||
+ (mode == MODE_GCLSRULE) ||
(mode == MODE_PHYS_ID) ||
(mode == MODE_FLASHDEV) ||
(mode == MODE_PERMADDR)) {
@@ -926,16 +862,45 @@ static void parse_cmdline(int argc, char **argp)
i = argc;
break;
}
- if (mode == MODE_SNTUPLE) {
+ if (mode == MODE_SCLSRULE) {
if (!strcmp(argp[i], "flow-type")) {
i += 1;
if (i >= argc) {
exit_bad_args();
break;
}
- parse_rxntupleopts(argc, argp, i);
- i = argc;
- break;
+ if (rxclass_parse_ruleopts(&argp[i],
+ argc - i,
+ &rx_rule_fs) < 0) {
+ exit_bad_args();
+ } else {
+ i = argc;
+ rx_class_rule_added = 1;
+ }
+ } else if (!strcmp(argp[i], "class-rule-del")) {
+ i += 1;
+ if (i >= argc) {
+ exit_bad_args();
+ break;
+ }
+ rx_class_rule_del =
+ get_uint_range(argp[i], 0,
+ INT_MAX);
+ } else {
+ exit_bad_args();
+ }
+ break;
+ }
+ if (mode == MODE_GCLSRULE) {
+ if (!strcmp(argp[i], "class-rule")) {
+ i += 1;
+ if (i >= argc) {
+ exit_bad_args();
+ break;
+ }
+ rx_class_rule_get =
+ get_uint_range(argp[i], 0,
+ INT_MAX);
} else {
exit_bad_args();
}
@@ -1606,66 +1571,6 @@ static char *unparse_rxfhashopts(u64 opts)
return buf;
}
-static void parse_rxntupleopts(int argc, char **argp, int i)
-{
- ntuple_fs.flow_type = rxflow_str_to_type(argp[i]);
-
- switch (ntuple_fs.flow_type) {
- case TCP_V4_FLOW:
- case UDP_V4_FLOW:
- case SCTP_V4_FLOW:
- parse_generic_cmdline(argc, argp, i + 1,
- &sntuple_changed,
- cmdline_ntuple_tcp_ip4,
- ARRAY_SIZE(cmdline_ntuple_tcp_ip4));
- if (!ntuple_ip4src_seen)
- ntuple_fs.m_u.tcp_ip4_spec.ip4src = 0xffffffff;
- if (!ntuple_ip4dst_seen)
- ntuple_fs.m_u.tcp_ip4_spec.ip4dst = 0xffffffff;
- if (!ntuple_psrc_seen)
- ntuple_fs.m_u.tcp_ip4_spec.psrc = 0xffff;
- if (!ntuple_pdst_seen)
- ntuple_fs.m_u.tcp_ip4_spec.pdst = 0xffff;
- ntuple_fs.m_u.tcp_ip4_spec.tos = 0xff;
- break;
- case ETHER_FLOW:
- parse_generic_cmdline(argc, argp, i + 1,
- &sntuple_changed,
- cmdline_ntuple_ether,
- ARRAY_SIZE(cmdline_ntuple_ether));
- if (!ntuple_ether_dst_seen)
- memset(ntuple_fs.m_u.ether_spec.h_dest, 0xff, ETH_ALEN);
- if (!ntuple_ether_src_seen)
- memset(ntuple_fs.m_u.ether_spec.h_source, 0xff,
- ETH_ALEN);
- if (!ntuple_ether_proto_seen)
- ntuple_fs.m_u.ether_spec.h_proto = 0xffff;
- break;
- default:
- fprintf(stderr, "Unsupported flow type \"%s\"\n", argp[i]);
- exit(106);
- break;
- }
-
- if (!ntuple_vlan_tag_seen)
- ntuple_fs.vlan_tag_mask = 0xffff;
- if (!ntuple_user_def_seen)
- ntuple_fs.data_mask = 0xffffffffffffffffULL;
-
- if ((ntuple_ip4src_mask_seen && !ntuple_ip4src_seen) ||
- (ntuple_ip4dst_mask_seen && !ntuple_ip4dst_seen) ||
- (ntuple_psrc_mask_seen && !ntuple_psrc_seen) ||
- (ntuple_pdst_mask_seen && !ntuple_pdst_seen) ||
- (ntuple_ether_dst_mask_seen && !ntuple_ether_dst_seen) ||
- (ntuple_ether_src_mask_seen && !ntuple_ether_src_seen) ||
- (ntuple_ether_proto_mask_seen && !ntuple_ether_proto_seen) ||
- (ntuple_vlan_tag_mask_seen && !ntuple_vlan_tag_seen) ||
- (ntuple_user_def_mask_seen && !ntuple_user_def_seen)) {
- fprintf(stderr, "Cannot specify mask without value\n");
- exit(107);
- }
-}
-
static struct {
const char *name;
int (*func)(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
@@ -2027,10 +1932,10 @@ static int doit(void)
return do_grxfhindir(fd, &ifr);
} else if (mode == MODE_SRXFHINDIR) {
return do_srxfhindir(fd, &ifr);
- } else if (mode == MODE_SNTUPLE) {
- return do_srxntuple(fd, &ifr);
- } else if (mode == MODE_GNTUPLE) {
- return do_grxntuple(fd, &ifr);
+ } else if (mode == MODE_SCLSRULE) {
+ return do_srxclsrule(fd, &ifr);
+ } else if (mode == MODE_GCLSRULE) {
+ return do_grxclsrule(fd, &ifr);
} else if (mode == MODE_FLASHDEV) {
return do_flash(fd, &ifr);
} else if (mode == MODE_PERMADDR) {
@@ -3163,21 +3068,130 @@ static int do_permaddr(int fd, struct ifreq *ifr)
return err;
}
+static int flow_spec_to_ntuple(struct ethtool_rx_flow_spec *fsp,
+ struct ethtool_rx_ntuple_flow_spec *ntuple)
+{
+ int i;
+
+ /* verify location is not specified */
+ if (fsp->location != RX_CLS_LOC_UNSPEC)
+ return -1;
+
+ /* verify ring cookie can transfer to action */
+ if (fsp->ring_cookie > INT_MAX &&
+ ~fsp->ring_cookie > 1)
+ return -1;
+
+ /* verify only one field is setting data field */
+ if ((fsp->flow_type & FLOW_EXT) &&
+ (fsp->m_ext.data[0] || fsp->m_ext.data[1]) &&
+ fsp->m_ext.vlan_etype)
+ return -1;
+
+ /* initialize entire ntuple to all 0xFF */
+ memset(ntuple, ~0, sizeof(*ntuple));
+
+ /* set non-filter values */
+ ntuple->flow_type = fsp->flow_type;
+ ntuple->action = fsp->ring_cookie;
+
+ /* copy header portion over */
+ memcpy(&ntuple->h_u, &fsp->h_u, sizeof(fsp->h_u));
+
+ /* copy mask portion over and invert */
+ memcpy(&ntuple->m_u, &fsp->m_u, sizeof(fsp->m_u));
+ for (i = 0; i < sizeof(fsp->m_u); i++)
+ ntuple->m_u.hdata[i] ^= 0xFF;
+
+ /* copy extended fields */
+ if (fsp->flow_type & FLOW_EXT) {
+ ntuple->vlan_tag =
+ ntohs(fsp->h_ext.vlan_tci);
+ ntuple->vlan_tag_mask =
+ ~ntohs(fsp->m_ext.vlan_tci);
+ if (fsp->m_ext.vlan_etype) {
+ ntuple->data =
+ ntohl(fsp->h_ext.vlan_etype);
+ ntuple->data_mask =
+ ~(u64)ntohl(fsp->m_ext.vlan_etype);
+ } else {
+ ntuple->data =
+ (u64)ntohl(fsp->h_ext.data[0]);
+ ntuple->data |=
+ (u64)ntohl(fsp->h_ext.data[1]) << 32;
+ ntuple->data_mask =
+ (u64)ntohl(~fsp->m_ext.data[0]);
+ ntuple->data_mask |=
+ (u64)ntohl(~fsp->m_ext.data[1]) << 32;
+ }
+ }
+
+ return 0;
+}
+
static int do_srxntuple(int fd, struct ifreq *ifr)
{
+ struct ethtool_rx_ntuple ntuplecmd;
+ struct ethtool_value eval;
int err;
- if (sntuple_changed) {
- struct ethtool_rx_ntuple ntuplecmd;
+ /* verify if Ntuple is supported on the HW */
+ err = flow_spec_to_ntuple(&rx_rule_fs, &ntuplecmd.fs);
+ if (err)
+ return -1;
+
+ /*
+ * Check to see if the flag is set for N-tuple, this allows
+ * us to avoid the possible EINVAL response for the N-tuple
+ * flag not being set on the device
+ */
+ eval.cmd = ETHTOOL_GFLAGS;
+ ifr->ifr_data = (caddr_t)&eval;
+ err = ioctl(fd, SIOCETHTOOL, ifr);
+ if (err || !(eval.data & ETH_FLAG_NTUPLE))
+ return -1;
- ntuplecmd.cmd = ETHTOOL_SRXNTUPLE;
- memcpy(&ntuplecmd.fs, &ntuple_fs,
- sizeof(struct ethtool_rx_ntuple_flow_spec));
+ /* send rule via N-tuple */
+ ntuplecmd.cmd = ETHTOOL_SRXNTUPLE;
+ ifr->ifr_data = (caddr_t)&ntuplecmd;
+ err = ioctl(fd, SIOCETHTOOL, ifr);
- ifr->ifr_data = (caddr_t)&ntuplecmd;
- err = ioctl(fd, SIOCETHTOOL, ifr);
- if (err < 0)
- perror("Cannot add new RX n-tuple filter");
+ /*
+ * Display error only if reponse is something other than op not
+ * supported. It is possible that the interface uses the network
+ * flow classifier interface instead of N-tuple.
+ */
+ if (err && errno != EOPNOTSUPP)
+ perror("Cannot add new rule via N-tuple");
+
+ return err;
+}
+
+static int do_srxclsrule(int fd, struct ifreq *ifr)
+{
+ int err;
+
+ if (rx_class_rule_added) {
+ /* attempt to add rule via N-tuple specifier */
+ err = do_srxntuple(fd, ifr);
+ if (!err)
+ return 0;
+
+ /* attempt to add rule via network flow classifier */
+ err = rxclass_rule_ins(fd, ifr, &rx_rule_fs);
+ if (err < 0) {
+ fprintf(stderr, "Cannot insert"
+ " classification rule\n");
+ return 1;
+ }
+ } else if (rx_class_rule_del >= 0) {
+ err = rxclass_rule_del(fd, ifr, rx_class_rule_del);
+
+ if (err < 0) {
+ fprintf(stderr, "Cannot delete"
+ " classification rule\n");
+ return 1;
+ }
} else {
exit_bad_args();
}
@@ -3185,9 +3199,32 @@ static int do_srxntuple(int fd, struct ifreq *ifr)
return 0;
}
-static int do_grxntuple(int fd, struct ifreq *ifr)
+static int do_grxclsrule(int fd, struct ifreq *ifr)
{
- return 0;
+ struct ethtool_rxnfc nfccmd;
+ int err;
+
+ if (rx_class_rule_get >= 0) {
+ err = rxclass_rule_get(fd, ifr, rx_class_rule_get);
+ if (err < 0)
+ fprintf(stderr, "Cannot get RX classification rule\n");
+ return err ? 1 : 0;
+ }
+
+ nfccmd.cmd = ETHTOOL_GRXRINGS;
+ ifr->ifr_data = (caddr_t)&nfccmd;
+ err = ioctl(fd, SIOCETHTOOL, ifr);
+ if (err < 0)
+ perror("Cannot get RX rings");
+ else
+ fprintf(stdout, "%d RX rings available\n",
+ (int)nfccmd.data);
+
+ err = rxclass_rule_getall(fd, ifr);
+ if (err < 0)
+ fprintf(stderr, "RX classification rule retrieval failed\n");
+
+ return err ? 1 : 0;
}
static int send_ioctl(int fd, struct ifreq *ifr)
diff --git a/rxclass.c b/rxclass.c
new file mode 100644
index 0000000..5ad0639
--- /dev/null
+++ b/rxclass.c
@@ -0,0 +1,1106 @@
+/*
+ * Copyright (C) 2008 Sun Microsystems, Inc. All rights reserved.
+ */
+#include <stdio.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <linux/sockios.h>
+#include <arpa/inet.h>
+#include "ethtool-util.h"
+#include "ethtool-bitops.h"
+
+/*
+ * This is a rule manager implementation for ordering rx flow
+ * classification rules in a longest prefix first match order.
+ * The assumption is that this rule manager is the only one adding rules to
+ * the device's hardware classifier.
+ */
+
+struct rmgr_ctrl {
+ /* slot contains a bitmap indicating which filters are valid */
+ unsigned long *slot;
+ __u32 n_rules;
+ __u32 size;
+};
+
+static struct rmgr_ctrl rmgr;
+static int rmgr_init_done = 0;
+
+static void invert_flow_mask(struct ethtool_rx_flow_spec *fsp)
+{
+ int i;
+
+ for (i = 0; i < sizeof(fsp->m_u); i++)
+ fsp->m_u.hdata[i] ^= 0xFF;
+}
+
+static void rmgr_print_nfc_spec_ext(struct ethtool_rx_flow_spec *fsp)
+{
+ u64 data, datam;
+ __u16 etype, etypem, tci, tcim;
+
+ if (!(fsp->flow_type & FLOW_EXT))
+ return;
+
+ etype = ntohs(fsp->h_ext.vlan_etype);
+ etypem = ntohs(~fsp->m_ext.vlan_etype);
+ tci = ntohs(fsp->h_ext.vlan_tci);
+ tcim = ntohs(~fsp->m_ext.vlan_tci);
+ data = (u64)ntohl(fsp->h_ext.data[0]) << 32;
+ data = (u64)ntohl(fsp->h_ext.data[1]);
+ datam = (u64)ntohl(~fsp->m_ext.data[0]) << 32;
+ datam |= (u64)ntohl(~fsp->m_ext.data[1]);
+
+ fprintf(stdout,
+ "\tVLAN EtherType: 0x%x mask: 0x%x\n"
+ "\tVLAN: 0x%x mask: 0x%x\n"
+ "\tUser-defined: 0x%Lx mask: 0x%Lx\n",
+ etype, etypem, tci, tcim, data, datam);
+}
+
+static void rmgr_print_nfc_rule(struct ethtool_rx_flow_spec *fsp)
+{
+ unsigned char *smac, *smacm, *dmac, *dmacm;
+ __u32 sip, dip, sipm, dipm, flow_type;
+ __u16 proto, protom;
+
+ if (fsp->location != RX_CLS_LOC_UNSPEC)
+ fprintf(stdout, "Filter: %d\n", fsp->location);
+ else
+ fprintf(stdout, "Filter: Unspecified\n");
+
+ flow_type = fsp->flow_type & ~FLOW_EXT;
+
+ invert_flow_mask(fsp);
+
+ switch (flow_type) {
+ case TCP_V4_FLOW:
+ case UDP_V4_FLOW:
+ case SCTP_V4_FLOW:
+ case AH_V4_FLOW:
+ case ESP_V4_FLOW:
+ case IP_USER_FLOW:
+ sip = ntohl(fsp->h_u.tcp_ip4_spec.ip4src);
+ dip = ntohl(fsp->h_u.tcp_ip4_spec.ip4dst);
+ sipm = ntohl(fsp->m_u.tcp_ip4_spec.ip4src);
+ dipm = ntohl(fsp->m_u.tcp_ip4_spec.ip4dst);
+
+ switch (flow_type) {
+ case TCP_V4_FLOW:
+ fprintf(stdout, "\tRule Type: TCP over IPv4\n");
+ break;
+ case UDP_V4_FLOW:
+ fprintf(stdout, "\tRule Type: UDP over IPv4\n");
+ break;
+ case SCTP_V4_FLOW:
+ fprintf(stdout, "\tRule Type: SCTP over IPv4\n");
+ break;
+ case AH_V4_FLOW:
+ fprintf(stdout, "\tRule Type: IPSEC AH over IPv4\n");
+ break;
+ case ESP_V4_FLOW:
+ fprintf(stdout, "\tRule Type: IPSEC ESP over IPv4\n");
+ break;
+ case IP_USER_FLOW:
+ fprintf(stdout, "\tRule Type: Raw IPv4\n");
+ break;
+ default:
+ break;
+ }
+
+ fprintf(stdout,
+ "\tSrc IP addr: %d.%d.%d.%d mask: %d.%d.%d.%d\n"
+ "\tDest IP addr: %d.%d.%d.%d mask: %d.%d.%d.%d\n"
+ "\tTOS: 0x%x mask: 0x%x\n",
+ (sip & 0xff000000) >> 24,
+ (sip & 0xff0000) >> 16,
+ (sip & 0xff00) >> 8,
+ sip & 0xff,
+ (sipm & 0xff000000) >> 24,
+ (sipm & 0xff0000) >> 16,
+ (sipm & 0xff00) >> 8,
+ sipm & 0xff,
+ (dip & 0xff000000) >> 24,
+ (dip & 0xff0000) >> 16,
+ (dip & 0xff00) >> 8,
+ dip & 0xff,
+ (dipm & 0xff000000) >> 24,
+ (dipm & 0xff0000) >> 16,
+ (dipm & 0xff00) >> 8,
+ dipm & 0xff,
+ fsp->h_u.tcp_ip4_spec.tos,
+ fsp->m_u.tcp_ip4_spec.tos);
+
+ switch (flow_type) {
+ case TCP_V4_FLOW:
+ case UDP_V4_FLOW:
+ case SCTP_V4_FLOW:
+ fprintf(stdout,
+ "\tSrc port: %d mask: 0x%x\n"
+ "\tDest port: %d mask: 0x%x\n",
+ ntohs(fsp->h_u.tcp_ip4_spec.psrc),
+ ntohs(fsp->m_u.tcp_ip4_spec.psrc),
+ ntohs(fsp->h_u.tcp_ip4_spec.pdst),
+ ntohs(fsp->m_u.tcp_ip4_spec.pdst));
+ break;
+ case AH_V4_FLOW:
+ case ESP_V4_FLOW:
+ fprintf(stdout,
+ "\tSPI: %d mask: 0x%x\n",
+ ntohl(fsp->h_u.esp_ip4_spec.spi),
+ ntohl(fsp->m_u.esp_ip4_spec.spi));
+ break;
+ case IP_USER_FLOW:
+ fprintf(stdout,
+ "\tProtocol: %d mask: 0x%x\n"
+ "\tL4 bytes: 0x%x mask: 0x%x\n",
+ fsp->h_u.usr_ip4_spec.proto,
+ fsp->m_u.usr_ip4_spec.proto,
+ ntohl(fsp->h_u.usr_ip4_spec.l4_4_bytes),
+ ntohl(fsp->m_u.usr_ip4_spec.l4_4_bytes));
+ break;
+ default:
+ break;
+ }
+ rmgr_print_nfc_spec_ext(fsp);
+ break;
+ case ETHER_FLOW:
+ dmac = fsp->h_u.ether_spec.h_dest;
+ dmacm = fsp->m_u.ether_spec.h_dest;
+ smac = fsp->h_u.ether_spec.h_source;
+ smacm = fsp->m_u.ether_spec.h_source;
+ proto = ntohs(fsp->h_u.ether_spec.h_proto);
+ protom = ntohs(fsp->m_u.ether_spec.h_proto);
+
+ fprintf(stdout,
+ "\tFlow Type: Raw Ethernet\n"
+ "\tSrc MAC addr: %02X:%02X:%02X:%02X:%02X:%02X"
+ " mask: %02X:%02X:%02X:%02X:%02X:%02X\n"
+ "\tDest MAC addr: %02X:%02X:%02X:%02X:%02X:%02X"
+ " mask: %02X:%02X:%02X:%02X:%02X:%02X\n"
+ "\tEthertype: 0x%X mask: 0x%X\n",
+ smac[0], smac[1], smac[2], smac[3], smac[4], smac[5],
+ smacm[0], smacm[1], smacm[2], smacm[3], smacm[4],
+ smacm[5], dmac[0], dmac[1], dmac[2], dmac[3], dmac[4],
+ dmac[5], dmacm[0], dmacm[1], dmacm[2], dmacm[3],
+ dmacm[4], dmacm[5], proto, protom);
+ rmgr_print_nfc_spec_ext(fsp);
+ break;
+ default:
+ fprintf(stdout,
+ "\tUnknown Flow type: %d\n", flow_type);
+ break;
+ }
+
+ if (fsp->ring_cookie != RX_CLS_FLOW_DISC)
+ fprintf(stdout, "\tAction: Direct to queue %llu\n",
+ fsp->ring_cookie);
+ else
+ fprintf(stdout, "\tAction: Drop\n");
+
+ fprintf(stdout, "\n");
+}
+
+static void rmgr_print_rule(struct ethtool_rx_flow_spec *fsp)
+{
+ /* print the rule in this location */
+ switch (fsp->flow_type & ~FLOW_EXT) {
+ case TCP_V4_FLOW:
+ case UDP_V4_FLOW:
+ case SCTP_V4_FLOW:
+ case AH_V4_FLOW:
+ case ESP_V4_FLOW:
+ case ETHER_FLOW:
+ rmgr_print_nfc_rule(fsp);
+ break;
+ case IP_USER_FLOW:
+ if (fsp->h_u.usr_ip4_spec.ip_ver == ETH_RX_NFC_IP4) {
+ rmgr_print_nfc_rule(fsp);
+ break;
+ }
+ /* IPv6 User Flow falls through to the case below */
+ case TCP_V6_FLOW:
+ case UDP_V6_FLOW:
+ case SCTP_V6_FLOW:
+ case AH_V6_FLOW:
+ case ESP_V6_FLOW:
+ fprintf(stderr, "IPv6 flows not implemented\n");
+ break;
+ default:
+ fprintf(stderr, "rmgr: Unknown flow type\n");
+ break;
+ }
+}
+
+static int rmgr_ins(__u32 loc)
+{
+ /* verify location is in rule manager range */
+ if ((loc < 0) || (loc >= rmgr.size)) {
+ fprintf(stderr, "rmgr: Location out of range\n");
+ return -1;
+ }
+
+ /* set bit for the rule */
+ set_bit(loc, rmgr.slot);
+
+ return 0;
+}
+
+static int rmgr_find(__u32 loc)
+{
+ /* verify location is in rule manager range */
+ if ((loc < 0) || (loc >= rmgr.size)) {
+ fprintf(stderr, "rmgr: Location out of range\n");
+ return -1;
+ }
+
+ /* if slot is found return 0 indicating success */
+ if (test_bit(loc, rmgr.slot))
+ return 0;
+
+ /* rule not found */
+ fprintf(stderr, "rmgr: No such rule\n");
+ return -1;
+}
+
+static int rmgr_del(__u32 loc)
+{
+ /* verify rule exists before attempting to delete */
+ int err = rmgr_find(loc);
+ if (err)
+ return err;
+
+ /* clear bit for the rule */
+ clear_bit(loc, rmgr.slot);
+
+ return 0;
+}
+
+static int rmgr_add(struct ethtool_rx_flow_spec *fsp)
+{
+ __u32 loc = fsp->location;
+
+ /* location provided, insert rule and update regions to match rule */
+ if (loc != RX_CLS_LOC_UNSPEC)
+ return rmgr_ins(loc);
+
+ /* start at the end of the list since it is lowest priority */
+ loc = rmgr.size - 1;
+
+ /* only part of last word is set so fill in remaining bits and test */
+ if (!~(rmgr.slot[loc / BITS_PER_LONG] |
+ (~1UL << (loc % BITS_PER_LONG))))
+ loc -= 1 + (loc % BITS_PER_LONG);
+
+ /* find an open slot */
+ while (loc != RX_CLS_LOC_UNSPEC && !~rmgr.slot[loc / BITS_PER_LONG])
+ loc -= BITS_PER_LONG;
+
+ /* find and use available location in slot */
+ while (loc != RX_CLS_LOC_UNSPEC && test_bit(loc, rmgr.slot))
+ loc--;
+
+ /* location found, insert rule */
+ if (loc != RX_CLS_LOC_UNSPEC) {
+ fsp->location = loc;
+ return rmgr_ins(loc);
+ }
+
+ /* No space to add this rule */
+ fprintf(stderr, "rmgr: Cannot find appropriate slot to insert rule\n");
+
+ return -1;
+}
+
+static int rmgr_init(int fd, struct ifreq *ifr)
+{
+ struct ethtool_rxnfc *nfccmd;
+ int err, i;
+ __u32 *rule_locs;
+
+ if (rmgr_init_done)
+ return 0;
+
+ /* clear rule manager settings */
+ memset(&rmgr, 0, sizeof(struct rmgr_ctrl));
+
+ /* allocate memory for count request */
+ nfccmd = calloc(1, sizeof(*nfccmd));
+ if (!nfccmd) {
+ perror("rmgr: Cannot allocate memory for RX class rule data");
+ return -1;
+ }
+
+ /* request count and store in rmgr.n_rules */
+ nfccmd->cmd = ETHTOOL_GRXCLSRLCNT;
+ ifr->ifr_data = (caddr_t)nfccmd;
+ err = ioctl(fd, SIOCETHTOOL, ifr);
+ rmgr.n_rules = nfccmd->rule_cnt;
+ free(nfccmd);
+ if (err < 0) {
+ perror("rmgr: Cannot get RX class rule count");
+ return -1;
+ }
+
+ /* alloc memory for request of location list */
+ nfccmd = calloc(1, sizeof(*nfccmd) + (rmgr.n_rules * sizeof(__u32)));
+ if (!nfccmd) {
+ perror("rmgr: Cannot allocate memory for"
+ " RX class rule locations");
+ return -1;
+ }
+
+ /* request location list */
+ nfccmd->cmd = ETHTOOL_GRXCLSRLALL;
+ nfccmd->rule_cnt = rmgr.n_rules;
+ ifr->ifr_data = (caddr_t)nfccmd;
+ err = ioctl(fd, SIOCETHTOOL, ifr);
+ if (err < 0) {
+ perror("rmgr: Cannot get RX class rules");
+ free(nfccmd);
+ return -1;
+ }
+
+ /* intitialize bitmap for storage of valid locations */
+ rmgr.size = nfccmd->data;
+ rmgr.slot = calloc(1, BITS_TO_LONGS(rmgr.size) * sizeof(long));
+ if (!rmgr.slot) {
+ perror("rmgr: Cannot allocate memory for RX class rules");
+ return -1;
+ }
+
+ /* write locations to bitmap */
+ rule_locs = nfccmd->rule_locs;
+ for (i = 0; i < rmgr.n_rules; i++) {
+ err = rmgr_ins(rule_locs[i]);
+ if (err < 0)
+ break;
+ }
+
+ /* free memory and set flag to avoid reinit */
+ free(nfccmd);
+ rmgr_init_done = 1;
+
+ return err;
+}
+
+static void rmgr_cleanup(void)
+{
+ if (!rmgr_init_done)
+ return;
+
+ rmgr_init_done = 0;
+
+ free(rmgr.slot);
+ rmgr.slot = NULL;
+ rmgr.size = 0;
+}
+
+int rxclass_rule_getall(int fd, struct ifreq *ifr)
+{
+ struct ethtool_rxnfc nfccmd;
+ int err, i, j;
+
+ /* init table of available rules */
+ err = rmgr_init(fd, ifr);
+ if (err < 0)
+ return err;
+
+ fprintf(stdout, "Total %d rules\n\n", rmgr.n_rules);
+
+ /* fetch and display all available rules */
+ for (i = 0; i < rmgr.size; i += BITS_PER_LONG) {
+ if (!~rmgr.slot[i / BITS_PER_LONG])
+ continue;
+ for (j = 0; j < BITS_PER_LONG; j++) {
+ if (!test_bit(i + j, rmgr.slot))
+ continue;
+ nfccmd.cmd = ETHTOOL_GRXCLSRULE;
+ memset(&nfccmd.fs, 0,
+ sizeof(struct ethtool_rx_flow_spec));
+ nfccmd.fs.location = i + j;
+ ifr->ifr_data = (caddr_t)&nfccmd;
+ err = ioctl(fd, SIOCETHTOOL, ifr);
+ if (err < 0) {
+ perror("rmgr: Cannot get RX class rule");
+ return -1;
+ }
+ rmgr_print_rule(&nfccmd.fs);
+ }
+ }
+
+ rmgr_cleanup();
+
+ return 0;
+}
+
+int rxclass_rule_get(int fd, struct ifreq *ifr, __u32 loc)
+{
+ struct ethtool_rxnfc nfccmd;
+ int err;
+
+ /* init table of available rules */
+ err = rmgr_init(fd, ifr);
+ if (err < 0)
+ return err;
+
+ /* verify rule exists before attempting to display */
+ err = rmgr_find(loc);
+ if (err < 0)
+ return err;
+
+ /* fetch rule from netdev and display */
+ nfccmd.cmd = ETHTOOL_GRXCLSRULE;
+ memset(&nfccmd.fs, 0, sizeof(struct ethtool_rx_flow_spec));
+ nfccmd.fs.location = loc;
+ ifr->ifr_data = (caddr_t)&nfccmd;
+ err = ioctl(fd, SIOCETHTOOL, ifr);
+ if (err < 0) {
+ perror("rmgr: Cannot get RX class rule");
+ return -1;
+ }
+ rmgr_print_rule(&nfccmd.fs);
+
+ rmgr_cleanup();
+
+ return 0;
+}
+
+int rxclass_rule_ins(int fd, struct ifreq *ifr,
+ struct ethtool_rx_flow_spec *fsp)
+{
+ struct ethtool_rxnfc nfccmd;
+ int err;
+
+ /* init table of available rules */
+ err = rmgr_init(fd, ifr);
+ if (err < 0)
+ return err;
+
+ /* verify rule location */
+ err = rmgr_add(fsp);
+ if (err < 0)
+ return err;
+
+ /* notify netdev of new rule */
+ nfccmd.cmd = ETHTOOL_SRXCLSRLINS;
+ nfccmd.fs = *fsp;
+ ifr->ifr_data = (caddr_t)&nfccmd;
+ err = ioctl(fd, SIOCETHTOOL, ifr);
+ if (err < 0) {
+ perror("rmgr: Cannot insert RX class rule");
+ return -1;
+ }
+ rmgr.n_rules++;
+
+ printf("Added rule with ID %d\n", fsp->location);
+
+ rmgr_cleanup();
+
+ return 0;
+}
+
+int rxclass_rule_del(int fd, struct ifreq *ifr, __u32 loc)
+{
+ struct ethtool_rxnfc nfccmd;
+ int err;
+
+ /* init table of available rules */
+ err = rmgr_init(fd, ifr);
+ if (err < 0)
+ return err;
+
+ /* verify rule exists */
+ err = rmgr_del(loc);
+ if (err < 0)
+ return err;
+
+ /* notify netdev of rule removal */
+ nfccmd.cmd = ETHTOOL_SRXCLSRLDEL;
+ nfccmd.fs.location = loc;
+ ifr->ifr_data = (caddr_t)&nfccmd;
+ err = ioctl(fd, SIOCETHTOOL, ifr);
+ if (err < 0) {
+ perror("rmgr: Cannot delete RX class rule");
+ return -1;
+ }
+ rmgr.n_rules--;
+
+ rmgr_cleanup();
+
+ return 0;
+}
+
+typedef enum {
+ OPT_NONE = 0,
+ OPT_S32,
+ OPT_U8,
+ OPT_U16,
+ OPT_U32,
+ OPT_U64,
+ OPT_BE16,
+ OPT_BE32,
+ OPT_BE64,
+ OPT_IP4,
+ OPT_MAC,
+} rule_opt_type_t;
+
+#define NFC_FLAG_RING 0x001
+#define NFC_FLAG_LOC 0x002
+#define NFC_FLAG_SADDR 0x004
+#define NFC_FLAG_DADDR 0x008
+#define NFC_FLAG_SPORT 0x010
+#define NFC_FLAG_DPORT 0x020
+#define NFC_FLAG_SPI 0x030
+#define NFC_FLAG_TOS 0x040
+#define NFC_FLAG_PROTO 0x080
+#define NTUPLE_FLAG_VLAN 0x100
+#define NTUPLE_FLAG_UDEF 0x200
+#define NTUPLE_FLAG_VETH 0x400
+
+struct rule_opts {
+ const char *name;
+ rule_opt_type_t type;
+ u32 flag;
+ int offset;
+ int moffset;
+};
+
+static struct rule_opts rule_nfc_tcp_ip4[] = {
+ { "src-ip", OPT_IP4, NFC_FLAG_SADDR,
+ offsetof(struct ethtool_rx_flow_spec, h_u.tcp_ip4_spec.ip4src),
+ offsetof(struct ethtool_rx_flow_spec, m_u.tcp_ip4_spec.ip4src) },
+ { "dst-ip", OPT_IP4, NFC_FLAG_DADDR,
+ offsetof(struct ethtool_rx_flow_spec, h_u.tcp_ip4_spec.ip4dst),
+ offsetof(struct ethtool_rx_flow_spec, m_u.tcp_ip4_spec.ip4dst) },
+ { "tos", OPT_U8, NFC_FLAG_TOS,
+ offsetof(struct ethtool_rx_flow_spec, h_u.tcp_ip4_spec.tos),
+ offsetof(struct ethtool_rx_flow_spec, m_u.tcp_ip4_spec.tos) },
+ { "src-port", OPT_BE16, NFC_FLAG_SPORT,
+ offsetof(struct ethtool_rx_flow_spec, h_u.tcp_ip4_spec.psrc),
+ offsetof(struct ethtool_rx_flow_spec, m_u.tcp_ip4_spec.psrc) },
+ { "dst-port", OPT_BE16, NFC_FLAG_DPORT,
+ offsetof(struct ethtool_rx_flow_spec, h_u.tcp_ip4_spec.pdst),
+ offsetof(struct ethtool_rx_flow_spec, m_u.tcp_ip4_spec.pdst) },
+ { "action", OPT_U64, NFC_FLAG_RING,
+ offsetof(struct ethtool_rx_flow_spec, ring_cookie), -1 },
+ { "loc", OPT_U32, NFC_FLAG_LOC,
+ offsetof(struct ethtool_rx_flow_spec, location), -1 },
+ { "vlan-etype", OPT_BE16, NTUPLE_FLAG_VETH,
+ offsetof(struct ethtool_rx_flow_spec, h_ext.vlan_etype),
+ offsetof(struct ethtool_rx_flow_spec, m_ext.vlan_etype) },
+ { "vlan", OPT_BE16, NTUPLE_FLAG_VLAN,
+ offsetof(struct ethtool_rx_flow_spec, h_ext.vlan_tci),
+ offsetof(struct ethtool_rx_flow_spec, m_ext.vlan_tci) },
+ { "user-def", OPT_BE64, NTUPLE_FLAG_UDEF,
+ offsetof(struct ethtool_rx_flow_spec, h_ext.data),
+ offsetof(struct ethtool_rx_flow_spec, m_ext.data) },
+};
+
+static struct rule_opts rule_nfc_esp_ip4[] = {
+ { "src-ip", OPT_IP4, NFC_FLAG_SADDR,
+ offsetof(struct ethtool_rx_flow_spec, h_u.esp_ip4_spec.ip4src),
+ offsetof(struct ethtool_rx_flow_spec, m_u.esp_ip4_spec.ip4src) },
+ { "dst-ip", OPT_IP4, NFC_FLAG_DADDR,
+ offsetof(struct ethtool_rx_flow_spec, h_u.esp_ip4_spec.ip4dst),
+ offsetof(struct ethtool_rx_flow_spec, m_u.esp_ip4_spec.ip4dst) },
+ { "tos", OPT_U8, NFC_FLAG_TOS,
+ offsetof(struct ethtool_rx_flow_spec, h_u.esp_ip4_spec.tos),
+ offsetof(struct ethtool_rx_flow_spec, m_u.esp_ip4_spec.tos) },
+ { "spi", OPT_BE32, NFC_FLAG_SPI,
+ offsetof(struct ethtool_rx_flow_spec, h_u.esp_ip4_spec.spi),
+ offsetof(struct ethtool_rx_flow_spec, m_u.esp_ip4_spec.spi) },
+ { "action", OPT_U64, NFC_FLAG_RING,
+ offsetof(struct ethtool_rx_flow_spec, ring_cookie), -1 },
+ { "loc", OPT_U32, NFC_FLAG_LOC,
+ offsetof(struct ethtool_rx_flow_spec, location), -1 },
+ { "vlan-etype", OPT_BE16, NTUPLE_FLAG_VETH,
+ offsetof(struct ethtool_rx_flow_spec, h_ext.vlan_etype),
+ offsetof(struct ethtool_rx_flow_spec, m_ext.vlan_etype) },
+ { "vlan", OPT_BE16, NTUPLE_FLAG_VLAN,
+ offsetof(struct ethtool_rx_flow_spec, h_ext.vlan_tci),
+ offsetof(struct ethtool_rx_flow_spec, m_ext.vlan_tci) },
+ { "user-def", OPT_BE64, NTUPLE_FLAG_UDEF,
+ offsetof(struct ethtool_rx_flow_spec, h_ext.data),
+ offsetof(struct ethtool_rx_flow_spec, m_ext.data) },
+};
+
+static struct rule_opts rule_nfc_usr_ip4[] = {
+ { "src-ip", OPT_IP4, NFC_FLAG_SADDR,
+ offsetof(struct ethtool_rx_flow_spec, h_u.usr_ip4_spec.ip4src),
+ offsetof(struct ethtool_rx_flow_spec, m_u.usr_ip4_spec.ip4src) },
+ { "dst-ip", OPT_IP4, NFC_FLAG_DADDR,
+ offsetof(struct ethtool_rx_flow_spec, h_u.usr_ip4_spec.ip4dst),
+ offsetof(struct ethtool_rx_flow_spec, m_u.usr_ip4_spec.ip4dst) },
+ { "tos", OPT_U8, NFC_FLAG_TOS,
+ offsetof(struct ethtool_rx_flow_spec, h_u.usr_ip4_spec.tos),
+ offsetof(struct ethtool_rx_flow_spec, m_u.usr_ip4_spec.tos) },
+ { "l4proto", OPT_U8, NFC_FLAG_PROTO,
+ offsetof(struct ethtool_rx_flow_spec, h_u.usr_ip4_spec.proto),
+ offsetof(struct ethtool_rx_flow_spec, m_u.usr_ip4_spec.proto) },
+ { "spi", OPT_BE32, NFC_FLAG_SPI,
+ offsetof(struct ethtool_rx_flow_spec, h_u.usr_ip4_spec.l4_4_bytes),
+ offsetof(struct ethtool_rx_flow_spec, m_u.usr_ip4_spec.l4_4_bytes) },
+ { "src-port", OPT_BE16, NFC_FLAG_SPORT,
+ offsetof(struct ethtool_rx_flow_spec, h_u.usr_ip4_spec.l4_4_bytes),
+ offsetof(struct ethtool_rx_flow_spec, m_u.usr_ip4_spec.l4_4_bytes) },
+ { "dst-port", OPT_BE16, NFC_FLAG_DPORT,
+ offsetof(struct ethtool_rx_flow_spec, h_u.usr_ip4_spec.l4_4_bytes) + 2,
+ offsetof(struct ethtool_rx_flow_spec, m_u.usr_ip4_spec.l4_4_bytes) + 2 },
+ { "action", OPT_U64, NFC_FLAG_RING,
+ offsetof(struct ethtool_rx_flow_spec, ring_cookie), -1 },
+ { "loc", OPT_U32, NFC_FLAG_LOC,
+ offsetof(struct ethtool_rx_flow_spec, location), -1 },
+ { "vlan-etype", OPT_BE16, NTUPLE_FLAG_VETH,
+ offsetof(struct ethtool_rx_flow_spec, h_ext.vlan_etype),
+ offsetof(struct ethtool_rx_flow_spec, m_ext.vlan_etype) },
+ { "vlan", OPT_BE16, NTUPLE_FLAG_VLAN,
+ offsetof(struct ethtool_rx_flow_spec, h_ext.vlan_tci),
+ offsetof(struct ethtool_rx_flow_spec, m_ext.vlan_tci) },
+ { "user-def", OPT_BE64, NTUPLE_FLAG_UDEF,
+ offsetof(struct ethtool_rx_flow_spec, h_ext.data),
+ offsetof(struct ethtool_rx_flow_spec, m_ext.data) },
+};
+
+static struct rule_opts rule_nfc_ether[] = {
+ { "src", OPT_MAC, NFC_FLAG_SADDR,
+ offsetof(struct ethtool_rx_flow_spec, h_u.ether_spec.h_dest),
+ offsetof(struct ethtool_rx_flow_spec, m_u.ether_spec.h_dest) },
+ { "dst", OPT_MAC, NFC_FLAG_DADDR,
+ offsetof(struct ethtool_rx_flow_spec, h_u.ether_spec.h_source),
+ offsetof(struct ethtool_rx_flow_spec, m_u.ether_spec.h_source) },
+ { "proto", OPT_BE16, NFC_FLAG_PROTO,
+ offsetof(struct ethtool_rx_flow_spec, h_u.ether_spec.h_proto),
+ offsetof(struct ethtool_rx_flow_spec, m_u.ether_spec.h_proto) },
+ { "action", OPT_U64, NFC_FLAG_RING,
+ offsetof(struct ethtool_rx_flow_spec, ring_cookie), -1 },
+ { "loc", OPT_U32, NFC_FLAG_LOC,
+ offsetof(struct ethtool_rx_flow_spec, location), -1 },
+ { "vlan-etype", OPT_BE16, NTUPLE_FLAG_VETH,
+ offsetof(struct ethtool_rx_flow_spec, h_ext.vlan_etype),
+ offsetof(struct ethtool_rx_flow_spec, m_ext.vlan_etype) },
+ { "vlan", OPT_BE16, NTUPLE_FLAG_VLAN,
+ offsetof(struct ethtool_rx_flow_spec, h_ext.vlan_tci),
+ offsetof(struct ethtool_rx_flow_spec, m_ext.vlan_tci) },
+ { "user-def", OPT_BE64, NTUPLE_FLAG_UDEF,
+ offsetof(struct ethtool_rx_flow_spec, h_ext.data),
+ offsetof(struct ethtool_rx_flow_spec, m_ext.data) },
+};
+
+static int rxclass_get_long(char *str, long long *val, int size)
+{
+ long long max = ~0ULL >> (65 - size);
+ char *endp;
+
+ errno = 0;
+
+ *val = strtoll(str, &endp, 0);
+
+ if (*endp || errno || (*val > max) || (*val < ~max))
+ return -1;
+
+ return 0;
+}
+
+static int rxclass_get_ulong(char *str, unsigned long long *val, int size)
+{
+ long long max = ~0ULL >> (64 - size);
+ char *endp;
+
+ errno = 0;
+
+ *val = strtoull(str, &endp, 0);
+
+ if (*endp || errno || (*val > max))
+ return -1;
+
+ return 0;
+}
+
+static int rxclass_get_ipv4(char *str, __be32 *val)
+{
+ if (!strchr(str, '.')) {
+ unsigned long long v;
+ int err;
+
+ err = rxclass_get_ulong(str, &v, 32);
+ if (err)
+ return -1;
+
+ *val = htonl((u32)v);
+
+ return 0;
+ }
+
+ if (!inet_pton(AF_INET, str, val))
+ return -1;
+
+ return 0;
+}
+
+static int rxclass_get_ether(char *str, unsigned char *val)
+{
+ unsigned int buf[ETH_ALEN];
+ int count;
+
+ if (!strchr(str, ':'))
+ return -1;
+
+ count = sscanf(str, "%2x:%2x:%2x:%2x:%2x:%2x",
+ &buf[0], &buf[1], &buf[2],
+ &buf[3], &buf[4], &buf[5]);
+
+ if (count != ETH_ALEN)
+ return -1;
+
+ do {
+ count--;
+ val[count] = buf[count];
+ } while (count);
+
+ return 0;
+}
+
+static int rxclass_get_val(char *str, unsigned char *p, u32 *flags,
+ const struct rule_opts *opt)
+{
+ unsigned long long mask = ~0ULL;
+ int err = 0;
+
+ if (*flags & opt->flag)
+ return -1;
+
+ *flags |= opt->flag;
+
+ switch (opt->type) {
+ case OPT_S32: {
+ long long val;
+ err = rxclass_get_long(str, &val, 32);
+ if (err)
+ return -1;
+ *(int *)&p[opt->offset] = (int)val;
+ if (opt->moffset >= 0)
+ *(int *)&p[opt->moffset] = (int)mask;
+ break;
+ }
+ case OPT_U8: {
+ unsigned long long val;
+ err = rxclass_get_ulong(str, &val, 8);
+ if (err)
+ return -1;
+ *(u8 *)&p[opt->offset] = (u8)val;
+ if (opt->moffset >= 0)
+ *(u8 *)&p[opt->moffset] = (u8)mask;
+ break;
+ }
+ case OPT_U16: {
+ unsigned long long val;
+ err = rxclass_get_ulong(str, &val, 16);
+ if (err)
+ return -1;
+ *(u16 *)&p[opt->offset] = (u16)val;
+ if (opt->moffset >= 0)
+ *(u16 *)&p[opt->moffset] = (u16)mask;
+ break;
+ }
+ case OPT_U32: {
+ unsigned long long val;
+ err = rxclass_get_ulong(str, &val, 32);
+ if (err)
+ return -1;
+ *(u32 *)&p[opt->offset] = (u32)val;
+ if (opt->moffset >= 0)
+ *(u32 *)&p[opt->moffset] = (u32)mask;
+ break;
+ }
+ case OPT_U64: {
+ unsigned long long val;
+ err = rxclass_get_ulong(str, &val, 64);
+ if (err)
+ return -1;
+ *(u64 *)&p[opt->offset] = (u64)val;
+ if (opt->moffset >= 0)
+ *(u64 *)&p[opt->moffset] = (u64)mask;
+ break;
+ }
+ case OPT_BE16: {
+ unsigned long long val;
+ err = rxclass_get_ulong(str, &val, 16);
+ if (err)
+ return -1;
+ *(__be16 *)&p[opt->offset] = htons((u16)val);
+ if (opt->moffset >= 0)
+ *(__be16 *)&p[opt->moffset] = (__be16)mask;
+ break;
+ }
+ case OPT_BE32: {
+ unsigned long long val;
+ err = rxclass_get_ulong(str, &val, 32);
+ if (err)
+ return -1;
+ *(__be32 *)&p[opt->offset] = htonl((u32)val);
+ if (opt->moffset >= 0)
+ *(__be32 *)&p[opt->moffset] = (__be32)mask;
+ break;
+ }
+ case OPT_BE64: {
+ unsigned long long val;
+ err = rxclass_get_ulong(str, &val, 64);
+ if (err)
+ return -1;
+ *(__be64 *)&p[opt->offset] = htonll((u64)val);
+ if (opt->moffset >= 0)
+ *(__be64 *)&p[opt->moffset] = (__be64)mask;
+ break;
+ }
+ case OPT_IP4: {
+ __be32 val;
+ err = rxclass_get_ipv4(str, &val);
+ if (err)
+ return -1;
+ *(__be32 *)&p[opt->offset] = val;
+ if (opt->moffset >= 0)
+ *(__be32 *)&p[opt->moffset] = (__be32)mask;
+ break;
+ }
+ case OPT_MAC: {
+ unsigned char val[ETH_ALEN];
+ err = rxclass_get_ether(str, val);
+ if (err)
+ return -1;
+ memcpy(&p[opt->offset], val, ETH_ALEN);
+ if (opt->moffset >= 0)
+ memcpy(&p[opt->moffset], &mask, ETH_ALEN);
+ break;
+ }
+ case OPT_NONE:
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
+static int rxclass_get_mask(char *str, unsigned char *p,
+ const struct rule_opts *opt)
+{
+ int err = 0;
+
+ if (opt->moffset < 0)
+ return -1;
+
+ switch (opt->type) {
+ case OPT_S32: {
+ long long val;
+ err = rxclass_get_long(str, &val, 32);
+ if (err)
+ return -1;
+ *(int *)&p[opt->moffset] = ~(int)val;
+ break;
+ }
+ case OPT_U8: {
+ unsigned long long val;
+ err = rxclass_get_ulong(str, &val, 8);
+ if (err)
+ return -1;
+ *(u8 *)&p[opt->moffset] = ~(u8)val;
+ break;
+ }
+ case OPT_U16: {
+ unsigned long long val;
+ err = rxclass_get_ulong(str, &val, 16);
+ if (err)
+ return -1;
+ *(u16 *)&p[opt->moffset] = ~(u16)val;
+ break;
+ }
+ case OPT_U32: {
+ unsigned long long val;
+ err = rxclass_get_ulong(str, &val, 32);
+ if (err)
+ return -1;
+ *(u32 *)&p[opt->moffset] = ~(u32)val;
+ break;
+ }
+ case OPT_U64: {
+ unsigned long long val;
+ err = rxclass_get_ulong(str, &val, 64);
+ if (err)
+ return -1;
+ *(u64 *)&p[opt->moffset] = ~(u64)val;
+ break;
+ }
+ case OPT_BE16: {
+ unsigned long long val;
+ err = rxclass_get_ulong(str, &val, 16);
+ if (err)
+ return -1;
+ *(__be16 *)&p[opt->moffset] = ~htons((u16)val);
+ break;
+ }
+ case OPT_BE32: {
+ unsigned long long val;
+ err = rxclass_get_ulong(str, &val, 32);
+ if (err)
+ return -1;
+ *(__be32 *)&p[opt->moffset] = ~htonl((u32)val);
+ break;
+ }
+ case OPT_BE64: {
+ unsigned long long val;
+ err = rxclass_get_ulong(str, &val, 64);
+ if (err)
+ return -1;
+ *(__be64 *)&p[opt->moffset] = ~htonll((u64)val);
+ break;
+ }
+ case OPT_IP4: {
+ __be32 val;
+ err = rxclass_get_ipv4(str, &val);
+ if (err)
+ return -1;
+ *(__be32 *)&p[opt->moffset] = ~val;
+ break;
+ }
+ case OPT_MAC: {
+ unsigned char val[ETH_ALEN];
+ int i;
+ err = rxclass_get_ether(str, val);
+ if (err)
+ return -1;
+
+ for (i = 0; i < ETH_ALEN; i++)
+ val[i] = ~val[i];
+
+ memcpy(&p[opt->moffset], val, ETH_ALEN);
+ break;
+ }
+ case OPT_NONE:
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
+int rxclass_parse_ruleopts(char **argp, int argc,
+ struct ethtool_rx_flow_spec *fsp)
+{
+ const struct rule_opts *options;
+ unsigned char *p = (unsigned char *)fsp;
+ int i = 0, n_opts, err;
+ u32 flags = 0;
+ int flow_type;
+
+ if (*argp == NULL || **argp == '\0' || argc < 1)
+ goto syntax_err;
+
+ if (!strcmp(argp[0], "tcp4"))
+ flow_type = TCP_V4_FLOW;
+ else if (!strcmp(argp[0], "udp4"))
+ flow_type = UDP_V4_FLOW;
+ else if (!strcmp(argp[0], "sctp4"))
+ flow_type = SCTP_V4_FLOW;
+ else if (!strcmp(argp[0], "ah4"))
+ flow_type = AH_V4_FLOW;
+ else if (!strcmp(argp[0], "esp4"))
+ flow_type = ESP_V4_FLOW;
+ else if (!strcmp(argp[0], "ip4"))
+ flow_type = IP_USER_FLOW;
+ else if (!strcmp(argp[0], "ether"))
+ flow_type = ETHER_FLOW;
+ else
+ goto syntax_err;
+
+ switch (flow_type) {
+ case TCP_V4_FLOW:
+ case UDP_V4_FLOW:
+ case SCTP_V4_FLOW:
+ options = rule_nfc_tcp_ip4;
+ n_opts = ARRAY_SIZE(rule_nfc_tcp_ip4);
+ break;
+ case AH_V4_FLOW:
+ case ESP_V4_FLOW:
+ options = rule_nfc_esp_ip4;
+ n_opts = ARRAY_SIZE(rule_nfc_esp_ip4);
+ break;
+ case IP_USER_FLOW:
+ options = rule_nfc_usr_ip4;
+ n_opts = ARRAY_SIZE(rule_nfc_usr_ip4);
+ break;
+ case ETHER_FLOW:
+ options = rule_nfc_ether;
+ n_opts = ARRAY_SIZE(rule_nfc_ether);
+ break;
+ default:
+ fprintf(stdout, "Add rule, invalid rule type[%s]\n", argp[0]);
+ return -1;
+ }
+
+ memset(p, 0, sizeof(*fsp));
+ fsp->flow_type = flow_type;
+ fsp->location = RX_CLS_LOC_UNSPEC;
+
+ for (i = 1; i < argc;) {
+ const struct rule_opts *opt;
+ int idx;
+ for (opt = options, idx = 0; idx < n_opts; idx++, opt++) {
+ char mask_name[16];
+
+ if (strcmp(argp[i], opt->name))
+ continue;
+
+ i++;
+ if (i >= argc)
+ break;
+
+ err = rxclass_get_val(argp[i], p, &flags, opt);
+ if (err) {
+ fprintf(stderr, "Invalid %s value[%s]\n",
+ opt->name, argp[i]);
+ return -1;
+ }
+
+ i++;
+ if (i >= argc)
+ break;
+
+ sprintf(mask_name, "%s-mask", opt->name);
+ if (strcmp(argp[i], "m") && strcmp(argp[i], mask_name))
+ break;
+
+ i++;
+ if (i >= argc)
+ goto syntax_err;
+
+ err = rxclass_get_mask(argp[i], p, opt);
+ if (err) {
+ fprintf(stderr, "Invalid %s mask[%s]\n",
+ opt->name, argp[i]);
+ return -1;
+ }
+
+ i++;
+
+ break;
+ }
+ if (idx == n_opts) {
+ fprintf(stdout, "Add rule, unreconized option[%s]\n",
+ argp[i]);
+ return -1;
+ }
+ }
+
+ if (flags & (NTUPLE_FLAG_VLAN | NTUPLE_FLAG_UDEF | NTUPLE_FLAG_VETH))
+ fsp->flow_type |= FLOW_EXT;
+
+ return 0;
+
+syntax_err:
+ fprintf(stdout, "Add rule, invalid syntax\n");
+ return -1;
+}
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox