Re: [PATCH 5/6] cxgb4: Add main driver file and driver Makefile

Previous thread: Re: Tiny patch (w/ discussion) to provide the peer information on unix domain sockets by Erkki Seppala on Tuesday, March 30, 2010 - 10:39 am. (1 message)

Next thread: [PATCH] net: Fix oops from tcp_collapse() when using splice() by Steven J. Magnani on Tuesday, March 30, 2010 - 1:45 pm. (3 messages)
From: Dimitris Michailidis
Date: Tuesday, March 30, 2010 - 11:52 am

This is an updated patch series for the cxgb4 driver.  Since the previous
posting there have been some fixes, simplifications, and updates here and
there but nothing extensive in any particular area.

The patches are against net-next as of 36c0d8c.

 drivers/net/Kconfig            |   25 +
 drivers/net/Makefile           |    1 +
 drivers/net/cxgb4/Makefile     |    7 +
 drivers/net/cxgb4/cxgb4.h      |  743 +++++++
 drivers/net/cxgb4/cxgb4_main.c | 4240 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/cxgb4/cxgb4_uld.h  |  235 +++
 drivers/net/cxgb4/l2t.c        |  626 ++++++
 drivers/net/cxgb4/l2t.h        |  110 ++
 drivers/net/cxgb4/sge.c        | 2431 +++++++++++++++++++++++
 drivers/net/cxgb4/t4_hw.c      | 3131 +++++++++++++++++++++++++++++
 drivers/net/cxgb4/t4_hw.h      |  100 +
 drivers/net/cxgb4/t4_msg.h     |  664 +++++++
 drivers/net/cxgb4/t4_regs.h    |  878 +++++++++
 drivers/net/cxgb4/t4fw_api.h   | 1584 +++++++++++++++
 14 files changed, 14775 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/cxgb4/Makefile
 create mode 100644 drivers/net/cxgb4/cxgb4.h
 create mode 100644 drivers/net/cxgb4/cxgb4_main.c
 create mode 100644 drivers/net/cxgb4/cxgb4_uld.h
 create mode 100644 drivers/net/cxgb4/l2t.c
 create mode 100644 drivers/net/cxgb4/l2t.h
 create mode 100644 drivers/net/cxgb4/sge.c
 create mode 100644 drivers/net/cxgb4/t4_hw.c
 create mode 100644 drivers/net/cxgb4/t4_hw.h
 create mode 100644 drivers/net/cxgb4/t4_msg.h
 create mode 100644 drivers/net/cxgb4/t4_regs.h
 create mode 100644 drivers/net/cxgb4/t4fw_api.h
--

From: Dimitris Michailidis
Date: Tuesday, March 30, 2010 - 11:52 am

Signed-off-by: Dimitris Michailidis <dm@chelsio.com>
---
 drivers/net/Kconfig  |   25 +++++++++++++++++++++++++
 drivers/net/Makefile |    1 +
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 4f1f974..944ffd1 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2582,6 +2582,31 @@ config CHELSIO_T3
 	  To compile this driver as a module, choose M here: the module
 	  will be called cxgb3.
 
+config CHELSIO_T4_DEPENDS
+	tristate
+	depends on PCI && INET
+	default y
+
+config CHELSIO_T4
+	tristate "Chelsio Communications T4 Ethernet support"
+	depends on CHELSIO_T4_DEPENDS
+	select FW_LOADER
+	select MDIO
+	help
+	  This driver supports Chelsio T4-based gigabit and 10Gb Ethernet
+	  adapters.
+
+	  For general information about Chelsio and our products, visit
+	  our website at <http://www.chelsio.com>.
+
+	  For customer support, please visit our customer support page at
+	  <http://www.chelsio.com/support.htm>.
+
+	  Please send feedback to <linux-bugs@chelsio.com>.
+
+	  To compile this driver as a module choose M here; the module
+	  will be called cxgb4.
+
 config EHEA
 	tristate "eHEA Ethernet support"
 	depends on IBMEBUS && INET && SPARSEMEM
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 4788862..a583b50 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_IXGB) += ixgb/
 obj-$(CONFIG_IP1000) += ipg.o
 obj-$(CONFIG_CHELSIO_T1) += chelsio/
 obj-$(CONFIG_CHELSIO_T3) += cxgb3/
+obj-$(CONFIG_CHELSIO_T4) += cxgb4/
 obj-$(CONFIG_EHEA) += ehea/
 obj-$(CONFIG_CAN) += can/
 obj-$(CONFIG_BONDING) += bonding/
-- 
1.5.4

--

From: Dimitris Michailidis
Date: Tuesday, March 30, 2010 - 11:52 am

Signed-off-by: Dimitris Michailidis <dm@chelsio.com>
---
 drivers/net/cxgb4/sge.c | 2431 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 2431 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/cxgb4/sge.c

