From: dykmanj@linux.vnet.ibm.com
To: netdev@vger.kernel.org
Cc: Jim Dykman <dykmanj@linux.vnet.ibm.com>,
Piyush Chaudhary <piyushc@linux.vnet.ibm.com>,
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>
Subject: [PATCH v4 08/27] HFI: DD request framework and first HFI DD request
Date: Mon, 25 Apr 2011 17:23:48 -0400 [thread overview]
Message-ID: <1303766647-30156-9-git-send-email-dykmanj@linux.vnet.ibm.com> (raw)
In-Reply-To: <1303766647-30156-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 | 22 +++++++-
include/linux/hfi/hfidd_requests.h | 38 ++++++++++++++
5 files changed, 191 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..65b8dc2 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -36,12 +36,28 @@
#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/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
next prev parent reply other threads:[~2011-04-25 21:24 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-25 21:23 [PATCH v4 00/27] HFI: minimal device driver/ip driver dykmanj
2011-04-25 21:23 ` [PATCH v4 01/27] HFI: skeleton driver dykmanj
2011-05-20 18:37 ` Brian King
2011-04-25 21:23 ` [PATCH v4 02/27] HFI: Add HFI adapter control structure dykmanj
2011-04-25 21:23 ` [PATCH v4 03/27] HFI: Add device_create/device_destroy calls for HFI devices dykmanj
2011-04-25 21:23 ` [PATCH v4 04/27] HFI: Find HFI devices in the device tree dykmanj
2011-04-25 21:23 ` [PATCH v4 05/27] HFI: The first few HFI-specific hypervisor calls dykmanj
2011-04-25 21:23 ` [PATCH v4 06/27] HFI: Add DD calls to START/STOP INTERFACE HCALLs dykmanj
2011-04-25 21:23 ` [PATCH v4 07/27] HFI: Add nMMU start/stop hypervisor calls dykmanj
2011-04-25 21:23 ` dykmanj [this message]
2011-04-25 21:23 ` [PATCH v4 09/27] HFI: Add HFI window resource tracking dykmanj
2011-04-25 21:23 ` [PATCH v4 10/27] HFI: HFIDD_REQ_OPEN_WINDOW request dykmanj
2011-04-25 21:23 ` [PATCH v4 11/27] HFI: Check window number/assign window number dykmanj
2011-04-25 21:23 ` [PATCH v4 12/27] HFI: Sanity check send and receive fifo parameters dykmanj
2011-04-25 21:23 ` [PATCH v4 13/27] HFI: Send and receive fifo address translation dykmanj
2011-04-25 21:23 ` [PATCH v4 14/27] HFI: Add hypercalls to create/modify/free page tables in the nMMU dykmanj
2011-04-25 21:23 ` [PATCH v4 15/27] HFI: Set up nMMU page tables for the send and receive fifos dykmanj
2011-04-25 21:23 ` [PATCH v4 16/27] HFI: Add window open hypervisor call dykmanj
2011-04-25 21:23 ` [PATCH v4 17/27] HFI: Set up and call the open window hypercall dykmanj
2011-04-25 21:23 ` [PATCH v4 18/27] HFI: Map window registers into user process dykmanj
2011-04-25 21:23 ` [PATCH v4 19/27] HFI: Add window close request dykmanj
2011-04-25 21:24 ` [PATCH v4 20/27] HFI: Close window hypervisor call dykmanj
2011-04-25 21:24 ` [PATCH v4 21/27] HFI: Add send and receive interrupts dykmanj
2011-04-25 21:24 ` [PATCH v4 22/27] HFI: Add event notifications dykmanj
2011-04-25 21:24 ` [PATCH v4 23/27] HFI: Define packet header formats and window register offsets dykmanj
2011-04-25 21:24 ` [PATCH v4 24/27] HFI: hfi_ip network driver dykmanj
2011-04-25 21:24 ` [PATCH v4 25/27] HFI: hfi_ip fifo transmit paths dykmanj
2011-04-25 21:24 ` [PATCH v4 26/27] HFI: hfi_ip fifo receive path dykmanj
2011-04-25 21:24 ` [PATCH v4 27/27] HFI: hfi_ip ethtool support dykmanj
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1303766647-30156-9-git-send-email-dykmanj@linux.vnet.ibm.com \
--to=dykmanj@linux.vnet.ibm.com \
--cc=clsoto@linux.vnet.ibm.com \
--cc=fcchang@linux.vnet.ibm.com \
--cc=jian@linux.vnet.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=piyushc@linux.vnet.ibm.com \
--cc=sakolish@linux.vnet.ibm.com \
--cc=sjsheppa@linux.vnet.ibm.com \
--cc=winstonc@linux.vnet.ibm.com \
--cc=wscadden@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).