diff --git a/drivers/net/cxgb4/sge.c b/drivers/net/cxgb4/sge.c
new file mode 100644
index 0000000..14adc58
--- /dev/null
+++ b/drivers/net/cxgb4/sge.c
@@ -0,0 +1,2431 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/skbuff.h>
+#include ...
From: Dimitris Michailidis
Date: Tuesday, March 30, 2010 - 11:52 am

Signed-off-by: Dimitris Michailidis <dm@chelsio.com>
---
 drivers/net/cxgb4/cxgb4.h     |  743 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/cxgb4/cxgb4_uld.h |  235 +++++++++++++
 drivers/net/cxgb4/l2t.c       |  626 ++++++++++++++++++++++++++++++++++
 drivers/net/cxgb4/l2t.h       |  110 ++++++
 4 files changed, 1714 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/cxgb4/cxgb4.h
 create mode 100644 drivers/net/cxgb4/cxgb4_uld.h
 create mode 100644 drivers/net/cxgb4/l2t.c
 create mode 100644 drivers/net/cxgb4/l2t.h

diff --git a/drivers/net/cxgb4/cxgb4.h b/drivers/net/cxgb4/cxgb4.h
new file mode 100644
index 0000000..ca162ef
--- /dev/null
+++ b/drivers/net/cxgb4/cxgb4.h
@@ -0,0 +1,743 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT ...
From: Dimitris Michailidis
Date: Tuesday, March 30, 2010 - 11:52 am

Signed-off-by: Dimitris Michailidis <dm@chelsio.com>
---
 drivers/net/cxgb4/Makefile     |    7 +
 drivers/net/cxgb4/cxgb4_main.c | 4240 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 4247 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/cxgb4/Makefile
 create mode 100644 drivers/net/cxgb4/cxgb4_main.c

diff --git a/drivers/net/cxgb4/Makefile b/drivers/net/cxgb4/Makefile
new file mode 100644
index 0000000..4986674
--- /dev/null
+++ b/drivers/net/cxgb4/Makefile
@@ -0,0 +1,7 @@
+#
+# Chelsio T4 driver
+#
+
+obj-$(CONFIG_CHELSIO_T4) += cxgb4.o
+
+cxgb4-objs := cxgb4_main.o l2t.o t4_hw.o sge.o
diff --git a/drivers/net/cxgb4/cxgb4_main.c b/drivers/net/cxgb4/cxgb4_main.c
new file mode 100644
index 0000000..c56fedc
--- /dev/null
+++ b/drivers/net/cxgb4/cxgb4_main.c
@@ -0,0 +1,4240 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE ...
From: Stephen Hemminger
Date: Tuesday, March 30, 2010 - 2:19 pm

On Tue, 30 Mar 2010 10:52:21 -0800

Do you really need this large number of /proc files.
It creates another stable API to worry about.  If it is just for
debugging move it to debugfs, or better yet just drop it.

-- 
--

From: Dimitris Michailidis
Date: Tuesday, March 30, 2010 - 6:34 pm

The driver already separates its files between debugfs and proc.  I put in 
debugfs files one wouldn't be looking at unless they were investigating some 
problem and the rest are in proc.  Frankly I don't really care which fs they 
use, they just contain useful information and it would be nice to have them 
somewhere.  Let me know what you want me to do here.
--

From: David Miller
Date: Tuesday, March 30, 2010 - 10:50 pm

From: Stephen Hemminger <shemminger@vyatta.com>

I also find this a bit too much.

We have all kinds of ways to export whatever statistics you
want.  In particular we have ethtool stats of which you
can have as many as you wish.

If necessary, we could add a feature to define "views" of ethtool
stats so that we can have domains of driver specific statistics if the
problem is that you don't want all of these debugging stats to clutter
up the "main" ethtool stats.
--

From: Steve Wise
Date: Wednesday, March 31, 2010 - 12:31 pm

This sounds interesting.  Dave, how would you envision the ethtool 
interface for this?  A new modifier to --statistics?  Like: 'ethtool 
--statistics ethX  viewname' where viewname could maybe be passed to the 
driver to allow arbitrary views?   Or something else?

Steve.



--

From: David Miller
Date: Wednesday, March 31, 2010 - 2:13 pm

From: Steve Wise <swise@opengridcomputing.com>

I really don't care much about the userland side, I'm only
interested in how you implement this in the kernel :-)
--

From: Dimitris Michailidis
Date: Wednesday, March 31, 2010 - 5:19 pm

It wasn't a concern with having too many ethtool stats that led to the use 
of proc, rather it was that most of this information isn't associated with 
netdevs.  Let me give an example.  Like most virtualized NICs this device 
contains a switch.  Some of the switch statistics are provided in the proc 
files.  While they are statistics, logically they are not associated with 
any of the netdevs.  If ethtool were to be extended so that the specified 
interface would access the underlying HW to get information possibly 
unrelated to the interface personally I'd be OK with that, I am just 
pointing out what kind of extension we are talking about.

Also some of the files here aren't statistics but report other functionality 
  of the device, usually also not tied to netdevs (e.g., the trace* files 
are again related to the switch).

So, I propose getting rid of 3-4 of these files that are of lesser value and 
moving the rest to debugfs for now.  If some alternative through ethtool or 
something becomes available I can get rid of anything that can be handled 
through a more general facility.  Would that be acceptable?
--

From: David Miller
Date: Wednesday, March 31, 2010 - 5:24 pm

From: Dimitris Michailidis <dm@chelsio.com>

You can use sysfs.

I have a similar issue on NIU wherein a top-level set of logic
behaves like a parent virtual device and contains attributes
I'd like to export.

I create a dummy platform device to represent this node and
hang the device sysfs information in that device's sysfs
directory.  It shows up as /sys/devices/platform/niu.%d
and the network ports underneath this parent appear as
symlinks named "port%d"  (part of this is setup in
drivers/net/niu.c:niu_get_parent() and niu_new_parent())

You could do something similar to represent the fact that
these statistics are virtualized and belong to some centralized
virtual entity that represents one or more actual device ports.
--

From: Dimitris Michailidis
Date: Wednesday, March 31, 2010 - 6:34 pm

sysfs is a possibility but I thought Stephen's initial concern was that I 
was adding too many of these proc files and that they were creating a 
potential API.  sysfs will result in a lot more files with its 
value-per-file model and I think sysfs and proc are similar in "APIness". 
So it's not clear to me how going to sysfs would address Stephen's point. 
The remove-a-few plus move-to-debugfs proposal was in order to end up with 
fewer files in a non-API filesystem.

As these builtin switches become more common I expect an official way to 
represent and access them will emerge but maybe it's not a good idea to 
introduce a sysfs model for them as part of this driver submission.
--

From: David Miller
Date: Wednesday, March 31, 2010 - 7:18 pm

From: Dimitris Michailidis <dm@chelsio.com>


It's in fact easier to retain API by using sysfs.  Instead of having
to worry about the format of a procfs file listing entries one by one

What nodes you create under your own device object in sysfs is your
domain and your business.  Since it's one value per file there is no
real complexity in making sure tools can display the values properly.
--

From: Dimitris Michailidis
Date: Tuesday, March 30, 2010 - 11:52 am

Signed-off-by: Dimitris Michailidis <dm@chelsio.com>
---
 drivers/net/cxgb4/t4_msg.h   |  664 ++++++++++++++++++
 drivers/net/cxgb4/t4_regs.h  |  878 +++++++++++++++++++++++
 drivers/net/cxgb4/t4fw_api.h | 1584 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 3126 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/cxgb4/t4_msg.h
 create mode 100644 drivers/net/cxgb4/t4_regs.h
 create mode 100644 drivers/net/cxgb4/t4fw_api.h

diff --git a/drivers/net/cxgb4/t4_msg.h b/drivers/net/cxgb4/t4_msg.h
new file mode 100644
index 0000000..6df2b92
--- /dev/null
+++ b/drivers/net/cxgb4/t4_msg.h
@@ -0,0 +1,664 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ...
From: Dimitris Michailidis
Date: Tuesday, March 30, 2010 - 11:52 am

Signed-off-by: Dimitris Michailidis <dm@chelsio.com>
---
 drivers/net/cxgb4/t4_hw.c | 3131 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/cxgb4/t4_hw.h |  100 ++
 2 files changed, 3231 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/cxgb4/t4_hw.c
 create mode 100644 drivers/net/cxgb4/t4_hw.h

diff --git a/drivers/net/cxgb4/t4_hw.c b/drivers/net/cxgb4/t4_hw.c
new file mode 100644
index 0000000..a814a3a
--- /dev/null
+++ b/drivers/net/cxgb4/t4_hw.c
@@ -0,0 +1,3131 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR ...
From: Stephen Hemminger
Date: Tuesday, March 30, 2010 - 2:09 pm

On Tue, 30 Mar 2010 10:52:17 -0800

The intent of the __types like __u8 etc are that these types
should only be used by structures that are part in some way of
a kernel to userspace API. Any structures which are only used
in the kernel should just use the regular type (ie u8).

I say intent because many places do not follow this practice.

-- 
--

From: Dimitris Michailidis
Date: Tuesday, March 30, 2010 - 6:25 pm

These headers aren't meant to be seen by user space and I can certainly 
replace __u8 with u8.  I'll update the patch.
--

Previous thread: Re: Tiny patch (w/ discussion) to provide the peer information on unix domain sockets by Erkki Seppala on Tuesday, March 30, 2010 - 10:39 am. (1 message)

Next thread: [PATCH] net: Fix oops from tcp_collapse() when using splice() by Steven J. Magnani on Tuesday, March 30, 2010 - 1:45 pm. (3 messages)