[PATCH net] MAINTAINERS: update cxgb4 and cxgb3 maintainer

2018-12-20 Thread Ganesh Goudar
Arjun Vynipadath will be taking over as maintainer from now.

Signed-off-by: Ganesh Goudar 
---
 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index f6d08b3..bcd633c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4046,7 +4046,7 @@ S:Maintained
 F: drivers/media/dvb-frontends/cxd2820r*
 
 CXGB3 ETHERNET DRIVER (CXGB3)
-M: Santosh Raspatur 
+M: Arjun Vynipadath 
 L: netdev@vger.kernel.org
 W: http://www.chelsio.com
 S: Supported
@@ -4075,7 +4075,7 @@ S:Supported
 F: drivers/crypto/chelsio
 
 CXGB4 ETHERNET DRIVER (CXGB4)
-M: Ganesh Goudar 
+M: Arjun Vynipadath 
 L: netdev@vger.kernel.org
 W: http://www.chelsio.com
 S: Supported
-- 
2.1.0



[PATCH net] net/tls: allocate tls context using GFP_ATOMIC

2018-12-19 Thread Ganesh Goudar
create_ctx can be called from atomic context, hence use
GFP_ATOMIC instead of GFP_KERNEL.

[  395.962599] BUG: sleeping function called from invalid context at 
mm/slab.h:421
[  395.979896] in_atomic(): 1, irqs_disabled(): 0, pid: 16254, name: openssl
[  395.996564] 2 locks held by openssl/16254:
[  396.010492]  #0: 347acb52 (sk_lock-AF_INET){+.+.}, at: 
do_tcp_setsockopt.isra.44+0x13b/0x9a0
[  396.029838]  #1: 6c9552b5 (device_spinlock){+...}, at: 
tls_init+0x1d/0x280
[  396.047675] CPU: 5 PID: 16254 Comm: openssl Tainted: G   O  
4.20.0-rc6+ #25
[  396.066019] Hardware name: Supermicro X10SRA-F/X10SRA-F, BIOS 2.0c 09/25/2017
[  396.083537] Call Trace:
[  396.096265]  dump_stack+0x5e/0x8b
[  396.109876]  ___might_sleep+0x216/0x250
[  396.123940]  kmem_cache_alloc_trace+0x1b0/0x240
[  396.138800]  create_ctx+0x1f/0x60
[  396.152504]  tls_init+0xbd/0x280
[  396.166135]  tcp_set_ulp+0x191/0x2d0
[  396.180035]  ? tcp_set_ulp+0x2c/0x2d0
[  396.193960]  do_tcp_setsockopt.isra.44+0x148/0x9a0
[  396.209013]  __sys_setsockopt+0x7c/0xe0
[  396.223054]  __x64_sys_setsockopt+0x20/0x30
[  396.237378]  do_syscall_64+0x4a/0x180
[  396.251200]  entry_SYSCALL_64_after_hwframe+0x49/0xbe

Fixes: df9d4a178022 ("net/tls: sleeping function from invalid context")
Signed-off-by: Ganesh Goudar 
---
 net/tls/tls_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index 1428bd7..28887cf 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -538,7 +538,7 @@ static struct tls_context *create_ctx(struct sock *sk)
struct inet_connection_sock *icsk = inet_csk(sk);
struct tls_context *ctx;
 
-   ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+   ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
if (!ctx)
return NULL;
 
-- 
2.1.0



[PATCH v2 net-next] cxgb4: number of VFs supported is not always 16

2018-11-27 Thread Ganesh Goudar
Total number of VFs supported by PF is used to determine the last
byte of VF's mac address. Number of VFs supported is not always
16, use the variable nvfs to get the number of VFs supported
rather than hard coding it to 16.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
V2: Fixes typo in commit message
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 7f76ad9..6ba9099 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2646,7 +2646,7 @@ static void cxgb4_mgmt_fill_vf_station_mac_addr(struct 
adapter *adap)
 
for (vf = 0, nvfs = pci_sriov_get_totalvfs(adap->pdev);
vf < nvfs; vf++) {
-   macaddr[5] = adap->pf * 16 + vf;
+   macaddr[5] = adap->pf * nvfs + vf;
ether_addr_copy(adap->vfinfo[vf].vf_mac_addr, macaddr);
}
 }
-- 
2.1.0



[PATCH net-next] cxgb4: number of VFs supported is not always 16

2018-11-26 Thread Ganesh Goudar
Total number of VFs supported by PF is used determine the last
byte of VF's mac address. Number of VFs supported is not always
16, use the variable nvfs to get the number of VFs supported
rather than hard coding it to 16.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 7f76ad9..6ba9099 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2646,7 +2646,7 @@ static void cxgb4_mgmt_fill_vf_station_mac_addr(struct 
adapter *adap)
 
for (vf = 0, nvfs = pci_sriov_get_totalvfs(adap->pdev);
vf < nvfs; vf++) {
-   macaddr[5] = adap->pf * 16 + vf;
+   macaddr[5] = adap->pf * nvfs + vf;
ether_addr_copy(adap->vfinfo[vf].vf_mac_addr, macaddr);
}
 }
-- 
2.1.0



[PATCH net V2] cxgb4: fix thermal zone build error

2018-11-15 Thread Ganesh Goudar
with CONFIG_THERMAL=m and cxgb4 as built-in build fails, and
'commit e70a57fa59bb ("cxgb4: fix thermal configuration dependencies")'
tries to fix it but when cxgb4i is made built-in build fails again,
use IS_REACHABLE instead of IS_ENABLED to fix the issue.

Fixes: e70a57fa59bb (cxgb4: fix thermal configuration dependencies)
Reported-by: Randy Dunlap 
Signed-off-by: Ganesh Goudar 
---
V2: Fixing spelling mistake and avoid preprocessor conditionals.
---
 drivers/net/ethernet/chelsio/Kconfig| 1 -
 drivers/net/ethernet/chelsio/cxgb4/Makefile | 4 +---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 4 ++--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/Kconfig 
b/drivers/net/ethernet/chelsio/Kconfig
index 75c1c5e..e2cdfa7 100644
--- a/drivers/net/ethernet/chelsio/Kconfig
+++ b/drivers/net/ethernet/chelsio/Kconfig
@@ -67,7 +67,6 @@ config CHELSIO_T3
 config CHELSIO_T4
tristate "Chelsio Communications T4/T5/T6 Ethernet support"
depends on PCI && (IPV6 || IPV6=n)
-   depends on THERMAL || !THERMAL
select FW_LOADER
select MDIO
select ZLIB_DEFLATE
diff --git a/drivers/net/ethernet/chelsio/cxgb4/Makefile 
b/drivers/net/ethernet/chelsio/cxgb4/Makefile
index 78e5d17..91d8a88 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/Makefile
+++ b/drivers/net/ethernet/chelsio/cxgb4/Makefile
@@ -12,6 +12,4 @@ cxgb4-objs := cxgb4_main.o l2t.o smt.o t4_hw.o sge.o 
clip_tbl.o cxgb4_ethtool.o
 cxgb4-$(CONFIG_CHELSIO_T4_DCB) +=  cxgb4_dcb.o
 cxgb4-$(CONFIG_CHELSIO_T4_FCOE) +=  cxgb4_fcoe.o
 cxgb4-$(CONFIG_DEBUG_FS) += cxgb4_debugfs.o
-ifdef CONFIG_THERMAL
-cxgb4-objs += cxgb4_thermal.o
-endif
+cxgb4-$(CONFIG_THERMAL) += cxgb4_thermal.o
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 05a4692..d49db46 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5863,7 +5863,7 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (!is_t4(adapter->params.chip))
cxgb4_ptp_init(adapter);
 
-   if (IS_ENABLED(CONFIG_THERMAL) &&
+   if (IS_REACHABLE(CONFIG_THERMAL) &&
!is_t4(adapter->params.chip) && (adapter->flags & FW_OK))
cxgb4_thermal_init(adapter);
 
@@ -5932,7 +5932,7 @@ static void remove_one(struct pci_dev *pdev)
 
if (!is_t4(adapter->params.chip))
cxgb4_ptp_stop(adapter);
-   if (IS_ENABLED(CONFIG_THERMAL))
+   if (IS_REACHABLE(CONFIG_THERMAL))
cxgb4_thermal_remove(adapter);
 
/* If we allocated filters, free up state associated with any
-- 
2.1.0



[PATCH net] cxgb4: fix thermal zone build error

2018-11-15 Thread Ganesh Goudar
with CONFIG_THERMAL=m and cxgb4 as built-in build fails, and
'commit e70a57fa59bb ("cxgb4: fix thermal configuration dependencies")'
tires to fix it but when cxgb4i is made built-in build fails again,
use IS_REACHABLE instead of IS_ENABLED to fix the issue.

Fixes: e70a57fa59bb (cxgb4: fix thermal configuration dependencies)
Reported-by: Randy Dunlap 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/Kconfig|  1 -
 drivers/net/ethernet/chelsio/cxgb4/Makefile |  4 +---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 12 ++--
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/Kconfig 
b/drivers/net/ethernet/chelsio/Kconfig
index 75c1c5e..e2cdfa7 100644
--- a/drivers/net/ethernet/chelsio/Kconfig
+++ b/drivers/net/ethernet/chelsio/Kconfig
@@ -67,7 +67,6 @@ config CHELSIO_T3
 config CHELSIO_T4
tristate "Chelsio Communications T4/T5/T6 Ethernet support"
depends on PCI && (IPV6 || IPV6=n)
-   depends on THERMAL || !THERMAL
select FW_LOADER
select MDIO
select ZLIB_DEFLATE
diff --git a/drivers/net/ethernet/chelsio/cxgb4/Makefile 
b/drivers/net/ethernet/chelsio/cxgb4/Makefile
index 78e5d17..91d8a88 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/Makefile
+++ b/drivers/net/ethernet/chelsio/cxgb4/Makefile
@@ -12,6 +12,4 @@ cxgb4-objs := cxgb4_main.o l2t.o smt.o t4_hw.o sge.o 
clip_tbl.o cxgb4_ethtool.o
 cxgb4-$(CONFIG_CHELSIO_T4_DCB) +=  cxgb4_dcb.o
 cxgb4-$(CONFIG_CHELSIO_T4_FCOE) +=  cxgb4_fcoe.o
 cxgb4-$(CONFIG_DEBUG_FS) += cxgb4_debugfs.o
-ifdef CONFIG_THERMAL
-cxgb4-objs += cxgb4_thermal.o
-endif
+cxgb4-$(CONFIG_THERMAL) += cxgb4_thermal.o
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 05a4692..bd85210 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5863,10 +5863,10 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (!is_t4(adapter->params.chip))
cxgb4_ptp_init(adapter);
 
-   if (IS_ENABLED(CONFIG_THERMAL) &&
-   !is_t4(adapter->params.chip) && (adapter->flags & FW_OK))
+#if IS_REACHABLE(CONFIG_THERMAL)
+   if (!is_t4(adapter->params.chip) && (adapter->flags & FW_OK))
cxgb4_thermal_init(adapter);
-
+#endif
print_adapter_info(adapter);
return 0;
 
@@ -5932,9 +5932,9 @@ static void remove_one(struct pci_dev *pdev)
 
if (!is_t4(adapter->params.chip))
cxgb4_ptp_stop(adapter);
-   if (IS_ENABLED(CONFIG_THERMAL))
-   cxgb4_thermal_remove(adapter);
-
+#if IS_REACHABLE(CONFIG_THERMAL)
+   cxgb4_thermal_remove(adapter);
+#endif
/* If we allocated filters, free up state associated with any
 * valid filters ...
 */
-- 
2.1.0



[PATCH net-next] cxgb4: Add new T6 PCI device ids 0x608a

2018-11-08 Thread Ganesh Goudar
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
index 60df66f..bf7325f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
@@ -217,6 +217,7 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
CH_PCI_ID_TABLE_FENTRY(0x6087), /* Custom T6225-CR */
CH_PCI_ID_TABLE_FENTRY(0x6088), /* Custom T62100-CR */
CH_PCI_ID_TABLE_FENTRY(0x6089), /* Custom T62100-KR */
+   CH_PCI_ID_TABLE_FENTRY(0x608a), /* Custom T62100-CR */
 CH_PCI_DEVICE_ID_TABLE_DEFINE_END;
 
 #endif /* __T4_PCI_ID_TBL_H__ */
-- 
2.1.0



[PATCH net-next] cxgb4: Add thermal zone support

2018-10-09 Thread Ganesh Goudar
Add thermal zone support to monitor ASIC's temperature.

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/Makefile|   1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |  18 
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   8 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c | 114 +
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  |   1 +
 5 files changed, 142 insertions(+)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c

diff --git a/drivers/net/ethernet/chelsio/cxgb4/Makefile 
b/drivers/net/ethernet/chelsio/cxgb4/Makefile
index bea6a05..91d8a88 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/Makefile
+++ b/drivers/net/ethernet/chelsio/cxgb4/Makefile
@@ -12,3 +12,4 @@ cxgb4-objs := cxgb4_main.o l2t.o smt.o t4_hw.o sge.o 
clip_tbl.o cxgb4_ethtool.o
 cxgb4-$(CONFIG_CHELSIO_T4_DCB) +=  cxgb4_dcb.o
 cxgb4-$(CONFIG_CHELSIO_T4_FCOE) +=  cxgb4_fcoe.o
 cxgb4-$(CONFIG_DEBUG_FS) += cxgb4_debugfs.o
+cxgb4-$(CONFIG_THERMAL) += cxgb4_thermal.o
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index b5010bd..95909f0 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -52,6 +52,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "t4_chip_type.h"
 #include "cxgb4_uld.h"
@@ -890,6 +891,14 @@ struct mps_encap_entry {
atomic_t refcnt;
 };
 
+#ifdef CONFIG_THERMAL
+struct ch_thermal {
+   struct thermal_zone_device *tzdev;
+   int trip_temp;
+   int trip_type;
+};
+#endif
+
 struct adapter {
void __iomem *regs;
void __iomem *bar2;
@@ -1008,6 +1017,9 @@ struct adapter {
 
/* Dump buffer for collecting logs in kdump kernel */
struct vmcoredd_data vmcoredd;
+#ifdef CONFIG_THERMAL
+   struct ch_thermal ch_thermal;
+#endif
 };
 
 /* Support for "sched-class" command to allow a TX Scheduling Class to be
@@ -1862,4 +1874,10 @@ void cxgb4_ring_tx_db(struct adapter *adap, struct 
sge_txq *q, int n);
 int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf,
u16 vlan);
 int cxgb4_dcb_enabled(const struct net_device *dev);
+
+#ifdef CONFIG_THERMAL
+int cxgb4_thermal_init(struct adapter *adap);
+int cxgb4_thermal_remove(struct adapter *adap);
+#endif /* CONFIG_THERMAL */
+
 #endif /* __CXGB4_H__ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 1a93efa..03cc073 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5864,6 +5864,11 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (!is_t4(adapter->params.chip))
cxgb4_ptp_init(adapter);
 
+#ifdef CONFIG_THERMAL
+   if (!is_t4(adapter->params.chip) && (adapter->flags & FW_OK))
+   cxgb4_thermal_init(adapter);
+#endif /* CONFIG_THERMAL */
+
print_adapter_info(adapter);
return 0;
 
@@ -5929,6 +5934,9 @@ static void remove_one(struct pci_dev *pdev)
 
if (!is_t4(adapter->params.chip))
cxgb4_ptp_stop(adapter);
+#ifdef CONFIG_THERMAL
+   cxgb4_thermal_remove(adapter);
+#endif
 
/* If we allocated filters, free up state associated with any
 * valid filters ...
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c
new file mode 100644
index 000..28052e750
--- /dev/null
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c
@@ -0,0 +1,114 @@
+/*
+ *  Copyright (C) 2017 Chelsio Communications.  All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms and conditions of the GNU General Public License,
+ *  version 2, as published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope 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.
+ *
+ *  The full GNU General Public License is included in this distribution in
+ *  the file called "COPYING".
+ *
+ *  Written by: Ganesh Goudar (ganes...@chelsio.com)
+ */
+
+#include "cxgb4.h"
+
+#define CXGB4_NUM_TRIPS 1
+
+static int cxgb4_thermal_get_temp(struct thermal_zone_device *tzdev,
+ int *temp)
+{
+   struct adapter *adap = tzdev->devdata;
+   u32 param, val;
+   int ret;
+
+   param = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
+FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_DIAG) |
+FW_PARAMS_PARAM_Y_V(FW_PARAM_DEV_DIAG_TMP));
+
+   ret = t4_query_params(adap, adap->mbox

[PATCH net-next] cxgb4: use FW_PORT_ACTION_L1_CFG32 for 32 bit capability

2018-10-05 Thread Ganesh Goudar
when 32 bit port capability is in use, use FW_PORT_ACTION_L1_CFG32
rather than FW_PORT_ACTION_L1_CFG.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index f85eab5..cb52394 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -4204,6 +4204,7 @@ int t4_link_l1cfg_core(struct adapter *adapter, unsigned 
int mbox,
  */
 int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port)
 {
+   unsigned int fw_caps = adap->params.fw_caps_support;
struct fw_port_cmd c;
 
memset(&c, 0, sizeof(c));
@@ -4211,9 +4212,14 @@ int t4_restart_aneg(struct adapter *adap, unsigned int 
mbox, unsigned int port)
 FW_CMD_REQUEST_F | FW_CMD_EXEC_F |
 FW_PORT_CMD_PORTID_V(port));
c.action_to_len16 =
-   cpu_to_be32(FW_PORT_CMD_ACTION_V(FW_PORT_ACTION_L1_CFG) |
+   cpu_to_be32(FW_PORT_CMD_ACTION_V(fw_caps == FW_CAPS16
+? FW_PORT_ACTION_L1_CFG
+: FW_PORT_ACTION_L1_CFG32) |
FW_LEN16(c));
-   c.u.l1cfg.rcap = cpu_to_be32(FW_PORT_CAP32_ANEG);
+   if (fw_caps == FW_CAPS16)
+   c.u.l1cfg.rcap = cpu_to_be32(FW_PORT_CAP_ANEG);
+   else
+   c.u.l1cfg32.rcap32 = cpu_to_be32(FW_PORT_CAP32_ANEG);
return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
 }
 
-- 
2.1.0



[PATCH net-next] cxgb4: remove the unneeded locks

2018-10-03 Thread Ganesh Goudar
cxgb_set_tx_maxrate will be called holding rtnl lock,
hence remove all unneeded locks.

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/sched.c | 68 +++---
 drivers/net/ethernet/chelsio/cxgb4/sched.h |  2 -
 2 files changed, 15 insertions(+), 55 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/sched.c 
b/drivers/net/ethernet/chelsio/cxgb4/sched.c
index 7fc6566..52edb68 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sched.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sched.c
@@ -38,7 +38,6 @@
 #include "cxgb4.h"
 #include "sched.h"
 
-/* Spinlock must be held by caller */
 static int t4_sched_class_fw_cmd(struct port_info *pi,
 struct ch_sched_params *p,
 enum sched_fw_ops op)
@@ -67,7 +66,6 @@ static int t4_sched_class_fw_cmd(struct port_info *pi,
return err;
 }
 
-/* Spinlock must be held by caller */
 static int t4_sched_bind_unbind_op(struct port_info *pi, void *arg,
   enum sched_bind_type type, bool bind)
 {
@@ -163,7 +161,6 @@ static int t4_sched_queue_unbind(struct port_info *pi, 
struct ch_sched_queue *p)
if (e && index >= 0) {
int i = 0;
 
-   spin_lock(&e->lock);
list_for_each_entry(qe, &e->queue_list, list) {
if (i == index)
break;
@@ -171,10 +168,8 @@ static int t4_sched_queue_unbind(struct port_info *pi, 
struct ch_sched_queue *p)
}
err = t4_sched_bind_unbind_op(pi, (void *)qe, SCHED_QUEUE,
  false);
-   if (err) {
-   spin_unlock(&e->lock);
-   goto out;
-   }
+   if (err)
+   return err;
 
list_del(&qe->list);
kvfree(qe);
@@ -182,9 +177,7 @@ static int t4_sched_queue_unbind(struct port_info *pi, 
struct ch_sched_queue *p)
e->state = SCHED_STATE_UNUSED;
memset(&e->info, 0, sizeof(e->info));
}
-   spin_unlock(&e->lock);
}
-out:
return err;
 }
 
@@ -210,10 +203,8 @@ static int t4_sched_queue_bind(struct port_info *pi, 
struct ch_sched_queue *p)
 
/* Unbind queue from any existing class */
err = t4_sched_queue_unbind(pi, p);
-   if (err) {
-   kvfree(qe);
-   goto out;
-   }
+   if (err)
+   goto out_err;
 
/* Bind queue to specified class */
memset(qe, 0, sizeof(*qe));
@@ -221,18 +212,16 @@ static int t4_sched_queue_bind(struct port_info *pi, 
struct ch_sched_queue *p)
memcpy(&qe->param, p, sizeof(qe->param));
 
e = &s->tab[qe->param.class];
-   spin_lock(&e->lock);
err = t4_sched_bind_unbind_op(pi, (void *)qe, SCHED_QUEUE, true);
-   if (err) {
-   kvfree(qe);
-   spin_unlock(&e->lock);
-   goto out;
-   }
+   if (err)
+   goto out_err;
 
list_add_tail(&qe->list, &e->queue_list);
atomic_inc(&e->refcnt);
-   spin_unlock(&e->lock);
-out:
+   return err;
+
+out_err:
+   kvfree(qe);
return err;
 }
 
@@ -296,8 +285,6 @@ int cxgb4_sched_class_bind(struct net_device *dev, void 
*arg,
   enum sched_bind_type type)
 {
struct port_info *pi = netdev2pinfo(dev);
-   struct sched_table *s;
-   int err = 0;
u8 class_id;
 
if (!can_sched(dev))
@@ -323,12 +310,8 @@ int cxgb4_sched_class_bind(struct net_device *dev, void 
*arg,
if (class_id == SCHED_CLS_NONE)
return -ENOTSUPP;
 
-   s = pi->sched_tbl;
-   write_lock(&s->rw_lock);
-   err = t4_sched_class_bind_unbind_op(pi, arg, type, true);
-   write_unlock(&s->rw_lock);
+   return t4_sched_class_bind_unbind_op(pi, arg, type, true);
 
-   return err;
 }
 
 /**
@@ -343,8 +326,6 @@ int cxgb4_sched_class_unbind(struct net_device *dev, void 
*arg,
 enum sched_bind_type type)
 {
struct port_info *pi = netdev2pinfo(dev);
-   struct sched_table *s;
-   int err = 0;
u8 class_id;
 
if (!can_sched(dev))
@@ -367,12 +348,7 @@ int cxgb4_sched_class_unbind(struct net_device *dev, void 
*arg,
if (!valid_class_id(dev, class_id))
return -EINVAL;
 
-   s = pi->sched_tbl;
-   write_lock(&s->rw_lock);
-   err = t4_sched_class_bind_unbind_op(pi, arg, type, false);
-   write_unlock(&s->rw_lock);
-
-   return err;
+   return t4_sched_class_bind_unbind_op(pi, arg, type, false);
 }
 
 /* If @p is NULL, fetch any available un

[PATCH net-next] cxgb4: update supported DCB version

2018-09-14 Thread Ganesh Goudar
- In CXGB4_DCB_STATE_FW_INCOMPLETE state check if the dcb
  version is changed and update the dcb supported version.

- Also, fill the priority code point value for priority
  based flow control.

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c | 27 ++
 drivers/net/ethernet/chelsio/cxgb4/l2t.c   |  6 --
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
index b34f0f0..6ba3104 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
@@ -114,6 +114,24 @@ void cxgb4_dcb_reset(struct net_device *dev)
cxgb4_dcb_state_init(dev);
 }
 
+/* update the dcb port support, if version is IEEE then set it to
+ * FW_PORT_DCB_VER_IEEE and if DCB_CAP_DCBX_VER_CEE is already set then
+ * clear that. and if it is set to CEE then set dcb supported to
+ * DCB_CAP_DCBX_VER_CEE & if DCB_CAP_DCBX_VER_IEEE is set, clear it
+ */
+static inline void cxgb4_dcb_update_support(struct port_dcb_info *dcb)
+{
+   if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) {
+   if (dcb->supported & DCB_CAP_DCBX_VER_CEE)
+   dcb->supported &= ~DCB_CAP_DCBX_VER_CEE;
+   dcb->supported |= DCB_CAP_DCBX_VER_IEEE;
+   } else if (dcb->dcb_version == FW_PORT_DCB_VER_CEE1D01) {
+   if (dcb->supported & DCB_CAP_DCBX_VER_IEEE)
+   dcb->supported &= ~DCB_CAP_DCBX_VER_IEEE;
+   dcb->supported |= DCB_CAP_DCBX_VER_CEE;
+   }
+}
+
 /* Finite State machine for Data Center Bridging.
  */
 void cxgb4_dcb_state_fsm(struct net_device *dev,
@@ -165,6 +183,15 @@ void cxgb4_dcb_state_fsm(struct net_device *dev,
}
 
case CXGB4_DCB_STATE_FW_INCOMPLETE: {
+   if (transition_to != CXGB4_DCB_INPUT_FW_DISABLED) {
+   /* during this CXGB4_DCB_STATE_FW_INCOMPLETE state,
+* check if the dcb version is changed (there can be
+* mismatch in default config & the negotiated switch
+* configuration at FW, so update the dcb support
+* accordingly.
+*/
+   cxgb4_dcb_update_support(dcb);
+   }
switch (transition_to) {
case CXGB4_DCB_INPUT_FW_ENABLED: {
/* we're alreaady in firmware DCB mode */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/l2t.c 
b/drivers/net/ethernet/chelsio/cxgb4/l2t.c
index 301c4df..99022c0 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/l2t.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/l2t.c
@@ -433,10 +433,12 @@ struct l2t_entry *cxgb4_l2t_get(struct l2t_data *d, 
struct neighbour *neigh,
else
lport = netdev2pinfo(physdev)->lport;
 
-   if (is_vlan_dev(neigh->dev))
+   if (is_vlan_dev(neigh->dev)) {
vlan = vlan_dev_vlan_id(neigh->dev);
-   else
+   vlan |= vlan_dev_get_egress_qos_mask(neigh->dev, priority);
+   } else {
vlan = VLAN_NONE;
+   }
 
write_lock_bh(&d->lock);
for (e = d->l2tab[hash].first; e; e = e->next)
-- 
2.1.0



[PATCH net-next] cxgb4: add per rx-queue counter for packet errors

2018-09-14 Thread Ganesh Goudar
print per rx-queue packet errors in sge_qinfo

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 1 +
 drivers/net/ethernet/chelsio/cxgb4/sge.c   | 4 
 3 files changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 298701ed..b5010bd 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -692,6 +692,7 @@ struct sge_eth_stats {  /* Ethernet queue 
statistics */
unsigned long rx_cso;   /* # of Rx checksum offloads */
unsigned long vlan_ex;  /* # of Rx VLAN extractions */
unsigned long rx_drops; /* # of packets dropped due to no mem */
+   unsigned long bad_rx_pkts;  /* # of packets with err_vec!=0 */
 };
 
 struct sge_eth_rxq {/* SW Ethernet Rx queue */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index 0f72f9c..cab492e 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -2784,6 +2784,7 @@ do { \
RL("LROmerged:", stats.lro_merged);
RL("LROpackets:", stats.lro_pkts);
RL("RxDrops:", stats.rx_drops);
+   RL("RxBadPkts:", stats.bad_rx_pkts);
TL("TSO:", tso);
TL("TxCSO:", tx_cso);
TL("VLANins:", vlan_ins);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 6807bc3..b901884 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -2830,6 +2830,10 @@ int t4_ethrx_handler(struct sge_rspq *q, const __be64 
*rsp,
 
csum_ok = pkt->csum_calc && !err_vec &&
  (q->netdev->features & NETIF_F_RXCSUM);
+
+   if (err_vec)
+   rxq->stats.bad_rx_pkts++;
+
if (((pkt->l2info & htonl(RXF_TCP_F)) ||
 tnl_hdr_len) &&
(q->netdev->features & NETIF_F_GRO) && csum_ok && !pkt->ip_frag) {
-- 
2.1.0



[PATCH net-next] cxgb4: Fix endianness issue in t4_fwcache()

2018-09-14 Thread Ganesh Goudar
Do not put host-endian 0 or 1 into big endian feild.

Reported-by: Al Viro 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index c28a1d8..f85eab5 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -3889,7 +3889,7 @@ int t4_fwcache(struct adapter *adap, enum 
fw_params_param_dev_fwcache op)
c.param[0].mnem =
cpu_to_be32(FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_FWCACHE));
-   c.param[0].val = (__force __be32)op;
+   c.param[0].val = cpu_to_be32(op);
 
return t4_wr_mbox(adap, adap->mbox, &c, sizeof(c), NULL);
 }
-- 
2.1.0



[PATCH net-next] cxgb4: impose mandatory VLAN usage when non-zero TAG ID

2018-09-07 Thread Ganesh Goudar
From: Casey Leedom 

When a non-zero VLAN Tag ID is passed to t4_set_vlan_acl()
then impose mandatory VLAN Usage with that VLAN ID.
I.e any other VLAN ID should result in packets getting
dropped.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c| 3 +++
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 5fe5d16..6f1bd7b 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -10210,6 +10210,9 @@ int t4_set_vlan_acl(struct adapter *adap, unsigned int 
mbox, unsigned int vf,
vlan_cmd.en_to_len16 = cpu_to_be32(enable | FW_LEN16(vlan_cmd));
/* Drop all packets that donot match vlan id */
vlan_cmd.dropnovlan_fm = FW_ACL_VLAN_CMD_FM_F;
+   vlan_cmd.dropnovlan_fm = (enable
+ ? (FW_ACL_VLAN_CMD_DROPNOVLAN_F |
+FW_ACL_VLAN_CMD_FM_F) : 0);
if (enable != 0) {
vlan_cmd.nvlan = 1;
vlan_cmd.vlanid[0] = cpu_to_be16(vlan);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
index 5dc6c41..6d2bc87 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
@@ -2464,6 +2464,7 @@ struct fw_acl_vlan_cmd {
 
 #define FW_ACL_VLAN_CMD_DROPNOVLAN_S   7
 #define FW_ACL_VLAN_CMD_DROPNOVLAN_V(x)((x) << 
FW_ACL_VLAN_CMD_DROPNOVLAN_S)
+#define FW_ACL_VLAN_CMD_DROPNOVLAN_FFW_ACL_VLAN_CMD_DROPNOVLAN_V(1U)
 
 #define FW_ACL_VLAN_CMD_FM_S   6
 #define FW_ACL_VLAN_CMD_FM_M   0x1
-- 
2.1.0



[PATCH net-next] cxgb4: when max_tx_rate is 0 disable tx rate limiting

2018-09-03 Thread Ganesh Goudar
in ndo_set_vf_rate() when max_tx_rate is 0 disable tx
rate limiting for that vf.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 961e3087..2e1e286 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2749,6 +2749,27 @@ static int cxgb4_mgmt_set_vf_rate(struct net_device 
*dev, int vf,
return -EINVAL;
}
 
+   if (max_tx_rate == 0) {
+   /* unbind VF to to any Traffic Class */
+   fw_pfvf =
+   (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_PFVF) |
+FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_PFVF_SCHEDCLASS_ETH));
+   fw_class = 0x;
+   ret = t4_set_params(adap, adap->mbox, adap->pf, vf + 1, 1,
+   &fw_pfvf, &fw_class);
+   if (ret) {
+   dev_err(adap->pdev_dev,
+   "Err %d in unbinding PF %d VF %d from TX Rate 
Limiting\n",
+   ret, adap->pf, vf);
+   return -EINVAL;
+   }
+   dev_info(adap->pdev_dev,
+"PF %d VF %d is unbound from TX Rate Limiting\n",
+adap->pf, vf);
+   adap->vfinfo[vf].tx_rate = 0;
+   return 0;
+   }
+
ret = t4_get_link_params(pi, &link_ok, &speed, &mtu);
if (ret != FW_SUCCESS) {
dev_err(adap->pdev_dev,
@@ -2798,8 +2819,8 @@ static int cxgb4_mgmt_set_vf_rate(struct net_device *dev, 
int vf,
&fw_class);
if (ret) {
dev_err(adap->pdev_dev,
-   "Err %d in binding VF %d to Traffic Class %d\n",
-   ret, vf, class_id);
+   "Err %d in binding PF %d VF %d to Traffic Class %d\n",
+   ret, adap->pf, vf, class_id);
return -EINVAL;
}
dev_info(adap->pdev_dev, "PF %d VF %d is bound to Class %d\n",
-- 
2.1.0



Re: [endianness bug] cxgb4: mk_act_open_req() buggers ->{local,peer}_ip on big-endian hosts

2018-08-22 Thread Ganesh Goudar
Hi Al,

All the issues you have mentioned make sense to me, I will fix them
and try to have them tested on big endian machine.
I got all the patches from net-endian.chelsio they all look good,
But I am yet to go through
(struct cxgb4_next_header .match_val/.match_mask/mask should be net-endian).

regarding "le64_to_cpu(*src)", I think we have not tested our vf driver on
a big endian machine. will address this as well.

Thanks
Ganesh


Re: [endianness bug] cxgb4: mk_act_open_req() buggers ->{local,peer}_ip on big-endian hosts

2018-08-17 Thread Ganesh Goudar
Thanks, Al. The patch looks good to me but it does not seem
to be showing up in patchwork, should I resend the patch on
your behalf to net tree ?

Ganesh


[PATCH net] cxgb4: Add new T5 PCI device ids 0x50af and 0x50b0

2018-08-14 Thread Ganesh Goudar
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
index e3adf43..60df66f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
@@ -189,6 +189,8 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
CH_PCI_ID_TABLE_FENTRY(0x50ac), /* Custom T540-BT */
CH_PCI_ID_TABLE_FENTRY(0x50ad), /* Custom T520-CR */
CH_PCI_ID_TABLE_FENTRY(0x50ae), /* Custom T540-XL-SO */
+   CH_PCI_ID_TABLE_FENTRY(0x50af), /* Custom T580-KR-SO */
+   CH_PCI_ID_TABLE_FENTRY(0x50b0), /* Custom T520-CR-LOM */
 
/* T6 adapters:
 */
-- 
2.1.0



[PATCH net-next] cxgb4: add support to display DCB info

2018-08-10 Thread Ganesh Goudar
display Data Center bridging information in debug
fs.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |   1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c |   2 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 193 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   3 +-
 4 files changed, 197 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 3da9299..76d1674 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -1853,4 +1853,5 @@ void cxgb4_write_sgl(const struct sk_buff *skb, struct 
sge_txq *q,
 void cxgb4_ring_tx_db(struct adapter *adap, struct sge_txq *q, int n);
 int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf,
u16 vlan);
+int cxgb4_dcb_enabled(const struct net_device *dev);
 #endif /* __CXGB4_H__ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
index 4e7f72b..b34f0f0 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
@@ -22,7 +22,7 @@
 
 /* DCBx version control
  */
-static const char * const dcb_ver_array[] = {
+const char * const dcb_ver_array[] = {
"Unknown",
"DCBx-CIN",
"DCBx-CEE 1.01",
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index 6f312e0..0f72f9c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -2414,6 +2414,196 @@ static const struct file_operations 
rss_vf_config_debugfs_fops = {
.release = seq_release_private
 };
 
+#ifdef CONFIG_CHELSIO_T4_DCB
+extern char *dcb_ver_array[];
+
+/* Data Center Briging information for each port.
+ */
+static int dcb_info_show(struct seq_file *seq, void *v)
+{
+   struct adapter *adap = seq->private;
+
+   if (v == SEQ_START_TOKEN) {
+   seq_puts(seq, "Data Center Bridging Information\n");
+   } else {
+   int port = (uintptr_t)v - 2;
+   struct net_device *dev = adap->port[port];
+   struct port_info *pi = netdev2pinfo(dev);
+   struct port_dcb_info *dcb = &pi->dcb;
+
+   seq_puts(seq, "\n");
+   seq_printf(seq, "Port: %d (DCB negotiated: %s)\n",
+  port,
+  cxgb4_dcb_enabled(dev) ? "yes" : "no");
+
+   if (cxgb4_dcb_enabled(dev))
+   seq_printf(seq, "[ DCBx Version %s ]\n",
+  dcb_ver_array[dcb->dcb_version]);
+
+   if (dcb->msgs) {
+   int i;
+
+   seq_puts(seq, "\n  Index\t\t\t  :\t");
+   for (i = 0; i < 8; i++)
+   seq_printf(seq, " %3d", i);
+   seq_puts(seq, "\n\n");
+   }
+
+   if (dcb->msgs & CXGB4_DCB_FW_PGID) {
+   int prio, pgid;
+
+   seq_puts(seq, "  Priority Group IDs\t  :\t");
+   for (prio = 0; prio < 8; prio++) {
+   pgid = (dcb->pgid >> 4 * (7 - prio)) & 0xf;
+   seq_printf(seq, " %3d", pgid);
+   }
+   seq_puts(seq, "\n");
+   }
+
+   if (dcb->msgs & CXGB4_DCB_FW_PGRATE) {
+   int pg;
+
+   seq_puts(seq, "  Priority Group BW(%)\t  :\t");
+   for (pg = 0; pg < 8; pg++)
+   seq_printf(seq, " %3d", dcb->pgrate[pg]);
+   seq_puts(seq, "\n");
+
+   if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) {
+   seq_puts(seq, "  TSA Algorithm\t\t  :\t");
+   for (pg = 0; pg < 8; pg++)
+   seq_printf(seq, " %3d", dcb->tsa[pg]);
+   seq_puts(seq, "\n");
+   }
+
+   seq_printf(seq, "  Max PG Traffic Classes  [%3d  ]\n",
+  dcb->pg_num_tcs_supported);
+
+   seq_puts(seq, "\n");
+   }
+
+   if (dcb->msgs & CXGB4_DCB_FW_PRIORATE) {
+   int prio;
+
+   seq_puts(seq, "  Priority Rate\t:\t");
+   for (prio = 0; 

[PATCH net-next] cxgb4: update 1.20.8.0 as the latest firmware supported

2018-08-09 Thread Ganesh Goudar
Change t4fw_version.h to update latest firmware version
number to 1.20.8.0.

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h
index 4eb15ce..a844296 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h
@@ -36,8 +36,8 @@
 #define __T4FW_VERSION_H__
 
 #define T4FW_VERSION_MAJOR 0x01
-#define T4FW_VERSION_MINOR 0x13
-#define T4FW_VERSION_MICRO 0x01
+#define T4FW_VERSION_MINOR 0x14
+#define T4FW_VERSION_MICRO 0x08
 #define T4FW_VERSION_BUILD 0x00
 
 #define T4FW_MIN_VERSION_MAJOR 0x01
@@ -45,8 +45,8 @@
 #define T4FW_MIN_VERSION_MICRO 0x00
 
 #define T5FW_VERSION_MAJOR 0x01
-#define T5FW_VERSION_MINOR 0x13
-#define T5FW_VERSION_MICRO 0x01
+#define T5FW_VERSION_MINOR 0x14
+#define T5FW_VERSION_MICRO 0x08
 #define T5FW_VERSION_BUILD 0x00
 
 #define T5FW_MIN_VERSION_MAJOR 0x00
@@ -54,8 +54,8 @@
 #define T5FW_MIN_VERSION_MICRO 0x00
 
 #define T6FW_VERSION_MAJOR 0x01
-#define T6FW_VERSION_MINOR 0x13
-#define T6FW_VERSION_MICRO 0x01
+#define T6FW_VERSION_MINOR 0x14
+#define T6FW_VERSION_MICRO 0x08
 #define T6FW_VERSION_BUILD 0x00
 
 #define T6FW_MIN_VERSION_MAJOR 0x00
-- 
2.1.0



[PATCH net-next] net: Fix coding style in skb_push()

2018-08-02 Thread Ganesh Goudar
Signed-off-by: Ganesh Goudar 
---
 net/core/skbuff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 266b954..51b0a912 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1715,7 +1715,7 @@ void *skb_push(struct sk_buff *skb, unsigned int len)
 {
skb->data -= len;
skb->len  += len;
-   if (unlikely(skb->datahead))
+   if (unlikely(skb->data < skb->head))
skb_under_panic(skb, len, __builtin_return_address(0));
return skb->data;
 }
-- 
2.1.0



[PATCH net-next] cxgb4: fix endian to test F_FW_PORT_CMD_DCBXDIS32

2018-08-01 Thread Ganesh Goudar
For FW_PORT_ACTION_GET_PORT_INFO32 messages, the
u.info32.lstatus32_to_cbllen32 is 32-bit Big Endian.
We need to translate that to CPU Endian in order to
test F_FW_PORT_CMD_DCBXDIS32.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 40cf8dc..674997d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -554,10 +554,9 @@ static int fwevtq_handler(struct sge_rspq *q, const __be64 
*rsp,
 
dev = q->adap->port[q->adap->chan_map[port]];
dcbxdis = (action == FW_PORT_ACTION_GET_PORT_INFO
-  ? !!(pcmd->u.info.dcbxdis_pkd &
-   FW_PORT_CMD_DCBXDIS_F)
-  : !!(pcmd->u.info32.lstatus32_to_cbllen32 &
-   FW_PORT_CMD_DCBXDIS32_F));
+ ? !!(pcmd->u.info.dcbxdis_pkd & FW_PORT_CMD_DCBXDIS_F)
+ : !!(be32_to_cpu(pcmd->u.info32.lstatus32_to_cbllen32)
+  & FW_PORT_CMD_DCBXDIS32_F));
state_input = (dcbxdis
   ? CXGB4_DCB_INPUT_FW_DISABLED
   : CXGB4_DCB_INPUT_FW_ENABLED);
-- 
2.1.0



[PATCH net-next] cxgb4: display number of rx and tx pages free

2018-07-18 Thread Ganesh Goudar
display free rx and tx page count in the meminfo of
an adapter.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 22 +++---
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h   | 14 ++
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index 511606f..631b78b 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -2858,6 +2858,7 @@ static int meminfo_show(struct seq_file *seq, void *v)
 {
static const char * const memory[] = { "EDC0:", "EDC1:", "MC:",
   "MC0:", "MC1:", "HMA:"};
+   unsigned int free_rx_cnt, free_tx_cnt;
struct adapter *adap = seq->private;
struct cudbg_meminfo meminfo;
int i, rc;
@@ -2889,13 +2890,20 @@ static int meminfo_show(struct seq_file *seq, void *v)
mem_region_show(seq, "uP Extmem2:", meminfo.up_extmem2_lo,
meminfo.up_extmem2_hi);
 
-   seq_printf(seq, "\n%u Rx pages of size %uKiB for %u channels\n",
-  meminfo.rx_pages_data[0], meminfo.rx_pages_data[1],
-  meminfo.rx_pages_data[2]);
-
-   seq_printf(seq, "%u Tx pages of size %u%ciB for %u channels\n",
-  meminfo.tx_pages_data[0], meminfo.tx_pages_data[1],
-  meminfo.tx_pages_data[2], meminfo.tx_pages_data[3]);
+   for (i = 0, free_rx_cnt = 0; i < 2; i++)
+   free_rx_cnt += FREERXPAGECOUNT_G
+ (t4_read_reg(adap, TP_FLM_FREE_RX_CNT_A));
+   seq_printf(seq, "\n%u Rx pages (%u free) of size %uKiB for %u 
channels\n",
+  meminfo.rx_pages_data[0], free_rx_cnt,
+  meminfo.rx_pages_data[1], meminfo.rx_pages_data[2]);
+
+   for (i = 0, free_tx_cnt = 0; i < 4; i++)
+   free_tx_cnt += FREETXPAGECOUNT_G
+ (t4_read_reg(adap, TP_FLM_FREE_TX_CNT_A));
+   seq_printf(seq, "%u Tx pages (%u free) of size %u%ciB for %u 
channels\n",
+  meminfo.tx_pages_data[0], free_tx_cnt,
+  meminfo.tx_pages_data[1], meminfo.tx_pages_data[2],
+  meminfo.tx_pages_data[3]);
 
seq_printf(seq, "%u p-structs\n\n", meminfo.p_structs);
 
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
index 446aaff..da88588 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
@@ -1502,6 +1502,20 @@
 #define TP_MIB_DATA_A  0x7e54
 #define TP_INT_CAUSE_A 0x7e74
 
+#define TP_FLM_FREE_RX_CNT_A 0x7e84
+
+#define FREERXPAGECOUNT_S0
+#define FREERXPAGECOUNT_M0x1fU
+#define FREERXPAGECOUNT_V(x) ((x) << FREERXPAGECOUNT_S)
+#define FREERXPAGECOUNT_G(x) (((x) >> FREERXPAGECOUNT_S) & FREERXPAGECOUNT_M)
+
+#define TP_FLM_FREE_TX_CNT_A 0x7e88
+
+#define FREETXPAGECOUNT_S0
+#define FREETXPAGECOUNT_M0x1fU
+#define FREETXPAGECOUNT_V(x) ((x) << FREETXPAGECOUNT_S)
+#define FREETXPAGECOUNT_G(x) (((x) >> FREETXPAGECOUNT_S) & FREETXPAGECOUNT_M)
+
 #define FLMTXFLSTEMPTY_S30
 #define FLMTXFLSTEMPTY_V(x) ((x) << FLMTXFLSTEMPTY_S)
 #define FLMTXFLSTEMPTY_FFLMTXFLSTEMPTY_V(1U)
-- 
2.1.0



[PATCH net-next] cxgb4: do not return DUPLEX_UNKNOWN when link is down

2018-07-13 Thread Ganesh Goudar
We were returning DUPLEX_UNKNOWN in get_link_ksettings() when
the link was down.  Unfortunately, this causes a problem when
"ethtool -s autoneg on" is issued for a link which is down because
the ethtool code first reads the settings and then reapplies them
with only the changes provided on the command line. Which results
in us diving into set_link_ksettings() with DUPLEX_UNKNOWN which is
not DUPLEX_FULL, so set_link_ksettings() throws an -EINVAL error.
do not return DUPLEX_UNKNOWN to fix the issue.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index a14a290..d07230c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -628,13 +628,10 @@ static int get_link_ksettings(struct net_device *dev,
fw_caps_to_lmm(pi->port_type, pi->link_cfg.lpacaps,
   link_ksettings->link_modes.lp_advertising);
 
-   if (netif_carrier_ok(dev)) {
-   base->speed = pi->link_cfg.speed;
-   base->duplex = DUPLEX_FULL;
-   } else {
-   base->speed = SPEED_UNKNOWN;
-   base->duplex = DUPLEX_UNKNOWN;
-   }
+   base->speed = (netif_carrier_ok(dev)
+  ? pi->link_cfg.speed
+  : SPEED_UNKNOWN);
+   base->duplex = DUPLEX_FULL;
 
if (pi->link_cfg.fc & PAUSE_RX) {
if (pi->link_cfg.fc & PAUSE_TX) {
-- 
2.1.0



[PATCH net-next] cxgb4: specify IQTYPE in fw_iq_cmd

2018-07-09 Thread Ganesh Goudar
From: Arjun Vynipadath 

congestion argument passed to t4_sge_alloc_rxq() is used
to differentiate between nic/ofld queues.

Signed-off-by: Arjun Vynipadath 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/sge.c  |  4 +++-
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | 12 
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index ebb46c4..6807bc3 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -3412,7 +3412,9 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct 
sge_rspq *iq, bool fwevtq,
c.iqsize = htons(iq->size);
c.iqaddr = cpu_to_be64(iq->phys_addr);
if (cong >= 0)
-   c.iqns_to_fl0congen = htonl(FW_IQ_CMD_IQFLINTCONGEN_F);
+   c.iqns_to_fl0congen = htonl(FW_IQ_CMD_IQFLINTCONGEN_F |
+   FW_IQ_CMD_IQTYPE_V(cong ? FW_IQ_IQTYPE_NIC
+   :  FW_IQ_IQTYPE_OFLD));
 
if (fl) {
enum chip_type chip = CHELSIO_CHIP_VERSION(adap->params.chip);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
index f1967cf..5dc6c41 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
@@ -1472,6 +1472,12 @@ enum fw_iq_type {
FW_IQ_TYPE_NO_FL_INT_CAP
 };
 
+enum fw_iq_iqtype {
+   FW_IQ_IQTYPE_OTHER,
+   FW_IQ_IQTYPE_NIC,
+   FW_IQ_IQTYPE_OFLD,
+};
+
 struct fw_iq_cmd {
__be32 op_to_vfn;
__be32 alloc_to_len16;
@@ -1586,6 +1592,12 @@ struct fw_iq_cmd {
 #define FW_IQ_CMD_IQFLINTISCSIC_S  26
 #define FW_IQ_CMD_IQFLINTISCSIC_V(x)   ((x) << FW_IQ_CMD_IQFLINTISCSIC_S)
 
+#define FW_IQ_CMD_IQTYPE_S 24
+#define FW_IQ_CMD_IQTYPE_M 0x3
+#define FW_IQ_CMD_IQTYPE_V(x)  ((x) << FW_IQ_CMD_IQTYPE_S)
+#define FW_IQ_CMD_IQTYPE_G(x)  \
+   (((x) >> FW_IQ_CMD_IQTYPE_S) & FW_IQ_CMD_IQTYPE_M)
+
 #define FW_IQ_CMD_FL0CNGCHMAP_S20
 #define FW_IQ_CMD_FL0CNGCHMAP_V(x) ((x) << FW_IQ_CMD_FL0CNGCHMAP_S)
 
-- 
2.1.0



[PATH net] cxgb4: assume flash part size to be 4MB, if it can't be determined

2018-07-07 Thread Ganesh Goudar
From: Casey Leedom 

t4_get_flash_params() fails in a fatal fashion if the FLASH part isn't
one of the recognized parts. But this leads to desperate efforts to update
drivers when various FLASH parts which we are using suddenly become
unavailable and we need to substitute new FLASH parts.  This has lead to
more than one Customer Field Emergency when a Customer has an old driver
and suddenly can't use newly shipped adapters.

This commit fixes this by simply assuming that the FLASH part is 4MB in
size if it can't be identified. Note that all Chelsio adapters will have
flash parts which are at least 4MB in size.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 35 +++---
 1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index d266177..2d9943f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -8753,7 +8753,7 @@ static int t4_get_flash_params(struct adapter *adap)
};
 
unsigned int part, manufacturer;
-   unsigned int density, size;
+   unsigned int density, size = 0;
u32 flashid = 0;
int ret;
 
@@ -8823,11 +8823,6 @@ static int t4_get_flash_params(struct adapter *adap)
case 0x22: /* 256MB */
size = 1 << 28;
break;
-
-   default:
-   dev_err(adap->pdev_dev, "Micron Flash Part has bad 
size, ID = %#x, Density code = %#x\n",
-   flashid, density);
-   return -EINVAL;
}
break;
}
@@ -8843,10 +8838,6 @@ static int t4_get_flash_params(struct adapter *adap)
case 0x17: /* 64MB */
size = 1 << 26;
break;
-   default:
-   dev_err(adap->pdev_dev, "ISSI Flash Part has bad size, 
ID = %#x, Density code = %#x\n",
-   flashid, density);
-   return -EINVAL;
}
break;
}
@@ -8862,10 +8853,6 @@ static int t4_get_flash_params(struct adapter *adap)
case 0x18: /* 16MB */
size = 1 << 24;
break;
-   default:
-   dev_err(adap->pdev_dev, "Macronix Flash Part has bad 
size, ID = %#x, Density code = %#x\n",
-   flashid, density);
-   return -EINVAL;
}
break;
}
@@ -8881,17 +8868,21 @@ static int t4_get_flash_params(struct adapter *adap)
case 0x18: /* 16MB */
size = 1 << 24;
break;
-   default:
-   dev_err(adap->pdev_dev, "Winbond Flash Part has bad 
size, ID = %#x, Density code = %#x\n",
-   flashid, density);
-   return -EINVAL;
}
break;
}
-   default:
-   dev_err(adap->pdev_dev, "Unsupported Flash Part, ID = %#x\n",
-   flashid);
-   return -EINVAL;
+   }
+
+   /* If we didn't recognize the FLASH part, that's no real issue: the
+* Hardware/Software contract says that Hardware will _*ALWAYS*_
+* use a FLASH part which is at least 4MB in size and has 64KB
+* sectors.  The unrecognized FLASH part is likely to be much larger
+* than 4MB, but that's all we really need.
+*/
+   if (size == 0) {
+   dev_warn(adap->pdev_dev, "Unknown Flash Part, ID = %#x, 
assuming 4MB\n",
+flashid);
+   size = 1 << 22;
}
 
/* Store decoded Flash size and fall through into vetting code. */
-- 
2.1.0



[PATCH net-next] cxgb4: Fix the condition to check if the card is T5

2018-07-04 Thread Ganesh Goudar
Use 'chip_ver' rather than 'chip' to check if the card
is T5.

Fixes: e8d452923ae6 ("cxgb4: clean up init_one")
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 1be30bc..93b4b5a 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5766,7 +5766,7 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (t4_read_reg(adapter, LE_DB_CONFIG_A) & HASHEN_F) {
u32 hash_base, hash_reg;
 
-   if (chip <= CHELSIO_T5) {
+   if (chip_ver <= CHELSIO_T5) {
hash_reg = LE_DB_TID_HASHBASE_A;
hash_base = t4_read_reg(adapter, hash_reg);
adapter->tids.hash_base = hash_base / 4;
-- 
2.1.0



[PATCH net-next] cxgb4: Add support to read actual provisioned resources

2018-07-04 Thread Ganesh Goudar
From: Casey Leedom 

In highly constrained resources environments (like the 124VF
T5 and 248VF T6 configurations), PF4 may not have very many
resources at all and we need to adapt to whatever we've been
allocated, this patch adds support to get the provisioned
resources.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |  17 +++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c |  39 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c| 134 +++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |  51 
 4 files changed, 206 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 4a8cbd8..3da9299 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -320,6 +320,21 @@ struct vpd_params {
u8 na[MACADDR_LEN + 1];
 };
 
+/* Maximum resources provisioned for a PCI PF.
+ */
+struct pf_resources {
+   unsigned int nvi;   /* N virtual interfaces */
+   unsigned int neq;   /* N egress Qs */
+   unsigned int nethctrl;  /* N egress ETH or CTRL Qs */
+   unsigned int niqflint;  /* N ingress Qs/w free list(s) & intr */
+   unsigned int niq;   /* N ingress Qs */
+   unsigned int tc;/* PCI-E traffic class */
+   unsigned int pmask; /* port access rights mask */
+   unsigned int nexactf;   /* N exact MPS filters */
+   unsigned int r_caps;/* read capabilities */
+   unsigned int wx_caps;   /* write/execute capabilities */
+};
+
 struct pci_params {
unsigned int vpd_cap_addr;
unsigned char speed;
@@ -347,6 +362,7 @@ struct adapter_params {
struct sge_params sge;
struct tp_params  tp;
struct vpd_params vpd;
+   struct pf_resources pfres;
struct pci_params pci;
struct devlog_params devlog;
enum pcie_memwin drv_memwin;
@@ -1568,6 +1584,7 @@ int t4_eeprom_ptov(unsigned int phys_addr, unsigned int 
fn, unsigned int sz);
 int t4_seeprom_wp(struct adapter *adapter, bool enable);
 int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p);
 int t4_get_vpd_params(struct adapter *adapter, struct vpd_params *p);
+int t4_get_pfres(struct adapter *adapter);
 int t4_read_flash(struct adapter *adapter, unsigned int addr,
  unsigned int nwords, u32 *data, int byte_oriented);
 int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index c301aaf..516c883 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -2414,6 +2414,44 @@ static const struct file_operations 
rss_vf_config_debugfs_fops = {
.release = seq_release_private
 };
 
+static int resources_show(struct seq_file *seq, void *v)
+{
+   struct adapter *adapter = seq->private;
+   struct pf_resources *pfres = &adapter->params.pfres;
+
+   #define S(desc, fmt, var) \
+   seq_printf(seq, "%-60s " fmt "\n", \
+  desc " (" #var "):", pfres->var)
+
+   S("Virtual Interfaces", "%d", nvi);
+   S("Egress Queues", "%d", neq);
+   S("Ethernet Control", "%d", nethctrl);
+   S("Ingress Queues/w Free Lists/Interrupts", "%d", niqflint);
+   S("Ingress Queues", "%d", niq);
+   S("Traffic Class", "%d", tc);
+   S("Port Access Rights Mask", "%#x", pmask);
+   S("MAC Address Filters", "%d", nexactf);
+   S("Firmware Command Read Capabilities", "%#x", r_caps);
+   S("Firmware Command Write/Execute Capabilities", "%#x", wx_caps);
+
+   #undef S
+
+   return 0;
+}
+
+static int resources_open(struct inode *inode, struct file *file)
+{
+   return single_open(file, resources_show, inode->i_private);
+}
+
+static const struct file_operations resources_debugfs_fops = {
+   .owner   = THIS_MODULE,
+   .open= resources_open,
+   .read= seq_read,
+   .llseek  = seq_lseek,
+   .release = seq_release,
+};
+
 /**
  * ethqset2pinfo - return port_info of an Ethernet Queue Set
  * @adap: the adapter
@@ -2973,6 +3011,7 @@ int t4_setup_debugfs(struct adapter *adap)
{ "rss_key", &rss_key_debugfs_fops, 0400, 0 },
{ "rss_pf_config", &rss_pf_config_debugfs_fops, 0400, 0 },
{ "rss_vf_config", &rss_vf_config_debugfs_fops, 0400, 0 },
+ 

[PATCH net-next V4 2/2] cxgb4: Support ethtool private flags

2018-06-26 Thread Ganesh Goudar
From: Arjun Vynipadath 

This is used to change TX workrequests, which helps in
host->vf communication.

Signed-off-by: Arjun Vynipadath 
Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
V4: No changes

V3: No changes

V2: No changes
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index f7eef93..ddb8b9e 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -177,6 +177,10 @@ static char loopback_stats_strings[][ETH_GSTRING_LEN] = {
"bg3_frames_trunc   ",
 };
 
+static const char cxgb4_priv_flags_strings[][ETH_GSTRING_LEN] = {
+   [PRIV_FLAG_PORT_TX_VM_BIT] = "port_tx_vm_wr",
+};
+
 static int get_sset_count(struct net_device *dev, int sset)
 {
switch (sset) {
@@ -185,6 +189,8 @@ static int get_sset_count(struct net_device *dev, int sset)
   ARRAY_SIZE(adapter_stats_strings) +
   ARRAY_SIZE(channel_stats_strings) +
   ARRAY_SIZE(loopback_stats_strings);
+   case ETH_SS_PRIV_FLAGS:
+   return ARRAY_SIZE(cxgb4_priv_flags_strings);
default:
return -EOPNOTSUPP;
}
@@ -235,6 +241,7 @@ static void get_drvinfo(struct net_device *dev, struct 
ethtool_drvinfo *info)
 FW_HDR_FW_VER_MINOR_G(exprom_vers),
 FW_HDR_FW_VER_MICRO_G(exprom_vers),
 FW_HDR_FW_VER_BUILD_G(exprom_vers));
+   info->n_priv_flags = ARRAY_SIZE(cxgb4_priv_flags_strings);
 }
 
 static void get_strings(struct net_device *dev, u32 stringset, u8 *data)
@@ -250,6 +257,9 @@ static void get_strings(struct net_device *dev, u32 
stringset, u8 *data)
data += sizeof(channel_stats_strings);
memcpy(data, loopback_stats_strings,
   sizeof(loopback_stats_strings));
+   } else if (stringset == ETH_SS_PRIV_FLAGS) {
+   memcpy(data, cxgb4_priv_flags_strings,
+  sizeof(cxgb4_priv_flags_strings));
}
 }
 
@@ -1499,6 +1509,36 @@ static int cxgb4_get_module_eeprom(struct net_device 
*dev,
 offset, len, &data[eprom->len - len]);
 }
 
+static u32 cxgb4_get_priv_flags(struct net_device *netdev)
+{
+   struct port_info *pi = netdev_priv(netdev);
+   struct adapter *adapter = pi->adapter;
+
+   return (adapter->eth_flags | pi->eth_flags);
+}
+
+/**
+ * set_flags - set/unset specified flags if passed in new_flags
+ * @cur_flags: pointer to current flags
+ * @new_flags: new incoming flags
+ * @flags: set of flags to set/unset
+ */
+static inline void set_flags(u32 *cur_flags, u32 new_flags, u32 flags)
+{
+   *cur_flags = (*cur_flags & ~flags) | (new_flags & flags);
+}
+
+static int cxgb4_set_priv_flags(struct net_device *netdev, u32 flags)
+{
+   struct port_info *pi = netdev_priv(netdev);
+   struct adapter *adapter = pi->adapter;
+
+   set_flags(&adapter->eth_flags, flags, PRIV_FLAGS_ADAP);
+   set_flags(&pi->eth_flags, flags, PRIV_FLAGS_PORT);
+
+   return 0;
+}
+
 static const struct ethtool_ops cxgb_ethtool_ops = {
.get_link_ksettings = get_link_ksettings,
.set_link_ksettings = set_link_ksettings,
@@ -1535,6 +1575,8 @@ static const struct ethtool_ops cxgb_ethtool_ops = {
.get_dump_data = get_dump_data,
.get_module_info   = cxgb4_get_module_info,
.get_module_eeprom = cxgb4_get_module_eeprom,
+   .get_priv_flags= cxgb4_get_priv_flags,
+   .set_priv_flags= cxgb4_set_priv_flags,
 };
 
 void cxgb4_set_ethtool_ops(struct net_device *netdev)
-- 
2.1.0



[PATCH net-next V4 1/2] cxgb4: Add support for FW_ETH_TX_PKT_VM_WR

2018-06-26 Thread Ganesh Goudar
From: Arjun Vynipadath 

The present TX workrequest(FW_ETH_TX_PKT_WR) cant be used for
host->vf communication, since it doesn't loopback the outgoing
packets to virtual interfaces on the same port. This can be done
using FW_ETH_TX_PKT_VM_WR.
This fix depends on ethtool_flags to determine what WR to use for
TX path. Support for setting this flags by user is added in next
commit.

Based on the original work by : Casey Leedom 

Signed-off-by: Casey Leedom 
Signed-off-by: Arjun Vynipadath 
Signed-off-by: Ganesh Goudar 
---
V4: Fixed build errors.

V3: Made eth_flags type consistent across struct adapter and
struct port_info.   
   

V2: Renamed t4_eth_xmit() and t4vf_eth_xmit(), since some compilers
were warning about conflicting definition in cxgb4vf driver
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |  13 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   2 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c| 372 +++-
 3 files changed, 383 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 1adb968..a4ea53d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -522,6 +522,15 @@ enum {
MAX_INGQ = MAX_ETH_QSETS + INGQ_EXTRAS,
 };
 
+enum {
+   PRIV_FLAG_PORT_TX_VM_BIT,
+};
+
+#define PRIV_FLAG_PORT_TX_VM   BIT(PRIV_FLAG_PORT_TX_VM_BIT)
+
+#define PRIV_FLAGS_ADAP0
+#define PRIV_FLAGS_PORTPRIV_FLAG_PORT_TX_VM
+
 struct adapter;
 struct sge_rspq;
 
@@ -558,6 +567,7 @@ struct port_info {
struct hwtstamp_config tstamp_config;
bool ptp_enable;
struct sched_table *sched_tbl;
+   u32 eth_flags;
 };
 
 struct dentry;
@@ -868,6 +878,7 @@ struct adapter {
unsigned int flags;
unsigned int adap_idx;
enum chip_type chip;
+   u32 eth_flags;
 
int msg_enable;
__be16 vxlan_port;
@@ -1334,7 +1345,7 @@ void t4_os_link_changed(struct adapter *adap, int 
port_id, int link_stat);
 void t4_free_sge_resources(struct adapter *adap);
 void t4_free_ofld_rxqs(struct adapter *adap, int n, struct sge_ofld_rxq *q);
 irq_handler_t t4_intr_handler(struct adapter *adap);
-netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev);
+netdev_tx_t t4_start_xmit(struct sk_buff *skb, struct net_device *dev);
 int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
 const struct pkt_gl *gl);
 int t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index bc03c17..d3b0f9c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3217,7 +3217,7 @@ static netdev_features_t cxgb_fix_features(struct 
net_device *dev,
 static const struct net_device_ops cxgb4_netdev_ops = {
.ndo_open = cxgb_open,
.ndo_stop = cxgb_close,
-   .ndo_start_xmit   = t4_eth_xmit,
+   .ndo_start_xmit   = t4_start_xmit,
.ndo_select_queue = cxgb_select_queue,
.ndo_get_stats64  = cxgb_get_stats,
.ndo_set_rx_mode  = cxgb_set_rxmode,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 395e2a0..ebb46c4 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -1288,13 +1288,13 @@ static inline void t6_fill_tnl_lso(struct sk_buff *skb,
 }
 
 /**
- * t4_eth_xmit - add a packet to an Ethernet Tx queue
+ * cxgb4_eth_xmit - add a packet to an Ethernet Tx queue
  * @skb: the packet
  * @dev: the egress net device
  *
  * Add a packet to an SGE Ethernet Tx queue.  Runs with softirqs disabled.
  */
-netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t cxgb4_eth_xmit(struct sk_buff *skb, struct net_device *dev)
 {
u32 wr_mid, ctrl0, op;
u64 cntrl, *end, *sgl;
@@ -1547,6 +1547,374 @@ out_free:   dev_kfree_skb_any(skb);
return NETDEV_TX_OK;
 }
 
+/* Constants ... */
+enum {
+   /* Egress Queue sizes, producer and consumer indices are all in units
+* of Egress Context Units bytes.  Note that as far as the hardware is
+* concerned, the free list is an Egress Queue (the host produces free
+* buffers which the hardware consumes) and free list entries are
+* 64-bit PCI DMA addresses.
+*/
+   EQ_UNIT = SGE_EQ_IDXSIZE,
+   FL_PER_EQ_UNIT = EQ_UNIT / sizeof(__be64),
+   TXD_PER_EQ_UNIT = EQ_UNIT / sizeof(__be64),
+
+   T4VF_ETHTXQ_MAX_HDR = (sizeof(struct fw_eth_tx_pkt_vm_wr) +
+  sizeof(struct cpl_tx_pkt_lso_core) +
+  sizeo

[PATCH net-next] cxgb4: Add new T5 PCI device id 0x50ae

2018-06-26 Thread Ganesh Goudar
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
index c7f8d04..e3adf43 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
@@ -188,6 +188,7 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
CH_PCI_ID_TABLE_FENTRY(0x50ab), /* Custom T520-CR */
CH_PCI_ID_TABLE_FENTRY(0x50ac), /* Custom T540-BT */
CH_PCI_ID_TABLE_FENTRY(0x50ad), /* Custom T520-CR */
+   CH_PCI_ID_TABLE_FENTRY(0x50ae), /* Custom T540-XL-SO */
 
/* T6 adapters:
 */
-- 
2.1.0



[PATCH net-next] cxgb4: Add flag tc_flower_initialized

2018-06-26 Thread Ganesh Goudar
From: Casey Leedom 

Add flag tc_flower_initialized to indicate the
completion if tc flower initialization.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h   | 1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 8 
 drivers/net/ethernet/chelsio/cxgb4/sched.c   | 3 +++
 3 files changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index a4ea53d..4a8cbd8 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -968,6 +968,7 @@ struct adapter {
struct chcr_stats_debug chcr_stats;
 
/* TC flower offload */
+   bool tc_flower_initialized;
struct rhashtable flower_tbl;
struct rhashtable_params flower_ht_params;
struct timer_list flower_stats_timer;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
index 3ddd2c4..623f73d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
@@ -874,6 +874,9 @@ int cxgb4_init_tc_flower(struct adapter *adap)
 {
int ret;
 
+   if (adap->tc_flower_initialized)
+   return -EEXIST;
+
adap->flower_ht_params = cxgb4_tc_flower_ht_params;
ret = rhashtable_init(&adap->flower_tbl, &adap->flower_ht_params);
if (ret)
@@ -882,13 +885,18 @@ int cxgb4_init_tc_flower(struct adapter *adap)
INIT_WORK(&adap->flower_stats_work, ch_flower_stats_handler);
timer_setup(&adap->flower_stats_timer, ch_flower_stats_cb, 0);
mod_timer(&adap->flower_stats_timer, jiffies + STATS_CHECK_PERIOD);
+   adap->tc_flower_initialized = true;
return 0;
 }
 
 void cxgb4_cleanup_tc_flower(struct adapter *adap)
 {
+   if (!adap->tc_flower_initialized)
+   return;
+
if (adap->flower_stats_timer.function)
del_timer_sync(&adap->flower_stats_timer);
cancel_work_sync(&adap->flower_stats_work);
rhashtable_destroy(&adap->flower_tbl);
+   adap->tc_flower_initialized = false;
 }
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sched.c 
b/drivers/net/ethernet/chelsio/cxgb4/sched.c
index 9148abb..7fc6566 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sched.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sched.c
@@ -539,6 +539,9 @@ void t4_cleanup_sched(struct adapter *adap)
struct port_info *pi = netdev2pinfo(adap->port[j]);
 
s = pi->sched_tbl;
+   if (!s)
+   continue;
+
for (i = 0; i < s->sched_size; i++) {
struct sched_class *e;
 
-- 
2.1.0



[PATCH net-next V3 2/2] cxgb4: Support ethtool private flags

2018-06-26 Thread Ganesh Goudar
From: Arjun Vynipadath 

This is used to change TX workrequests, which helps in
host->vf communication.

Signed-off-by: Arjun Vynipadath 
Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index f7eef93..ddb8b9e 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -177,6 +177,10 @@ static char loopback_stats_strings[][ETH_GSTRING_LEN] = {
"bg3_frames_trunc   ",
 };
 
+static const char cxgb4_priv_flags_strings[][ETH_GSTRING_LEN] = {
+   [PRIV_FLAG_PORT_TX_VM_BIT] = "port_tx_vm_wr",
+};
+
 static int get_sset_count(struct net_device *dev, int sset)
 {
switch (sset) {
@@ -185,6 +189,8 @@ static int get_sset_count(struct net_device *dev, int sset)
   ARRAY_SIZE(adapter_stats_strings) +
   ARRAY_SIZE(channel_stats_strings) +
   ARRAY_SIZE(loopback_stats_strings);
+   case ETH_SS_PRIV_FLAGS:
+   return ARRAY_SIZE(cxgb4_priv_flags_strings);
default:
return -EOPNOTSUPP;
}
@@ -235,6 +241,7 @@ static void get_drvinfo(struct net_device *dev, struct 
ethtool_drvinfo *info)
 FW_HDR_FW_VER_MINOR_G(exprom_vers),
 FW_HDR_FW_VER_MICRO_G(exprom_vers),
 FW_HDR_FW_VER_BUILD_G(exprom_vers));
+   info->n_priv_flags = ARRAY_SIZE(cxgb4_priv_flags_strings);
 }
 
 static void get_strings(struct net_device *dev, u32 stringset, u8 *data)
@@ -250,6 +257,9 @@ static void get_strings(struct net_device *dev, u32 
stringset, u8 *data)
data += sizeof(channel_stats_strings);
memcpy(data, loopback_stats_strings,
   sizeof(loopback_stats_strings));
+   } else if (stringset == ETH_SS_PRIV_FLAGS) {
+   memcpy(data, cxgb4_priv_flags_strings,
+  sizeof(cxgb4_priv_flags_strings));
}
 }
 
@@ -1499,6 +1509,36 @@ static int cxgb4_get_module_eeprom(struct net_device 
*dev,
 offset, len, &data[eprom->len - len]);
 }
 
+static u32 cxgb4_get_priv_flags(struct net_device *netdev)
+{
+   struct port_info *pi = netdev_priv(netdev);
+   struct adapter *adapter = pi->adapter;
+
+   return (adapter->eth_flags | pi->eth_flags);
+}
+
+/**
+ * set_flags - set/unset specified flags if passed in new_flags
+ * @cur_flags: pointer to current flags
+ * @new_flags: new incoming flags
+ * @flags: set of flags to set/unset
+ */
+static inline void set_flags(u32 *cur_flags, u32 new_flags, u32 flags)
+{
+   *cur_flags = (*cur_flags & ~flags) | (new_flags & flags);
+}
+
+static int cxgb4_set_priv_flags(struct net_device *netdev, u32 flags)
+{
+   struct port_info *pi = netdev_priv(netdev);
+   struct adapter *adapter = pi->adapter;
+
+   set_flags(&adapter->eth_flags, flags, PRIV_FLAGS_ADAP);
+   set_flags(&pi->eth_flags, flags, PRIV_FLAGS_PORT);
+
+   return 0;
+}
+
 static const struct ethtool_ops cxgb_ethtool_ops = {
.get_link_ksettings = get_link_ksettings,
.set_link_ksettings = set_link_ksettings,
@@ -1535,6 +1575,8 @@ static const struct ethtool_ops cxgb_ethtool_ops = {
.get_dump_data = get_dump_data,
.get_module_info   = cxgb4_get_module_info,
.get_module_eeprom = cxgb4_get_module_eeprom,
+   .get_priv_flags= cxgb4_get_priv_flags,
+   .set_priv_flags= cxgb4_set_priv_flags,
 };
 
 void cxgb4_set_ethtool_ops(struct net_device *netdev)
-- 
2.1.0



[PATCH net-next V3 1/2] cxgb4: Add support for FW_ETH_TX_PKT_VM_WR

2018-06-26 Thread Ganesh Goudar
From: Arjun Vynipadath 

The present TX workrequest(FW_ETH_TX_PKT_WR) cant be used for
host->vf communication, since it doesn't loopback the outgoing
packets to virtual interfaces on the same port. This can be done using
FW_ETH_TX_PKT_VM_WR.
This fix depends on ethtool_flags to determine what WR to use for
TX path. Support for setting this flags by user is added in next commit.

Based on the original work by : Casey Leedom 

V3
- Made eth_flags type consistent across struct adapter and
  struct port_info.
V2
- Renamed t4_eth_xmit() and t4vf_eth_xmit(), since some compilers
  were warning about conflicting definition in cxgb4vf driver

Signed-off-by: Casey Leedom 
Signed-off-by: Arjun Vynipadath 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |  13 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   2 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c| 372 +++-
 3 files changed, 383 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 1adb968..a4ea53d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -522,6 +522,15 @@ enum {
MAX_INGQ = MAX_ETH_QSETS + INGQ_EXTRAS,
 };
 
+enum {
+   PRIV_FLAG_PORT_TX_VM_BIT,
+};
+
+#define PRIV_FLAG_PORT_TX_VM   BIT(PRIV_FLAG_PORT_TX_VM_BIT)
+
+#define PRIV_FLAGS_ADAP0
+#define PRIV_FLAGS_PORTPRIV_FLAG_PORT_TX_VM
+
 struct adapter;
 struct sge_rspq;
 
@@ -558,6 +567,7 @@ struct port_info {
struct hwtstamp_config tstamp_config;
bool ptp_enable;
struct sched_table *sched_tbl;
+   u32 eth_flags;
 };
 
 struct dentry;
@@ -868,6 +878,7 @@ struct adapter {
unsigned int flags;
unsigned int adap_idx;
enum chip_type chip;
+   u32 eth_flags;
 
int msg_enable;
__be16 vxlan_port;
@@ -1334,7 +1345,7 @@ void t4_os_link_changed(struct adapter *adap, int 
port_id, int link_stat);
 void t4_free_sge_resources(struct adapter *adap);
 void t4_free_ofld_rxqs(struct adapter *adap, int n, struct sge_ofld_rxq *q);
 irq_handler_t t4_intr_handler(struct adapter *adap);
-netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev);
+netdev_tx_t t4_start_xmit(struct sk_buff *skb, struct net_device *dev);
 int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
 const struct pkt_gl *gl);
 int t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index bc03c17..d3b0f9c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3217,7 +3217,7 @@ static netdev_features_t cxgb_fix_features(struct 
net_device *dev,
 static const struct net_device_ops cxgb4_netdev_ops = {
.ndo_open = cxgb_open,
.ndo_stop = cxgb_close,
-   .ndo_start_xmit   = t4_eth_xmit,
+   .ndo_start_xmit   = t4_start_xmit,
.ndo_select_queue = cxgb_select_queue,
.ndo_get_stats64  = cxgb_get_stats,
.ndo_set_rx_mode  = cxgb_set_rxmode,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 395e2a0..f1311fd 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -1288,13 +1288,13 @@ static inline void t6_fill_tnl_lso(struct sk_buff *skb,
 }
 
 /**
- * t4_eth_xmit - add a packet to an Ethernet Tx queue
+ * cxgb4_eth_xmit - add a packet to an Ethernet Tx queue
  * @skb: the packet
  * @dev: the egress net device
  *
  * Add a packet to an SGE Ethernet Tx queue.  Runs with softirqs disabled.
  */
-netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t cxgb4_eth_xmit(struct sk_buff *skb, struct net_device *dev)
 {
u32 wr_mid, ctrl0, op;
u64 cntrl, *end, *sgl;
@@ -1547,6 +1547,374 @@ out_free:   dev_kfree_skb_any(skb);
return NETDEV_TX_OK;
 }
 
+/* Constants ... */
+enum {
+   /* Egress Queue sizes, producer and consumer indices are all in units
+* of Egress Context Units bytes.  Note that as far as the hardware is
+* concerned, the free list is an Egress Queue (the host produces free
+* buffers which the hardware consumes) and free list entries are
+* 64-bit PCI DMA addresses.
+*/
+   EQ_UNIT = SGE_EQ_IDXSIZE,
+   FL_PER_EQ_UNIT = EQ_UNIT / sizeof(__be64),
+   TXD_PER_EQ_UNIT = EQ_UNIT / sizeof(__be64),
+
+   T4VF_ETHTXQ_MAX_HDR = (sizeof(struct fw_eth_tx_pkt_vm_wr) +
+  sizeof(struct cpl_tx_pkt_lso_core) +
+  sizeof(struct cpl_tx_pkt_core)) / sizeof(__be64),
+};
+
+/**
+ * t4vf_is_eth_imm - can an Ethernet packet

[PATCH net] cxgb4: when disabling dcb set txq dcb priority to 0

2018-06-23 Thread Ganesh Goudar
When we are disabling DCB, store "0" in txq->dcb_prio
since that's used for future TX Work Request "OVLAN_IDX"
values. Setting non zero priority upon disabling DCB
would halt the traffic.

Reported-by: AMG Zollner Robert 
CC: David Ahern 
Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 35cb3ae..aaaf775 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -263,7 +263,7 @@ static void dcb_tx_queue_prio_enable(struct net_device 
*dev, int enable)
"Can't %s DCB Priority on port %d, TX Queue %d: 
err=%d\n",
enable ? "set" : "unset", pi->port_id, i, -err);
else
-   txq->dcb_prio = value;
+   txq->dcb_prio = enable ? value : 0;
}
 }
 
-- 
2.1.0



Re: [bug] cxgb4: vrf stopped working with cxgb4 card

2018-06-11 Thread Ganesh Goudar
On Saturday, June 06/09/18, 2018 at 18:47:55 -0600, David Ahern wrote:
> Ganesh:
> 
> On 6/4/18 9:03 AM, AMG Zollner Robert wrote:
> > I have noticed that vrf is not working with kernel v4.15.0 but was
> > working with v4.13.0 when using cxgb4 Chelsio driver (T520-cr)
> > 
> > Setup:
> > Two metal servers with a T520-cr card each, directly connected without a
> > switch in between.
> > 
> >    SVR1  only ipfwd SVR2     with vrf
> > .. .--.
> > |                        | |     |
> > |    192.168.8.1 [  ens2f4]--|-|--[ens1f4] 192.168.8.2   |
> > |    192.168.9.1 [ens2f4d1]--|-|-- 192.168.9.2 VRF=10   |
> > `' `--'
> > 
> > When vrf is not working there are no error messages (dmesg or iproute
> > commands), tcpdump on the interface (SVR2.ens1f4d1) enslaved in vrf 10
> > shows packets(arp req/reply) coming in and going out, but outgoing
> > packets(arp reply) do not reach the other server SVR1.ens2f4d1
> > 
> > 
> > Bisect:
> > Found this commit to be the problem after doing a git bisect between
> > v4.13..v4.15:
> > 
> > commit ba581f77df23c8ee70b372966e69cf10bc5453d8
> > Author: Ganesh Goudar 
> > Date:   Sat Sep 23 16:07:28 2017 +0530
> > 
> >     cxgb4: do DCB state reset in couple of places
> > 
> >     reset the driver's DCB state in couple of places
> >     where it was missing.
> 
> Are you working on a fix for this or should a revert of the above patch
> be sent?
Will look into it and fix/revert it soon, Thanks for responding to Robert.
> 
> 
> > 
> > 
> > A bisect step was considered good when:
> > - successful ping from SVR1 to SVR2.ens1f4d1 vrf interface
> > - successful ping from SVR2 global to SVR2 vrf interface trough SVR1(l3
> > forwarding) (this check was redundant,both tests fail or pass simultaneous)
> > 
> > The problem is still present on recent kernels also, checked v4.16.0 and
> > v4.17.rc7
> > 
> > Disabling DCB for the card support fixes the problem ( Compiling kernel
> > with "CONFIG_CHELSIO_T4_DCB=n")
> > 
> > 
> > 
> > This is my first time reporting a bug to the linux kernel and hope I
> > have included the right amount of information. Please let me know if I
> > have missed something.
> > 
> > 
> > 
> > Thank you,
> > Zollner Robert
> > 
> > 
> > 
> > Logs:
> > 
> > VRF configured using folowing commands:
> > 
> > #!/bin/sh
> > 
> > CHDEV=ens1f4
> > VRF=vrf-recv
> > 
> > sysctl -w net.ipv4.tcp_l3mdev_accept=1
> > sysctl -w net.ipv4.udp_l3mdev_accept=1
> > sysctl -w net.ipv4.conf.all.accept_local=1
> > 
> > ifconfig ${CHDEV}   192.168.8.2/24
> > ifconfig ${CHDEV}d1 192.168.9.2/24
> > 
> > ip link add ${VRF} type vrf table 10
> > ip link set dev ${VRF} up
> > 
> > ip rule add pref 32765 table local
> > ip rule del pref 0
> > 
> > ip route add table 10 unreachable default metric 4278198272
> > 
> > ip link set dev ${CHDEV}d1 master ${VRF}
> > 
> > ip route add table 10 default via 192.168.9.1
> > ip route add 192.168.9.0/24 via 192.168.8.1
> > 
> > 
> > 
> > 
> 


[PATCH net-next] cxgb4: Add FORCE_PAUSE bit to 32 bit port caps

2018-05-30 Thread Ganesh Goudar
Add FORCE_PAUSE bit to force local pause settings instead
of using auto negotiated values.

Signed-off-by: Santosh Rastapur 
Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c| 10 +-
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h |  5 +++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 39da7e3..974a868 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -3941,6 +3941,7 @@ static fw_port_cap32_t fwcaps16_to_caps32(fw_port_cap16_t 
caps16)
CAP16_TO_CAP32(FC_RX);
CAP16_TO_CAP32(FC_TX);
CAP16_TO_CAP32(ANEG);
+   CAP16_TO_CAP32(FORCE_PAUSE);
CAP16_TO_CAP32(MDIAUTO);
CAP16_TO_CAP32(MDISTRAIGHT);
CAP16_TO_CAP32(FEC_RS);
@@ -3982,6 +3983,7 @@ static fw_port_cap16_t fwcaps32_to_caps16(fw_port_cap32_t 
caps32)
CAP32_TO_CAP16(802_3_PAUSE);
CAP32_TO_CAP16(802_3_ASM_DIR);
CAP32_TO_CAP16(ANEG);
+   CAP32_TO_CAP16(FORCE_PAUSE);
CAP32_TO_CAP16(MDIAUTO);
CAP32_TO_CAP16(MDISTRAIGHT);
CAP32_TO_CAP16(FEC_RS);
@@ -4014,6 +4016,8 @@ static inline fw_port_cap32_t cc_to_fwcap_pause(enum 
cc_pause cc_pause)
fw_pause |= FW_PORT_CAP32_FC_RX;
if (cc_pause & PAUSE_TX)
fw_pause |= FW_PORT_CAP32_FC_TX;
+   if (!(cc_pause & PAUSE_AUTONEG))
+   fw_pause |= FW_PORT_CAP32_FORCE_PAUSE;
 
return fw_pause;
 }
@@ -4101,7 +4105,11 @@ int t4_link_l1cfg_core(struct adapter *adapter, unsigned 
int mbox,
rcap = lc->acaps | fw_fc | fw_fec | fw_mdi;
}
 
-   if (rcap & ~lc->pcaps) {
+   /* Note that older Firmware doesn't have FW_PORT_CAP32_FORCE_PAUSE, so
+* we need to exclude this from this check in order to maintain
+* compatibility ...
+*/
+   if ((rcap & ~lc->pcaps) & ~FW_PORT_CAP32_FORCE_PAUSE) {
dev_err(adapter->pdev_dev,
"Requested Port Capabilities %#x exceed Physical Port 
Capabilities %#x\n",
rcap, lc->pcaps);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
index 2d91480..f1967cf 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
@@ -2475,7 +2475,7 @@ enum fw_port_cap {
FW_PORT_CAP_MDISTRAIGHT = 0x0400,
FW_PORT_CAP_FEC_RS  = 0x0800,
FW_PORT_CAP_FEC_BASER_RS= 0x1000,
-   FW_PORT_CAP_FEC_RESERVED= 0x2000,
+   FW_PORT_CAP_FORCE_PAUSE = 0x2000,
FW_PORT_CAP_802_3_PAUSE = 0x4000,
FW_PORT_CAP_802_3_ASM_DIR   = 0x8000,
 };
@@ -2522,7 +2522,8 @@ enum fw_port_mdi {
 #defineFW_PORT_CAP32_FEC_RESERVED1 0x0200UL
 #defineFW_PORT_CAP32_FEC_RESERVED2 0x0400UL
 #defineFW_PORT_CAP32_FEC_RESERVED3 0x0800UL
-#defineFW_PORT_CAP32_RESERVED2 0xf000UL
+#define FW_PORT_CAP32_FORCE_PAUSE  0x1000UL
+#define FW_PORT_CAP32_RESERVED20xe000UL
 
 #define FW_PORT_CAP32_SPEED_S  0
 #define FW_PORT_CAP32_SPEED_M  0xfff
-- 
2.1.0



[PATCH net-next] cxgb4/cxgb4vf: Notify link changes to OS-dependent code

2018-05-24 Thread Ganesh Goudar
From: Arjun Vynipadath 

We have a confusion of two different abstractions in the Common
Code:  Physical Link (Port) and Logical Network Interface (Virtual
Interface), and we haven't been properly managing the state of the
intersection of those two abstractions.
On the one hand we have the Physical state of the Link -- up or down --
and on the other we have the logical state of the VI, enabled or not.
{ethN} refers to both the Physical and Logical State. In this case,
ifconfig only affects/interrogates the Logical State of a VI,
and ethtool only deals with the Physical State. And these are different.

So, just because we disable the VI, we don't really want to change the
Physical Link Up/Down state.  Thus, the previous hack to set
"lc->link_ok = 0" when we disable a VI is completely incorrect.

Where we get into trouble is where the Physical Link State and the
Logical VI State cross swords.  And that happens in
t4_handle_get_port_info() where we need to manage/safe the Physical
Link State, but we also need to know when the Logical VI State has
changed and pass that back up to the OS-dependent Driver routine
t4_os_link_changed() which is concerned about the Logical Interface.

So we enable a VI and that causes Firmware to send us a new Port
Information message, but if none of the Physical Link State
particulars have changed, we don't call t4_os_link_changed().

This fix uses the existing OS Contract APIs for the Common Code to
inform the OS-dependent portion of the Host Driver when the "Link" (really
Logical Network Interface) is "up" or "down". A new API
t4_enable_pi_params() is added which calls t4_enable_vi_params() and,
if that is successful, then calls back to the OS Contract API
t4_os_link_changed() notifying the OS-dependent layer of the
potential Link State change.

Original Work by : Casey Leedom 

Signed-off-by: Santosh Rastapur 
Signed-off-by: Arjun Vynipadath 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |  3 +++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|  5 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 28 ++
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|  5 ++--
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h |  5 +++-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c | 24 +++
 6 files changed, 64 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 0f305d9..0dbe2d9 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -1738,6 +1738,9 @@ int t4_set_addr_hash(struct adapter *adap, unsigned int 
mbox, unsigned int viid,
 bool ucast, u64 vec, bool sleep_ok);
 int t4_enable_vi_params(struct adapter *adap, unsigned int mbox,
unsigned int viid, bool rx_en, bool tx_en, bool dcb_en);
+int t4_enable_pi_params(struct adapter *adap, unsigned int mbox,
+   struct port_info *pi,
+   bool rx_en, bool tx_en, bool dcb_en);
 int t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
 bool rx_en, bool tx_en);
 int t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int 
viid,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 513e1d3..666f11f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -465,7 +465,7 @@ static int link_start(struct net_device *dev)
&pi->link_cfg);
if (ret == 0) {
local_bh_disable();
-   ret = t4_enable_vi_params(pi->adapter, mb, pi->viid, true,
+   ret = t4_enable_pi_params(pi->adapter, mb, pi, true,
  true, CXGB4_DCB_ENABLED);
local_bh_enable();
}
@@ -2344,7 +2344,8 @@ static int cxgb_close(struct net_device *dev)
 
netif_tx_stop_all_queues(dev);
netif_carrier_off(dev);
-   ret = t4_enable_vi(adapter, adapter->pf, pi->viid, false, false);
+   ret = t4_enable_pi_params(adapter, adapter->pf, pi,
+ false, false, false);
 #ifdef CONFIG_CHELSIO_T4_DCB
cxgb4_dcb_reset(dev);
dcb_tx_queue_prio_enable(dev, false);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 704f696..bfe326f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -7998,6 +7998,34 @@ int t4_enable_vi(struct adapter *adap, unsigned int 
mbox, unsigned int viid,
 }
 
 /**
+ * t4_enable_pi_params - enable/disable a Port's Virtual Interface
+ *  @adap: the adapter
+ *  @mbox: mailbox to use for 

[PATCH net-next] cxgb4: clean up init_one

2018-05-24 Thread Ganesh Goudar
clean up init_one and use chip_ver consistently throughout
init_one() for chip version.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c   | 47 +--
 drivers/net/ethernet/chelsio/cxgb4/t4_chip_type.h |  2 +
 2 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 513e1d3..c1790785 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5236,14 +5236,11 @@ static void free_some_resources(struct adapter *adapter)
   NETIF_F_IPV6_CSUM | NETIF_F_HIGHDMA)
 #define SEGMENT_SIZE 128
 
-static int get_chip_type(struct pci_dev *pdev, u32 pl_rev)
+static int t4_get_chip_type(struct adapter *adap, int ver)
 {
-   u16 device_id;
-
-   /* Retrieve adapter's device ID */
-   pci_read_config_word(pdev, PCI_DEVICE_ID, &device_id);
+   u32 pl_rev = REV_G(t4_read_reg(adap, PL_REV_A));
 
-   switch (device_id >> 12) {
+   switch (ver) {
case CHELSIO_T4:
return CHELSIO_CHIP_CODE(CHELSIO_T4, pl_rev);
case CHELSIO_T5:
@@ -5251,8 +5248,7 @@ static int get_chip_type(struct pci_dev *pdev, u32 pl_rev)
case CHELSIO_T6:
return CHELSIO_CHIP_CODE(CHELSIO_T6, pl_rev);
default:
-   dev_err(&pdev->dev, "Device %d is not supported\n",
-   device_id);
+   break;
}
return -EINVAL;
 }
@@ -5422,15 +5418,18 @@ static int cxgb4_iov_configure(struct pci_dev *pdev, 
int num_vfs)
 
 static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-   int func, i, err, s_qpp, qpp, num_seg;
+   struct net_device *netdev;
+   struct adapter *adapter;
+   static int adap_idx = 1;
+   int s_qpp, qpp, num_seg;
struct port_info *pi;
bool highdma = false;
-   struct adapter *adapter = NULL;
-   struct net_device *netdev;
-   void __iomem *regs;
-   u32 whoami, pl_rev;
enum chip_type chip;
-   static int adap_idx = 1;
+   void __iomem *regs;
+   int func, chip_ver;
+   u16 device_id;
+   int i, err;
+   u32 whoami;
 
printk_once(KERN_INFO "%s - version %s\n", DRV_DESC, DRV_VERSION);
 
@@ -5466,11 +5465,17 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
goto out_free_adapter;
 
/* We control everything through one PF */
-   whoami = readl(regs + PL_WHOAMI_A);
-   pl_rev = REV_G(readl(regs + PL_REV_A));
-   chip = get_chip_type(pdev, pl_rev);
-   func = CHELSIO_CHIP_VERSION(chip) <= CHELSIO_T5 ?
-   SOURCEPF_G(whoami) : T6_SOURCEPF_G(whoami);
+   whoami = t4_read_reg(adapter, PL_WHOAMI_A);
+   pci_read_config_word(pdev, PCI_DEVICE_ID, &device_id);
+   chip = t4_get_chip_type(adapter, CHELSIO_PCI_ID_VER(device_id));
+   if (chip < 0) {
+   dev_err(&pdev->dev, "Device %d is not supported\n", device_id);
+   err = chip;
+   goto out_free_adapter;
+   }
+   chip_ver = CHELSIO_CHIP_VERSION(chip);
+   func = chip_ver <= CHELSIO_T5 ?
+  SOURCEPF_G(whoami) : T6_SOURCEPF_G(whoami);
 
adapter->pdev = pdev;
adapter->pdev_dev = &pdev->dev;
@@ -5636,7 +5641,7 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
NETIF_F_HW_TC;
 
-   if (CHELSIO_CHIP_VERSION(chip) > CHELSIO_T5) {
+   if (chip_ver > CHELSIO_T5) {
netdev->hw_enc_features |= NETIF_F_IP_CSUM |
   NETIF_F_IPV6_CSUM |
   NETIF_F_RXCSUM |
@@ -5716,7 +5721,7 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
dev_warn(&pdev->dev, "could not allocate MPS Encap entries, 
continuing\n");
 
 #if IS_ENABLED(CONFIG_IPV6)
-   if ((CHELSIO_CHIP_VERSION(adapter->params.chip) <= CHELSIO_T5) &&
+   if (chip_ver <= CHELSIO_T5 &&
(!(t4_read_reg(adapter, LE_DB_CONFIG_A) & ASLIPCOMPEN_F))) {
/* CLIP functionality is not present in hardware,
 * hence disable all offload features
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_chip_type.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4_chip_type.h
index 54b7181..721c775 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_chip_type.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_chip_type.h
@@ -34,6 +34,8 @@
 #ifndef __T4_CHIP_TYPE_H__
 #define __T4_CHIP_TYPE_H__
 
+#define CHELSIO_PCI_ID_VER(__D

[PATCH net-next v2] cxgb4/cxgb4vf: link management changes for new SFP

2018-05-24 Thread Ganesh Goudar
newer SFPs like SFP28 and QSFP28 Transceiver Modules present
several new possibilities which we haven't faced before. Fix the
assumptions in the code reflecting the more limited capabilities
of previous Transceiver Module systems

Original work by Casey Leedom 

Signed-off-by: Ganesh Goudar 
---
V2: Was not getting applied on net-next, respining on net-next
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 22 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 34 ++--
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c | 47 +-
 3 files changed, 85 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index 59d04d7..f7eef93 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -800,24 +800,20 @@ static int set_link_ksettings(struct net_device *dev,
if (base->duplex != DUPLEX_FULL)
return -EINVAL;
 
-   if (!(lc->pcaps & FW_PORT_CAP32_ANEG)) {
-   /* PHY offers a single speed.  See if that's what's
-* being requested.
-*/
-   if (base->autoneg == AUTONEG_DISABLE &&
-   (lc->pcaps & speed_to_fw_caps(base->speed)))
-   return 0;
-   return -EINVAL;
-   }
-
old_lc = *lc;
-   if (base->autoneg == AUTONEG_DISABLE) {
+   if (!(lc->pcaps & FW_PORT_CAP32_ANEG) ||
+   base->autoneg == AUTONEG_DISABLE) {
fw_caps = speed_to_fw_caps(base->speed);
 
-   if (!(lc->pcaps & fw_caps))
+   /* Must only specify a single speed which must be supported
+* as part of the Physical Port Capabilities.
+*/
+   if ((fw_caps & (fw_caps - 1)) != 0 ||
+   !(lc->pcaps & fw_caps))
return -EINVAL;
+
lc->speed_caps = fw_caps;
-   lc->acaps = 0;
+   lc->acaps = fw_caps;
} else {
fw_caps =
 lmm_to_fw_caps(link_ksettings->link_modes.advertising);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 704f696..962384c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -4066,6 +4066,7 @@ int t4_link_l1cfg_core(struct adapter *adapter, unsigned 
int mbox,
fw_port_cap32_t fw_fc, cc_fec, fw_fec, rcap;
struct fw_port_cmd cmd;
unsigned int fw_mdi;
+   int ret;
 
fw_mdi = (FW_PORT_CAP32_MDI_V(FW_PORT_CAP32_MDI_AUTO) & lc->pcaps);
/* Convert driver coding of Pause Frame Flow Control settings into the
@@ -4100,6 +4101,13 @@ int t4_link_l1cfg_core(struct adapter *adapter, unsigned 
int mbox,
rcap = lc->acaps | fw_fc | fw_fec | fw_mdi;
}
 
+   if (rcap & ~lc->pcaps) {
+   dev_err(adapter->pdev_dev,
+   "Requested Port Capabilities %#x exceed Physical Port 
Capabilities %#x\n",
+   rcap, lc->pcaps);
+   return -EINVAL;
+   }
+
/* And send that on to the Firmware ...
 */
memset(&cmd, 0, sizeof(cmd));
@@ -4110,13 +4118,21 @@ int t4_link_l1cfg_core(struct adapter *adapter, 
unsigned int mbox,
cpu_to_be32(FW_PORT_CMD_ACTION_V(fw_caps == FW_CAPS16
 ? FW_PORT_ACTION_L1_CFG
 : FW_PORT_ACTION_L1_CFG32) |
-   FW_LEN16(cmd));
+FW_LEN16(cmd));
if (fw_caps == FW_CAPS16)
cmd.u.l1cfg.rcap = cpu_to_be32(fwcaps32_to_caps16(rcap));
else
cmd.u.l1cfg32.rcap32 = cpu_to_be32(rcap);
-   return t4_wr_mbox_meat_timeout(adapter, mbox, &cmd, sizeof(cmd), NULL,
-  sleep_ok, timeout);
+
+   ret = t4_wr_mbox_meat_timeout(adapter, mbox, &cmd, sizeof(cmd), NULL,
+ sleep_ok, timeout);
+   if (ret) {
+   dev_err(adapter->pdev_dev,
+   "Requested Port Capabilities %#x rejected, error %d\n",
+   rcap, -ret);
+   return ret;
+   }
+   return ret;
 }
 
 /**
@@ -8395,7 +8411,9 @@ void t4_handle_get_port_info(struct port_info *pi, const 
__be64 *rpl)
lc->lpacaps = lpacaps;
lc->acaps = acaps & ADVERT_MASK;
 
-   if (lc->acaps & FW_PORT_CAP32_ANEG) {
+   if (!(lc->acaps & FW_PORT_CAP32_ANEG)) {
+ 

Re: [PATCH v6 0/5] PCI: Improve PCIe link status reporting

2018-05-24 Thread Ganesh Goudar
On Wednesday, May 05/23/18, 2018 at 16:46:51 -0500, Bjorn Helgaas wrote:
> [+to Davem]
> 
> On Thu, May 03, 2018 at 03:00:07PM -0500, Bjorn Helgaas wrote:
> > This is based on Tal's recent work to unify the approach for reporting PCIe
> > link speed/width and whether the device is being limited by a slower
> > upstream link.
> > 
> > The new pcie_print_link_status() interface appeared in v4.17-rc1; see
> > 9e506a7b5147 ("PCI: Add pcie_print_link_status() to log link speed and
> > whether it's limited").
> > 
> > That's a good way to replace use of pcie_get_minimum_link(), which gives
> > misleading results when a path contains both a fast, narrow link and a
> > slow, wide link: it reports the equivalent of a slow, narrow link.
> > 
> > This series removes the remaining uses of pcie_get_minimum_link() and then
> > removes the interface itself.  I'd like to merge them all through the PCI
> > tree to make the removal easy.
> > 
> > This does change the dmesg reporting of link speeds, and in the ixgbe case,
> > it changes the reporting from KERN_WARN level to KERN_INFO.  If that's an
> > issue, let's talk about it.  I'm hoping the reduce code size, improved
> > functionality, and consistency across drivers is enough to make this
> > worthwhile.
> > 
> > ---
> > 
> > Bjorn Helgaas (5):
> >   bnx2x: Report PCIe link properties with pcie_print_link_status()
> >   bnxt_en: Report PCIe link properties with pcie_print_link_status()
> >   cxgb4: Report PCIe link properties with pcie_print_link_status()
> >   ixgbe: Report PCIe link properties with pcie_print_link_status()
> >   PCI: Remove unused pcie_get_minimum_link()
> > 
> > 
> >  drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |   23 ++-
> >  drivers/net/ethernet/broadcom/bnxt/bnxt.c|   19 --
> >  drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c  |   75 
> > --
> >  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c|   47 --
> >  drivers/pci/pci.c|   43 -
> >  include/linux/pci.h  |2 -
> >  6 files changed, 9 insertions(+), 200 deletions(-)
> 
> I applied all of these on pci/enumeration for v4.18.  If you'd rather take
> them, Dave, let me know and I'll drop them.
> 
> I solicited more acks, but only heard from Jeff.
Sorry for that, Thanks for cxgb4 changes.


[PATCH net-next 2/2] cxgb4: do L1 config when module is inserted

2018-05-23 Thread Ganesh Goudar
trigger an L1 configure operation when a transceiver module
is inserted in order to cause current "sticky" options like
Requested Forward Error Correction to be reapplied.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  | 26 ++--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 11 +--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c  | 40 +
 3 files changed, 65 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 211086b..0f305d9 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -491,6 +491,9 @@ struct link_config {
 
unsigned char  link_ok;  /* link up? */
unsigned char  link_down_rc; /* link down reason */
+
+   bool new_module; /* ->OS Transceiver Module inserted */
+   bool redo_l1cfg; /* ->CC redo current "sticky" L1 CFG */
 };
 
 #define FW_LEN16(fw_struct) FW_CMD_LEN16_V(sizeof(fw_struct) / 16)
@@ -1324,7 +1327,7 @@ static inline unsigned int qtimer_val(const struct 
adapter *adap,
 extern char cxgb4_driver_name[];
 extern const char cxgb4_driver_version[];
 
-void t4_os_portmod_changed(const struct adapter *adap, int port_id);
+void t4_os_portmod_changed(struct adapter *adap, int port_id);
 void t4_os_link_changed(struct adapter *adap, int port_id, int link_stat);
 
 void t4_free_sge_resources(struct adapter *adap);
@@ -1505,8 +1508,25 @@ void t4_intr_disable(struct adapter *adapter);
 int t4_slow_intr_handler(struct adapter *adapter);
 
 int t4_wait_dev_ready(void __iomem *regs);
-int t4_link_l1cfg(struct adapter *adap, unsigned int mbox, unsigned int port,
- struct link_config *lc);
+
+int t4_link_l1cfg_core(struct adapter *adap, unsigned int mbox,
+  unsigned int port, struct link_config *lc,
+  bool sleep_ok, int timeout);
+
+static inline int t4_link_l1cfg(struct adapter *adapter, unsigned int mbox,
+   unsigned int port, struct link_config *lc)
+{
+   return t4_link_l1cfg_core(adapter, mbox, port, lc,
+ true, FW_CMD_MAX_TIMEOUT);
+}
+
+static inline int t4_link_l1cfg_ns(struct adapter *adapter, unsigned int mbox,
+  unsigned int port, struct link_config *lc)
+{
+   return t4_link_l1cfg_core(adapter, mbox, port, lc,
+ false, FW_CMD_MAX_TIMEOUT);
+}
+
 int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int 
port);
 
 u32 t4_read_pcie_cfg4(struct adapter *adap, int reg);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 130d1ee..513e1d3 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -301,14 +301,14 @@ void t4_os_link_changed(struct adapter *adapter, int 
port_id, int link_stat)
}
 }
 
-void t4_os_portmod_changed(const struct adapter *adap, int port_id)
+void t4_os_portmod_changed(struct adapter *adap, int port_id)
 {
static const char *mod_str[] = {
NULL, "LR", "SR", "ER", "passive DA", "active DA", "LRM"
};
 
-   const struct net_device *dev = adap->port[port_id];
-   const struct port_info *pi = netdev_priv(dev);
+   struct net_device *dev = adap->port[port_id];
+   struct port_info *pi = netdev_priv(dev);
 
if (pi->mod_type == FW_PORT_MOD_TYPE_NONE)
netdev_info(dev, "port module unplugged\n");
@@ -325,6 +325,11 @@ void t4_os_portmod_changed(const struct adapter *adap, int 
port_id)
else
netdev_info(dev, "%s: unknown module type %d inserted\n",
dev->name, pi->mod_type);
+
+   /* If the interface is running, then we'll need any "sticky" Link
+* Parameters redone with a new Transceiver Module.
+*/
+   pi->link_cfg.redo_l1cfg = netif_running(dev);
 }
 
 int dbfifo_int_thresh = 10; /* 10 == 640 entry threshold */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 537ed07..704f696 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -4058,14 +4058,16 @@ static inline fw_port_cap32_t cc_to_fwcap_fec(enum 
cc_fec cc_fec)
  * - If auto-negotiation is off set the MAC to the proper speed/duplex/FC,
  *   otherwise do it later based on the outcome of auto-negotiation.
  */
-int t4_link_l1cfg(struct adapter *adapter, unsigned int mbox,
- unsigned int port, struct link_config *lc)
+int t4_link_l1cfg_core(struct adapter *adap

[PATCH net-next 1/2] cxgb4: change the port capability bits definition

2018-05-23 Thread Ganesh Goudar
MDI Port Capabilities bit definitions were inconsistent with
regard to the MDI enum values. 2 bits used to define MDI in
the port capabilities are not really separable, it's a 2-bit
field with 4 different values. Change the port capability bit
definitions to be "AUTO" and "STRAIGHT" in order to get them
to line up with the enum's.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 4 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  | 8 
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c | 2 +-
 drivers/scsi/csiostor/csio_hw.c| 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index df5e7c7..537ed07 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -3941,8 +3941,8 @@ static fw_port_cap32_t fwcaps16_to_caps32(fw_port_cap16_t 
caps16)
CAP16_TO_CAP32(FC_RX);
CAP16_TO_CAP32(FC_TX);
CAP16_TO_CAP32(ANEG);
-   CAP16_TO_CAP32(MDIX);
CAP16_TO_CAP32(MDIAUTO);
+   CAP16_TO_CAP32(MDISTRAIGHT);
CAP16_TO_CAP32(FEC_RS);
CAP16_TO_CAP32(FEC_BASER_RS);
CAP16_TO_CAP32(802_3_PAUSE);
@@ -3982,8 +3982,8 @@ static fw_port_cap16_t fwcaps32_to_caps16(fw_port_cap32_t 
caps32)
CAP32_TO_CAP16(802_3_PAUSE);
CAP32_TO_CAP16(802_3_ASM_DIR);
CAP32_TO_CAP16(ANEG);
-   CAP32_TO_CAP16(MDIX);
CAP32_TO_CAP16(MDIAUTO);
+   CAP32_TO_CAP16(MDISTRAIGHT);
CAP32_TO_CAP16(FEC_RS);
CAP32_TO_CAP16(FEC_BASER_RS);
 
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
index e6b2e95..2d91480 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
@@ -2471,8 +2471,8 @@ enum fw_port_cap {
FW_PORT_CAP_FC_RX   = 0x0040,
FW_PORT_CAP_FC_TX   = 0x0080,
FW_PORT_CAP_ANEG= 0x0100,
-   FW_PORT_CAP_MDIX= 0x0200,
-   FW_PORT_CAP_MDIAUTO = 0x0400,
+   FW_PORT_CAP_MDIAUTO = 0x0200,
+   FW_PORT_CAP_MDISTRAIGHT = 0x0400,
FW_PORT_CAP_FEC_RS  = 0x0800,
FW_PORT_CAP_FEC_BASER_RS= 0x1000,
FW_PORT_CAP_FEC_RESERVED= 0x2000,
@@ -2515,8 +2515,8 @@ enum fw_port_mdi {
 #defineFW_PORT_CAP32_802_3_PAUSE   0x0004UL
 #defineFW_PORT_CAP32_802_3_ASM_DIR 0x0008UL
 #defineFW_PORT_CAP32_ANEG  0x0010UL
-#defineFW_PORT_CAP32_MDIX  0x0020UL
-#defineFW_PORT_CAP32_MDIAUTO   0x0040UL
+#defineFW_PORT_CAP32_MDIAUTO   0x0020UL
+#defineFW_PORT_CAP32_MDISTRAIGHT   0x0040UL
 #defineFW_PORT_CAP32_FEC_RS0x0080UL
 #defineFW_PORT_CAP32_FEC_BASER_RS  0x0100UL
 #defineFW_PORT_CAP32_FEC_RESERVED1 0x0200UL
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
index 798695b..3017f78 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
@@ -341,8 +341,8 @@ static fw_port_cap32_t fwcaps16_to_caps32(fw_port_cap16_t 
caps16)
CAP16_TO_CAP32(FC_RX);
CAP16_TO_CAP32(FC_TX);
CAP16_TO_CAP32(ANEG);
-   CAP16_TO_CAP32(MDIX);
CAP16_TO_CAP32(MDIAUTO);
+   CAP16_TO_CAP32(MDISTRAIGHT);
CAP16_TO_CAP32(FEC_RS);
CAP16_TO_CAP32(FEC_BASER_RS);
CAP16_TO_CAP32(802_3_PAUSE);
diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c
index 96bbb82..a10cf25 100644
--- a/drivers/scsi/csiostor/csio_hw.c
+++ b/drivers/scsi/csiostor/csio_hw.c
@@ -1500,8 +1500,8 @@ fw_port_cap32_t fwcaps16_to_caps32(fw_port_cap16_t caps16)
CAP16_TO_CAP32(FC_RX);
CAP16_TO_CAP32(FC_TX);
CAP16_TO_CAP32(ANEG);
-   CAP16_TO_CAP32(MDIX);
CAP16_TO_CAP32(MDIAUTO);
+   CAP16_TO_CAP32(MDISTRAIGHT);
CAP16_TO_CAP32(FEC_RS);
CAP16_TO_CAP32(FEC_BASER_RS);
CAP16_TO_CAP32(802_3_PAUSE);
-- 
2.1.0



[PATCH net-next] cxgb4: Add new T6 device ids

2018-05-22 Thread Ganesh Goudar
Add 0x6088 and 0x6089 device ids for new T6 cards.

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
index adacc63..c7f8d04 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
@@ -212,6 +212,8 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
CH_PCI_ID_TABLE_FENTRY(0x6085), /* Custom T6240-SO */
CH_PCI_ID_TABLE_FENTRY(0x6086), /* Custom T6225-SO-CR */
CH_PCI_ID_TABLE_FENTRY(0x6087), /* Custom T6225-CR */
+   CH_PCI_ID_TABLE_FENTRY(0x6088), /* Custom T62100-CR */
+   CH_PCI_ID_TABLE_FENTRY(0x6089), /* Custom T62100-KR */
 CH_PCI_DEVICE_ID_TABLE_DEFINE_END;
 
 #endif /* __T4_PCI_ID_TBL_H__ */
-- 
2.1.0



[PATCH net-next] cxgb4: do L1 config when module is inserted

2018-05-21 Thread Ganesh Goudar
trigger an L1 configure operation when a transceiver module
is inserted in order to cause current "sticky" options like
Requested Forward Error Correction to be reapplied.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  | 26 +--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 11 +--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c  | 44 -
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h   |  8 ++---
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c  |  2 +-
 5 files changed, 72 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 211086b..442b35c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -491,6 +491,9 @@ struct link_config {
 
unsigned char  link_ok;  /* link up? */
unsigned char  link_down_rc; /* link down reason */
+
+   unsigned char   new_module;  /* ->OS Transceiver Module inserted */
+   unsigned char   redo_l1cfg;  /* ->CC redo current "sticky" L1 CFG */
 };
 
 #define FW_LEN16(fw_struct) FW_CMD_LEN16_V(sizeof(fw_struct) / 16)
@@ -1324,7 +1327,7 @@ static inline unsigned int qtimer_val(const struct 
adapter *adap,
 extern char cxgb4_driver_name[];
 extern const char cxgb4_driver_version[];
 
-void t4_os_portmod_changed(const struct adapter *adap, int port_id);
+void t4_os_portmod_changed(struct adapter *adap, int port_id);
 void t4_os_link_changed(struct adapter *adap, int port_id, int link_stat);
 
 void t4_free_sge_resources(struct adapter *adap);
@@ -1505,8 +1508,25 @@ void t4_intr_disable(struct adapter *adapter);
 int t4_slow_intr_handler(struct adapter *adapter);
 
 int t4_wait_dev_ready(void __iomem *regs);
-int t4_link_l1cfg(struct adapter *adap, unsigned int mbox, unsigned int port,
- struct link_config *lc);
+
+int t4_link_l1cfg_core(struct adapter *adap, unsigned int mbox,
+  unsigned int port, struct link_config *lc,
+  bool sleep_ok, int timeout);
+
+static inline int t4_link_l1cfg(struct adapter *adapter, unsigned int mbox,
+   unsigned int port, struct link_config *lc)
+{
+   return t4_link_l1cfg_core(adapter, mbox, port, lc,
+ true, FW_CMD_MAX_TIMEOUT);
+}
+
+static inline int t4_link_l1cfg_ns(struct adapter *adapter, unsigned int mbox,
+  unsigned int port, struct link_config *lc)
+{
+   return t4_link_l1cfg_core(adapter, mbox, port, lc,
+ false, FW_CMD_MAX_TIMEOUT);
+}
+
 int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int 
port);
 
 u32 t4_read_pcie_cfg4(struct adapter *adap, int reg);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 130d1ee..513e1d3 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -301,14 +301,14 @@ void t4_os_link_changed(struct adapter *adapter, int 
port_id, int link_stat)
}
 }
 
-void t4_os_portmod_changed(const struct adapter *adap, int port_id)
+void t4_os_portmod_changed(struct adapter *adap, int port_id)
 {
static const char *mod_str[] = {
NULL, "LR", "SR", "ER", "passive DA", "active DA", "LRM"
};
 
-   const struct net_device *dev = adap->port[port_id];
-   const struct port_info *pi = netdev_priv(dev);
+   struct net_device *dev = adap->port[port_id];
+   struct port_info *pi = netdev_priv(dev);
 
if (pi->mod_type == FW_PORT_MOD_TYPE_NONE)
netdev_info(dev, "port module unplugged\n");
@@ -325,6 +325,11 @@ void t4_os_portmod_changed(const struct adapter *adap, int 
port_id)
else
netdev_info(dev, "%s: unknown module type %d inserted\n",
dev->name, pi->mod_type);
+
+   /* If the interface is running, then we'll need any "sticky" Link
+* Parameters redone with a new Transceiver Module.
+*/
+   pi->link_cfg.redo_l1cfg = netif_running(dev);
 }
 
 int dbfifo_int_thresh = 10; /* 10 == 640 entry threshold */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index df5e7c7..cc6e576 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -3941,8 +3941,8 @@ static fw_port_cap32_t fwcaps16_to_caps32(fw_port_cap16_t 
caps16)
CAP16_TO_CAP32(FC_RX);
CAP16_TO_CAP32(FC_TX);
CAP16_TO_CAP32(ANEG);
-   CAP16_TO_CAP32(MDIX);
CAP16_TO_CAP32(MDIAUTO);
+   CAP16_TO_CAP32(MDISTRAIGHT);
CAP1

[PATCH net-next] cxgb4/cxgb4vf: link management changes for new SFP

2018-05-21 Thread Ganesh Goudar
newer SFPs like SFP28 and QSFP28 Transceiver Modules present
several new possibilities which we haven't faced before. Fix the
assumptions in the code reflecting the more limited capabilities
of previous Transceiver Module systems

Original work by Casey Leedom 

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 22 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 34 ++--
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c | 47 +-
 3 files changed, 85 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index 59d04d7..f7eef93 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -800,24 +800,20 @@ static int set_link_ksettings(struct net_device *dev,
if (base->duplex != DUPLEX_FULL)
return -EINVAL;
 
-   if (!(lc->pcaps & FW_PORT_CAP32_ANEG)) {
-   /* PHY offers a single speed.  See if that's what's
-* being requested.
-*/
-   if (base->autoneg == AUTONEG_DISABLE &&
-   (lc->pcaps & speed_to_fw_caps(base->speed)))
-   return 0;
-   return -EINVAL;
-   }
-
old_lc = *lc;
-   if (base->autoneg == AUTONEG_DISABLE) {
+   if (!(lc->pcaps & FW_PORT_CAP32_ANEG) ||
+   base->autoneg == AUTONEG_DISABLE) {
fw_caps = speed_to_fw_caps(base->speed);
 
-   if (!(lc->pcaps & fw_caps))
+   /* Must only specify a single speed which must be supported
+* as part of the Physical Port Capabilities.
+*/
+   if ((fw_caps & (fw_caps - 1)) != 0 ||
+   !(lc->pcaps & fw_caps))
return -EINVAL;
+
lc->speed_caps = fw_caps;
-   lc->acaps = 0;
+   lc->acaps = fw_caps;
} else {
fw_caps =
 lmm_to_fw_caps(link_ksettings->link_modes.advertising);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index cc6e576..6ac4f56 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -4066,6 +4066,7 @@ int t4_link_l1cfg_core(struct adapter *adapter, unsigned 
int mbox,
fw_port_cap32_t fw_fc, cc_fec, fw_fec, rcap;
struct fw_port_cmd cmd;
unsigned int fw_mdi;
+   int ret;
 
fw_mdi = (FW_PORT_CAP32_MDI_V(FW_PORT_CAP32_MDI_AUTO) & lc->pcaps);
/* Convert driver coding of Pause Frame Flow Control settings into the
@@ -4100,6 +4101,13 @@ int t4_link_l1cfg_core(struct adapter *adapter, unsigned 
int mbox,
rcap = lc->acaps | fw_fc | fw_fec | fw_mdi;
}
 
+   if (rcap & ~lc->pcaps) {
+   dev_err(adapter->pdev_dev,
+   "Requested Port Capabilities %#x exceed Physical Port 
Capabilities %#x\n",
+   rcap, lc->pcaps);
+   return -EINVAL;
+   }
+
/* And send that on to the Firmware ...
 */
memset(&cmd, 0, sizeof(cmd));
@@ -4110,13 +4118,21 @@ int t4_link_l1cfg_core(struct adapter *adapter, 
unsigned int mbox,
cpu_to_be32(FW_PORT_CMD_ACTION_V(fw_caps == FW_CAPS16
 ? FW_PORT_ACTION_L1_CFG
 : FW_PORT_ACTION_L1_CFG32) |
-   FW_LEN16(cmd));
+FW_LEN16(cmd));
if (fw_caps == FW_CAPS16)
cmd.u.l1cfg.rcap = cpu_to_be32(fwcaps32_to_caps16(rcap));
else
cmd.u.l1cfg32.rcap32 = cpu_to_be32(rcap);
-   return t4_wr_mbox_meat_timeout(adapter, mbox, &cmd, sizeof(cmd), NULL,
-  sleep_ok, timeout);
+
+   ret = t4_wr_mbox_meat_timeout(adapter, mbox, &cmd, sizeof(cmd), NULL,
+ sleep_ok, timeout);
+   if (ret) {
+   dev_err(adapter->pdev_dev,
+   "Requested Port Capabilities %#x rejected, error %d\n",
+   rcap, -ret);
+   return ret;
+   }
+   return ret;
 }
 
 /**
@@ -8395,7 +8411,9 @@ void t4_handle_get_port_info(struct port_info *pi, const 
__be64 *rpl)
lc->lpacaps = lpacaps;
lc->acaps = acaps & ADVERT_MASK;
 
-   if (lc->acaps & FW_PORT_CAP32_ANEG) {
+   if (!(lc->acaps & FW_PORT_CAP32_ANEG)) {
+   lc->autoneg = AUTONEG_DISABLE;
+   } else if (lc->acaps & FW_PORT

[PACTH net-next] cxgb4: copy the length of cpl_tx_pkt_core to fw_wr

2018-05-20 Thread Ganesh Goudar
immdlen field of FW_ETH_TX_PKT_WR is filled in a wrong way,
we must copy the length of all the cpls encapsulated in fw
work request. In the xmit path we missed adding the length
of CPL_TX_PKT_CORE but we added the length of WR_HDR and it
worked because WR_HDR and CPL_TX_PKT_CORE are of same length.
Add the length of cpl_tx_pkt_core not WR_HDR's. This also
fixes the lso cpl errors for udp tunnels

Fixes: d0a1299c6bf7 ("cxgb4: add support for vxlan segmentation offload")
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/sge.c | 29 ++---
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 0f87e97..276f223 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -1411,8 +1411,9 @@ out_free: dev_kfree_skb_any(skb);
end = (u64 *)wr + flits;
 
len = immediate ? skb->len : 0;
+   len += sizeof(*cpl);
if (ssi->gso_size) {
-   struct cpl_tx_pkt_lso *lso = (void *)wr;
+   struct cpl_tx_pkt_lso_core *lso = (void *)(wr + 1);
bool v6 = (ssi->gso_type & SKB_GSO_TCPV6) != 0;
int l3hdr_len = skb_network_header_len(skb);
int eth_xtra_len = skb_network_offset(skb) - ETH_HLEN;
@@ -1442,20 +1443,19 @@ out_free:   dev_kfree_skb_any(skb);
if (skb->ip_summed == CHECKSUM_PARTIAL)
cntrl = hwcsum(adap->params.chip, skb);
} else {
-   lso->c.lso_ctrl = htonl(LSO_OPCODE_V(CPL_TX_PKT_LSO) |
- LSO_FIRST_SLICE_F | LSO_LAST_SLICE_F |
- LSO_IPV6_V(v6) |
- LSO_ETHHDR_LEN_V(eth_xtra_len / 4) |
- LSO_IPHDR_LEN_V(l3hdr_len / 4) |
- LSO_TCPHDR_LEN_V(tcp_hdr(skb)->doff));
-   lso->c.ipid_ofst = htons(0);
-   lso->c.mss = htons(ssi->gso_size);
-   lso->c.seqno_offset = htonl(0);
+   lso->lso_ctrl = htonl(LSO_OPCODE_V(CPL_TX_PKT_LSO) |
+   LSO_FIRST_SLICE_F | LSO_LAST_SLICE_F |
+   LSO_IPV6_V(v6) |
+   LSO_ETHHDR_LEN_V(eth_xtra_len / 4) |
+   LSO_IPHDR_LEN_V(l3hdr_len / 4) |
+   LSO_TCPHDR_LEN_V(tcp_hdr(skb)->doff));
+   lso->ipid_ofst = htons(0);
+   lso->mss = htons(ssi->gso_size);
+   lso->seqno_offset = htonl(0);
if (is_t4(adap->params.chip))
-   lso->c.len = htonl(skb->len);
+   lso->len = htonl(skb->len);
else
-   lso->c.len =
-   htonl(LSO_T5_XFER_SIZE_V(skb->len));
+   lso->len = htonl(LSO_T5_XFER_SIZE_V(skb->len));
cpl = (void *)(lso + 1);
 
if (CHELSIO_CHIP_VERSION(adap->params.chip)
@@ -1484,7 +1484,6 @@ out_free: dev_kfree_skb_any(skb);
q->tso++;
q->tx_cso += ssi->gso_segs;
} else {
-   len += sizeof(*cpl);
if (ptp_enabled)
op = FW_PTP_TX_PKT_WR;
else
@@ -1538,7 +1537,7 @@ out_free: dev_kfree_skb_any(skb);
if (last_desc >= q->q.size)
last_desc -= q->q.size;
q->q.sdesc[last_desc].skb = skb;
-   q->q.sdesc[last_desc].sgl = (struct ulptx_sgl *)(cpl + 1);
+   q->q.sdesc[last_desc].sgl = (struct ulptx_sgl *)sgl;
}
 
txq_advance(&q->q, ndesc);
-- 
2.1.0



[PATCH net-next V2 2/2] cxgb4: Support ethtool private flags

2018-05-16 Thread Ganesh Goudar
From: Arjun Vynipadath 

This is used to change TX workrequests, which helps in
host->vf communication.

Signed-off-by: Arjun Vynipadath 
Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
V2: no v2 changes in this patch
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index 59d04d7..1d979a6 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -177,6 +177,10 @@ static char loopback_stats_strings[][ETH_GSTRING_LEN] = {
"bg3_frames_trunc   ",
 };
 
+static const char cxgb4_priv_flags_strings[][ETH_GSTRING_LEN] = {
+   [PRIV_FLAG_PORT_TX_VM_BIT] = "port_tx_vm_wr",
+};
+
 static int get_sset_count(struct net_device *dev, int sset)
 {
switch (sset) {
@@ -185,6 +189,8 @@ static int get_sset_count(struct net_device *dev, int sset)
   ARRAY_SIZE(adapter_stats_strings) +
   ARRAY_SIZE(channel_stats_strings) +
   ARRAY_SIZE(loopback_stats_strings);
+   case ETH_SS_PRIV_FLAGS:
+   return ARRAY_SIZE(cxgb4_priv_flags_strings);
default:
return -EOPNOTSUPP;
}
@@ -235,6 +241,7 @@ static void get_drvinfo(struct net_device *dev, struct 
ethtool_drvinfo *info)
 FW_HDR_FW_VER_MINOR_G(exprom_vers),
 FW_HDR_FW_VER_MICRO_G(exprom_vers),
 FW_HDR_FW_VER_BUILD_G(exprom_vers));
+   info->n_priv_flags = ARRAY_SIZE(cxgb4_priv_flags_strings);
 }
 
 static void get_strings(struct net_device *dev, u32 stringset, u8 *data)
@@ -250,6 +257,9 @@ static void get_strings(struct net_device *dev, u32 
stringset, u8 *data)
data += sizeof(channel_stats_strings);
memcpy(data, loopback_stats_strings,
   sizeof(loopback_stats_strings));
+   } else if (stringset == ETH_SS_PRIV_FLAGS) {
+   memcpy(data, cxgb4_priv_flags_strings,
+  sizeof(cxgb4_priv_flags_strings));
}
 }
 
@@ -1503,6 +1513,36 @@ static int cxgb4_get_module_eeprom(struct net_device 
*dev,
 offset, len, &data[eprom->len - len]);
 }
 
+static u32 cxgb4_get_priv_flags(struct net_device *netdev)
+{
+   struct port_info *pi = netdev_priv(netdev);
+   struct adapter *adapter = pi->adapter;
+
+   return (adapter->eth_flags | pi->eth_flags);
+}
+
+/**
+ * set_flags - set/unset specified flags if passed in new_flags
+ * @cur_flags: pointer to current flags
+ * @new_flags: new incoming flags
+ * @flags: set of flags to set/unset
+ */
+static inline void set_flags(u32 *cur_flags, u32 new_flags, u32 flags)
+{
+   *cur_flags = (*cur_flags & ~flags) | (new_flags & flags);
+}
+
+static int cxgb4_set_priv_flags(struct net_device *netdev, u32 flags)
+{
+   struct port_info *pi = netdev_priv(netdev);
+   struct adapter *adapter = pi->adapter;
+
+   set_flags(&adapter->eth_flags, flags, PRIV_FLAGS_ADAP);
+   set_flags(&pi->eth_flags, flags, PRIV_FLAGS_PORT);
+
+   return 0;
+}
+
 static const struct ethtool_ops cxgb_ethtool_ops = {
.get_link_ksettings = get_link_ksettings,
.set_link_ksettings = set_link_ksettings,
@@ -1539,6 +1579,8 @@ static const struct ethtool_ops cxgb_ethtool_ops = {
.get_dump_data = get_dump_data,
.get_module_info   = cxgb4_get_module_info,
.get_module_eeprom = cxgb4_get_module_eeprom,
+   .get_priv_flags= cxgb4_get_priv_flags,
+   .set_priv_flags= cxgb4_set_priv_flags,
 };
 
 void cxgb4_set_ethtool_ops(struct net_device *netdev)
-- 
2.1.0



[PATCH net-next V2 1/2] cxgb4: Add support for FW_ETH_TX_PKT_VM_WR

2018-05-16 Thread Ganesh Goudar
From: Arjun Vynipadath 

The present TX workrequest(FW_ETH_TX_PKT_WR) cant be used for
host->vf communication, since it doesn't loopback the outgoing
packets to virtual interfaces on the same port. This can be done using
FW_ETH_TX_PKT_VM_WR.
This fix depends on ethtool_flags to determine what WR to use for
TX path. Support for setting this flags by user is added in next commit.

Based on the original work by : Casey Leedom 

Signed-off-by: Casey Leedom 
Signed-off-by: Arjun Vynipadath 
Signed-off-by: Ganesh Goudar 
---
V2: rename t4_eth_xmit() and t4vf_eth_xmit() to fix build error
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |  13 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   2 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c| 372 +++-
 3 files changed, 383 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 211086b..e7dd49d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -518,6 +518,15 @@ enum {
MAX_INGQ = MAX_ETH_QSETS + INGQ_EXTRAS,
 };
 
+enum {
+   PRIV_FLAG_PORT_TX_VM_BIT,
+};
+
+#define PRIV_FLAG_PORT_TX_VM   BIT(PRIV_FLAG_PORT_TX_VM_BIT)
+
+#define PRIV_FLAGS_ADAP0
+#define PRIV_FLAGS_PORTPRIV_FLAG_PORT_TX_VM
+
 struct adapter;
 struct sge_rspq;
 
@@ -554,6 +563,7 @@ struct port_info {
struct hwtstamp_config tstamp_config;
bool ptp_enable;
struct sched_table *sched_tbl;
+   u32 eth_flags;
 };
 
 struct dentry;
@@ -864,6 +874,7 @@ struct adapter {
unsigned int flags;
unsigned int adap_idx;
enum chip_type chip;
+   unsigned int eth_flags;
 
int msg_enable;
__be16 vxlan_port;
@@ -1330,7 +1341,7 @@ void t4_os_link_changed(struct adapter *adap, int 
port_id, int link_stat);
 void t4_free_sge_resources(struct adapter *adap);
 void t4_free_ofld_rxqs(struct adapter *adap, int n, struct sge_ofld_rxq *q);
 irq_handler_t t4_intr_handler(struct adapter *adap);
-netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev);
+netdev_tx_t t4_start_xmit(struct sk_buff *skb, struct net_device *dev);
 int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
 const struct pkt_gl *gl);
 int t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 130d1ee..2942b30 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3211,7 +3211,7 @@ static netdev_features_t cxgb_fix_features(struct 
net_device *dev,
 static const struct net_device_ops cxgb4_netdev_ops = {
.ndo_open = cxgb_open,
.ndo_stop = cxgb_close,
-   .ndo_start_xmit   = t4_eth_xmit,
+   .ndo_start_xmit   = t4_start_xmit,
.ndo_select_queue = cxgb_select_queue,
.ndo_get_stats64  = cxgb_get_stats,
.ndo_set_rx_mode  = cxgb_set_rxmode,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 0f87e97..ede1ebc 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -1289,13 +1289,13 @@ static inline void t6_fill_tnl_lso(struct sk_buff *skb,
 }
 
 /**
- * t4_eth_xmit - add a packet to an Ethernet Tx queue
+ * cxgb4_eth_xmit - add a packet to an Ethernet Tx queue
  * @skb: the packet
  * @dev: the egress net device
  *
  * Add a packet to an SGE Ethernet Tx queue.  Runs with softirqs disabled.
  */
-netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t cxgb4_eth_xmit(struct sk_buff *skb, struct net_device *dev)
 {
u32 wr_mid, ctrl0, op;
u64 cntrl, *end, *sgl;
@@ -1549,6 +1549,374 @@ out_free:   dev_kfree_skb_any(skb);
return NETDEV_TX_OK;
 }
 
+/* Constants ... */
+enum {
+   /* Egress Queue sizes, producer and consumer indices are all in units
+* of Egress Context Units bytes.  Note that as far as the hardware is
+* concerned, the free list is an Egress Queue (the host produces free
+* buffers which the hardware consumes) and free list entries are
+* 64-bit PCI DMA addresses.
+*/
+   EQ_UNIT = SGE_EQ_IDXSIZE,
+   FL_PER_EQ_UNIT = EQ_UNIT / sizeof(__be64),
+   TXD_PER_EQ_UNIT = EQ_UNIT / sizeof(__be64),
+
+   T4VF_ETHTXQ_MAX_HDR = (sizeof(struct fw_eth_tx_pkt_vm_wr) +
+  sizeof(struct cpl_tx_pkt_lso_core) +
+  sizeof(struct cpl_tx_pkt_core)) / sizeof(__be64),
+};
+
+/**
+ * t4vf_is_eth_imm - can an Ethernet packet be sent as immediate data?
+ * @skb: the packet
+ *
+ * Returns whether an Ethernet packet is small enough to fit compl

[PATCH net-next] cxgb4: add tc flower match support for tunnel VNI

2018-05-14 Thread Ganesh Goudar
From: Kumar Sanghvi 

Adds support for matching flows based on tunnel VNI value.
Introduces fw APIs for allocating/removing MPS entries related
to encapsulation. And uses the same while adding/deleting filters
for offloading flows based on tunnel VNI match.

Signed-off-by: Kumar Sanghvi 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |  9 +++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c  | 91 --
 .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c   | 18 +
 drivers/net/ethernet/chelsio/cxgb4/l2t.c   |  2 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 86 
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h   |  4 +
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  | 34 
 7 files changed, 237 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index d2a..ce47daf 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -1045,6 +1045,7 @@ struct ch_sched_queue {
 #define VF_BITWIDTH 8
 #define IVLAN_BITWIDTH 16
 #define OVLAN_BITWIDTH 16
+#define ENCAP_VNI_BITWIDTH 24
 
 /* Filter matching rules.  These consist of a set of ingress packet field
  * (value, mask) tuples.  The associated ingress packet field matches the
@@ -1075,6 +1076,7 @@ struct ch_filter_tuple {
uint32_t ivlan_vld:1;   /* inner VLAN valid */
uint32_t ovlan_vld:1;   /* outer VLAN valid */
uint32_t pfvf_vld:1;/* PF/VF valid */
+   uint32_t encap_vld:1;   /* Encapsulation valid */
uint32_t macidx:MACIDX_BITWIDTH;/* exact match MAC index */
uint32_t fcoe:FCOE_BITWIDTH;/* FCoE packet */
uint32_t iport:IPORT_BITWIDTH;  /* ingress port */
@@ -1085,6 +1087,7 @@ struct ch_filter_tuple {
uint32_t vf:VF_BITWIDTH;/* PCI-E VF ID */
uint32_t ivlan:IVLAN_BITWIDTH;  /* inner VLAN */
uint32_t ovlan:OVLAN_BITWIDTH;  /* outer VLAN */
+   uint32_t vni:ENCAP_VNI_BITWIDTH;/* VNI of tunnel */
 
/* Uncompressed header matching field rules.  These are always
 * available for field rules.
@@ -1703,6 +1706,12 @@ int t4_set_rxmode(struct adapter *adap, unsigned int 
mbox, unsigned int viid,
 int t4_free_raw_mac_filt(struct adapter *adap, unsigned int viid,
 const u8 *addr, const u8 *mask, unsigned int idx,
 u8 lookup_type, u8 port_id, bool sleep_ok);
+int t4_free_encap_mac_filt(struct adapter *adap, unsigned int viid, int idx,
+  bool sleep_ok);
+int t4_alloc_encap_mac_filt(struct adapter *adap, unsigned int viid,
+   const u8 *addr, const u8 *mask, unsigned int vni,
+   unsigned int vni_mask, u8 dip_hit, u8 lookup_type,
+   bool sleep_ok);
 int t4_alloc_raw_mac_filt(struct adapter *adap, unsigned int viid,
  const u8 *addr, const u8 *mask, unsigned int idx,
  u8 lookup_type, u8 port_id, bool sleep_ok);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
index aae9802..ac4d7f7 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
@@ -265,6 +265,8 @@ static int validate_filter(struct net_device *dev,
fs->mask.pfvf_vld) ||
unsupported(fconf, VNIC_ID_F, fs->val.ovlan_vld,
fs->mask.ovlan_vld) ||
+   unsupported(fconf, VNIC_ID_F, fs->val.encap_vld,
+   fs->mask.encap_vld) ||
unsupported(fconf, VLAN_F, fs->val.ivlan_vld, fs->mask.ivlan_vld))
return -EOPNOTSUPP;
 
@@ -275,8 +277,12 @@ static int validate_filter(struct net_device *dev,
 * carries that overlap, we need to translate any PF/VF
 * specification into that internal format below.
 */
-   if (is_field_set(fs->val.pfvf_vld, fs->mask.pfvf_vld) &&
-   is_field_set(fs->val.ovlan_vld, fs->mask.ovlan_vld))
+   if ((is_field_set(fs->val.pfvf_vld, fs->mask.pfvf_vld) &&
+is_field_set(fs->val.ovlan_vld, fs->mask.ovlan_vld)) ||
+   (is_field_set(fs->val.pfvf_vld, fs->mask.pfvf_vld) &&
+is_field_set(fs->val.encap_vld, fs->mask.encap_vld)) ||
+   (is_field_set(fs->val.ovlan_vld, fs->mask.ovlan_vld) &&
+is_field_set(fs->val.encap_vld, fs->mask.encap_vld)))
return -EOPNOTSUPP;
if (unsupported(iconf, VNIC_F, fs->val.pfvf_vld, fs->mask.pfvf_vld) ||
(is_field_set(fs->val.ovlan_vld, fs->m

[PATCH net] cxgb4: Correct ntuple mask validation for hash filters

2018-05-14 Thread Ganesh Goudar
From: Kumar Sanghvi 

Earlier code of doing bitwise AND with field width bits was wrong.
Instead, simplify code to calculate ntuple_mask based on supplied
fields and then compare with mask configured in hw - which is the
correct and simpler way to validate ntuple mask.

Fixes: 3eb8b62d5a26 ("cxgb4: add support to create hash-filters via tc-flower 
offload")
Signed-off-by: Kumar Sanghvi 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 88 ---
 1 file changed, 30 insertions(+), 58 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
index db92f18..b76447b 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
@@ -836,7 +836,7 @@ bool is_filter_exact_match(struct adapter *adap,
 {
struct tp_params *tp = &adap->params.tp;
u64 hash_filter_mask = tp->hash_filter_mask;
-   u32 mask;
+   u64 ntuple_mask = 0;
 
if (!is_hashfilter(adap))
return false;
@@ -865,73 +865,45 @@ bool is_filter_exact_match(struct adapter *adap,
if (!fs->val.fport || fs->mask.fport != 0x)
return false;
 
-   if (tp->fcoe_shift >= 0) {
-   mask = (hash_filter_mask >> tp->fcoe_shift) & FT_FCOE_W;
-   if (mask && !fs->mask.fcoe)
-   return false;
-   }
+   /* calculate tuple mask and compare with mask configured in hw */
+   if (tp->fcoe_shift >= 0)
+   ntuple_mask |= (u64)fs->mask.fcoe << tp->fcoe_shift;
 
-   if (tp->port_shift >= 0) {
-   mask = (hash_filter_mask >> tp->port_shift) & FT_PORT_W;
-   if (mask && !fs->mask.iport)
-   return false;
-   }
+   if (tp->port_shift >= 0)
+   ntuple_mask |= (u64)fs->mask.iport << tp->port_shift;
 
if (tp->vnic_shift >= 0) {
-   mask = (hash_filter_mask >> tp->vnic_shift) & FT_VNIC_ID_W;
-
-   if ((adap->params.tp.ingress_config & VNIC_F)) {
-   if (mask && !fs->mask.pfvf_vld)
-   return false;
-   } else {
-   if (mask && !fs->mask.ovlan_vld)
-   return false;
-   }
+   if ((adap->params.tp.ingress_config & VNIC_F))
+   ntuple_mask |= (u64)fs->mask.pfvf_vld << tp->vnic_shift;
+   else
+   ntuple_mask |= (u64)fs->mask.ovlan_vld <<
+   tp->vnic_shift;
}
 
-   if (tp->vlan_shift >= 0) {
-   mask = (hash_filter_mask >> tp->vlan_shift) & FT_VLAN_W;
-   if (mask && !fs->mask.ivlan)
-   return false;
-   }
+   if (tp->vlan_shift >= 0)
+   ntuple_mask |= (u64)fs->mask.ivlan << tp->vlan_shift;
 
-   if (tp->tos_shift >= 0) {
-   mask = (hash_filter_mask >> tp->tos_shift) & FT_TOS_W;
-   if (mask && !fs->mask.tos)
-   return false;
-   }
+   if (tp->tos_shift >= 0)
+   ntuple_mask |= (u64)fs->mask.tos << tp->tos_shift;
 
-   if (tp->protocol_shift >= 0) {
-   mask = (hash_filter_mask >> tp->protocol_shift) & FT_PROTOCOL_W;
-   if (mask && !fs->mask.proto)
-   return false;
-   }
+   if (tp->protocol_shift >= 0)
+   ntuple_mask |= (u64)fs->mask.proto << tp->protocol_shift;
 
-   if (tp->ethertype_shift >= 0) {
-   mask = (hash_filter_mask >> tp->ethertype_shift) &
-   FT_ETHERTYPE_W;
-   if (mask && !fs->mask.ethtype)
-   return false;
-   }
+   if (tp->ethertype_shift >= 0)
+   ntuple_mask |= (u64)fs->mask.ethtype << tp->ethertype_shift;
 
-   if (tp->macmatch_shift >= 0) {
-   mask = (hash_filter_mask >> tp->macmatch_shift) & FT_MACMATCH_W;
-   if (mask && !fs->mask.macidx)
-   return false;
-   }
+   if (tp->macmatch_shift >= 0)
+   ntuple_mask |= (u64)fs->mask.macidx << tp->macmatch_shift;
+
+   if (tp->matchtype_shift >= 0)
+   ntuple_mask |= (u64)fs->mask.matchtype << tp->matchtype_shift;
+
+   if (tp->frag_shift >= 0)
+   ntuple_mask |= (u64)fs->mask.frag << tp->frag_shift;
+
+   if (ntupl

[PATCH net-next 1/2] cxgb4: Add support for FW_ETH_TX_PKT_VM_WR

2018-05-14 Thread Ganesh Goudar
From: Arjun Vynipadath 

The present TX workrequest(FW_ETH_TX_PKT_WR) cant be used for
host->vf communication, since it doesn't loopback the outgoing
packets to virtual interfaces on the same port. This can be done using
FW_ETH_TX_PKT_VM_WR.
This fix depends on ethtool_flags to determine what WR to use for
TX path. Support for setting this flags by user is added in next commit.

Based on the original work by : Casey Leedom 

Signed-off-by: Casey Leedom 
Signed-off-by: Arjun Vynipadath 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |  13 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   2 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c| 367 
 3 files changed, 381 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 688f954..d2a 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -517,6 +517,15 @@ enum {
MAX_INGQ = MAX_ETH_QSETS + INGQ_EXTRAS,
 };
 
+enum {
+   PRIV_FLAG_PORT_TX_VM_BIT,
+};
+
+#define PRIV_FLAG_PORT_TX_VM   BIT(PRIV_FLAG_PORT_TX_VM_BIT)
+
+#define PRIV_FLAGS_ADAP0
+#define PRIV_FLAGS_PORTPRIV_FLAG_PORT_TX_VM
+
 struct adapter;
 struct sge_rspq;
 
@@ -553,6 +562,7 @@ struct port_info {
struct hwtstamp_config tstamp_config;
bool ptp_enable;
struct sched_table *sched_tbl;
+   u32 eth_flags;
 };
 
 struct dentry;
@@ -863,6 +873,7 @@ struct adapter {
unsigned int flags;
unsigned int adap_idx;
enum chip_type chip;
+   unsigned int eth_flags;
 
int msg_enable;
__be16 vxlan_port;
@@ -1324,6 +1335,8 @@ void t4_free_sge_resources(struct adapter *adap);
 void t4_free_ofld_rxqs(struct adapter *adap, int n, struct sge_ofld_rxq *q);
 irq_handler_t t4_intr_handler(struct adapter *adap);
 netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev);
+netdev_tx_t  t4vf_eth_xmit(struct sk_buff *skb, struct net_device *dev);
+netdev_tx_t t4_start_xmit(struct sk_buff *skb, struct net_device *dev);
 int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
 const struct pkt_gl *gl);
 int t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index c54fd18..b329bd1 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3211,7 +3211,7 @@ static netdev_features_t cxgb_fix_features(struct 
net_device *dev,
 static const struct net_device_ops cxgb4_netdev_ops = {
.ndo_open = cxgb_open,
.ndo_stop = cxgb_close,
-   .ndo_start_xmit   = t4_eth_xmit,
+   .ndo_start_xmit   = t4_start_xmit,
.ndo_select_queue = cxgb_select_queue,
.ndo_get_stats64  = cxgb_get_stats,
.ndo_set_rx_mode  = cxgb_set_rxmode,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 0f87e97..b914a5e 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -1549,6 +1549,373 @@ out_free:   dev_kfree_skb_any(skb);
return NETDEV_TX_OK;
 }
 
+/* Constants ... */
+enum {
+   /* Egress Queue sizes, producer and consumer indices are all in units
+* of Egress Context Units bytes.  Note that as far as the hardware is
+* concerned, the free list is an Egress Queue (the host produces free
+* buffers which the hardware consumes) and free list entries are
+* 64-bit PCI DMA addresses.
+*/
+   EQ_UNIT = SGE_EQ_IDXSIZE,
+   FL_PER_EQ_UNIT = EQ_UNIT / sizeof(__be64),
+   TXD_PER_EQ_UNIT = EQ_UNIT / sizeof(__be64),
+
+   T4VF_ETHTXQ_MAX_HDR = (sizeof(struct fw_eth_tx_pkt_vm_wr) +
+  sizeof(struct cpl_tx_pkt_lso_core) +
+  sizeof(struct cpl_tx_pkt_core)) / sizeof(__be64),
+};
+
+/**
+ * t4vf_is_eth_imm - can an Ethernet packet be sent as immediate data?
+ * @skb: the packet
+ *
+ * Returns whether an Ethernet packet is small enough to fit completely as
+ * immediate data.
+ */
+static inline int t4vf_is_eth_imm(const struct sk_buff *skb)
+{
+   /* The VF Driver uses the FW_ETH_TX_PKT_VM_WR firmware Work Request
+* which does not accommodate immediate data.  We could dike out all
+* of the support code for immediate data but that would tie our hands
+* too much if we ever want to enhace the firmware.  It would also
+* create more differences between the PF and VF Drivers.
+*/
+   return false;
+}
+
+/**
+ * t4vf_calc_tx_flits - calculate the number of flits for a packet TX WR
+ * @skb: the packet
+ *
+ * Returns the number 

[PATCH net-next 2/2] cxgb4: Support ethtool private flags

2018-05-14 Thread Ganesh Goudar
From: Arjun Vynipadath 

This is used to change TX workrequests, which helps in
host->vf communication.

Signed-off-by: Arjun Vynipadath 
Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index 59d04d7..1d979a6 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -177,6 +177,10 @@ static char loopback_stats_strings[][ETH_GSTRING_LEN] = {
"bg3_frames_trunc   ",
 };
 
+static const char cxgb4_priv_flags_strings[][ETH_GSTRING_LEN] = {
+   [PRIV_FLAG_PORT_TX_VM_BIT] = "port_tx_vm_wr",
+};
+
 static int get_sset_count(struct net_device *dev, int sset)
 {
switch (sset) {
@@ -185,6 +189,8 @@ static int get_sset_count(struct net_device *dev, int sset)
   ARRAY_SIZE(adapter_stats_strings) +
   ARRAY_SIZE(channel_stats_strings) +
   ARRAY_SIZE(loopback_stats_strings);
+   case ETH_SS_PRIV_FLAGS:
+   return ARRAY_SIZE(cxgb4_priv_flags_strings);
default:
return -EOPNOTSUPP;
}
@@ -235,6 +241,7 @@ static void get_drvinfo(struct net_device *dev, struct 
ethtool_drvinfo *info)
 FW_HDR_FW_VER_MINOR_G(exprom_vers),
 FW_HDR_FW_VER_MICRO_G(exprom_vers),
 FW_HDR_FW_VER_BUILD_G(exprom_vers));
+   info->n_priv_flags = ARRAY_SIZE(cxgb4_priv_flags_strings);
 }
 
 static void get_strings(struct net_device *dev, u32 stringset, u8 *data)
@@ -250,6 +257,9 @@ static void get_strings(struct net_device *dev, u32 
stringset, u8 *data)
data += sizeof(channel_stats_strings);
memcpy(data, loopback_stats_strings,
   sizeof(loopback_stats_strings));
+   } else if (stringset == ETH_SS_PRIV_FLAGS) {
+   memcpy(data, cxgb4_priv_flags_strings,
+  sizeof(cxgb4_priv_flags_strings));
}
 }
 
@@ -1503,6 +1513,36 @@ static int cxgb4_get_module_eeprom(struct net_device 
*dev,
 offset, len, &data[eprom->len - len]);
 }
 
+static u32 cxgb4_get_priv_flags(struct net_device *netdev)
+{
+   struct port_info *pi = netdev_priv(netdev);
+   struct adapter *adapter = pi->adapter;
+
+   return (adapter->eth_flags | pi->eth_flags);
+}
+
+/**
+ * set_flags - set/unset specified flags if passed in new_flags
+ * @cur_flags: pointer to current flags
+ * @new_flags: new incoming flags
+ * @flags: set of flags to set/unset
+ */
+static inline void set_flags(u32 *cur_flags, u32 new_flags, u32 flags)
+{
+   *cur_flags = (*cur_flags & ~flags) | (new_flags & flags);
+}
+
+static int cxgb4_set_priv_flags(struct net_device *netdev, u32 flags)
+{
+   struct port_info *pi = netdev_priv(netdev);
+   struct adapter *adapter = pi->adapter;
+
+   set_flags(&adapter->eth_flags, flags, PRIV_FLAGS_ADAP);
+   set_flags(&pi->eth_flags, flags, PRIV_FLAGS_PORT);
+
+   return 0;
+}
+
 static const struct ethtool_ops cxgb_ethtool_ops = {
.get_link_ksettings = get_link_ksettings,
.set_link_ksettings = set_link_ksettings,
@@ -1539,6 +1579,8 @@ static const struct ethtool_ops cxgb_ethtool_ops = {
.get_dump_data = get_dump_data,
.get_module_info   = cxgb4_get_module_info,
.get_module_eeprom = cxgb4_get_module_eeprom,
+   .get_priv_flags= cxgb4_get_priv_flags,
+   .set_priv_flags= cxgb4_set_priv_flags,
 };
 
 void cxgb4_set_ethtool_ops(struct net_device *netdev)
-- 
2.1.0



[PATCH net-next] cxgb4: do not fail vf instatiation in slave mode

2018-05-14 Thread Ganesh Goudar
From: Arjun Vynipadath 

We no longer require a check for cxgb4 to be MASTER
when configuring SRIOV, It was required when we had
module parameter to instantiate vf.

Signed-off-by: Arjun Vynipadath 
Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index c54fd18..4ca828c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5276,13 +5276,9 @@ static int cxgb4_iov_configure(struct pci_dev *pdev, int 
num_vfs)
u32 pcie_fw;
 
pcie_fw = readl(adap->regs + PCIE_FW_A);
-   /* Check if cxgb4 is the MASTER and fw is initialized */
-   if (num_vfs &&
-   (!(pcie_fw & PCIE_FW_INIT_F) ||
-   !(pcie_fw & PCIE_FW_MASTER_VLD_F) ||
-   PCIE_FW_MASTER_G(pcie_fw) != CXGB4_UNIFIED_PF)) {
-   dev_warn(&pdev->dev,
-"cxgb4 driver needs to be MASTER to support SRIOV\n");
+   /* Check if fw is initialized */
+   if (!(pcie_fw & PCIE_FW_INIT_F)) {
+   dev_warn(&pdev->dev, "Device not initialized\n");
return -EOPNOTSUPP;
}
 
-- 
2.1.0



[PATCH net-next] cxgb4: Add new T5 device id

2018-05-11 Thread Ganesh Goudar
Add 0x50ad device id for new T5 card.

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
index 90b5274..adacc63 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
@@ -187,6 +187,7 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
CH_PCI_ID_TABLE_FENTRY(0x50aa), /* Custom T580-CR */
CH_PCI_ID_TABLE_FENTRY(0x50ab), /* Custom T520-CR */
CH_PCI_ID_TABLE_FENTRY(0x50ac), /* Custom T540-BT */
+   CH_PCI_ID_TABLE_FENTRY(0x50ad), /* Custom T520-CR */
 
/* T6 adapters:
 */
-- 
2.1.0



[PATCH net-next 3/3] cxgb4: avoid schedule while atomic

2018-05-11 Thread Ganesh Goudar
do not sleep while adding or deleting udp tunnel.

Fixes: 846eac3fccec ("cxgb4: implement udp tunnel callbacks")
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index aa266e2..27ad69a 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3081,7 +3081,7 @@ static void cxgb_del_udp_tunnel(struct net_device *netdev,
   match_all_mac, match_all_mac,
   adapter->rawf_start +
pi->port_id,
-  1, pi->port_id, true);
+  1, pi->port_id, false);
if (ret < 0) {
netdev_info(netdev, "Failed to free mac filter entry, 
for port %d\n",
i);
@@ -3169,7 +3169,7 @@ static void cxgb_add_udp_tunnel(struct net_device *netdev,
match_all_mac,
adapter->rawf_start +
pi->port_id,
-   1, pi->port_id, true);
+   1, pi->port_id, false);
if (ret < 0) {
netdev_info(netdev, "Failed to allocate a mac filter 
entry, not adding port %d\n",
be16_to_cpu(ti->port));
-- 
2.1.0



[PATCH net-next 2/3] cxgb4: enable inner header checksum calculation

2018-05-11 Thread Ganesh Goudar
set cntrl bits to indicate whether inner header checksum
needs to be calculated whenever the packet is an encapsulated
packet and enable supported encap features.

Fixes: d0a1299c6bf7 ("cxgb4: add support for vxlan segmentation offload")
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |  9 ++-
 drivers/net/ethernet/chelsio/cxgb4/sge.c| 91 +++--
 drivers/net/ethernet/chelsio/cxgb4/t4_msg.h |  5 ++
 3 files changed, 83 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index a8aa233..aa266e2 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5636,8 +5636,15 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
NETIF_F_HW_TC;
 
-   if (CHELSIO_CHIP_VERSION(chip) > CHELSIO_T5)
+   if (CHELSIO_CHIP_VERSION(chip) > CHELSIO_T5) {
+   netdev->hw_enc_features |= NETIF_F_IP_CSUM |
+  NETIF_F_IPV6_CSUM |
+  NETIF_F_RXCSUM |
+  NETIF_F_GSO_UDP_TUNNEL |
+  NETIF_F_TSO | NETIF_F_TSO6;
+
netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
+   }
 
if (highdma)
netdev->hw_features |= NETIF_F_HIGHDMA;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 1a28df1..0f87e97 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -1072,12 +1072,27 @@ static void *inline_tx_skb_header(const struct sk_buff 
*skb,
 static u64 hwcsum(enum chip_type chip, const struct sk_buff *skb)
 {
int csum_type;
-   const struct iphdr *iph = ip_hdr(skb);
+   bool inner_hdr_csum = false;
+   u16 proto, ver;
 
-   if (iph->version == 4) {
-   if (iph->protocol == IPPROTO_TCP)
+   if (skb->encapsulation &&
+   (CHELSIO_CHIP_VERSION(chip) > CHELSIO_T5))
+   inner_hdr_csum = true;
+
+   if (inner_hdr_csum) {
+   ver = inner_ip_hdr(skb)->version;
+   proto = (ver == 4) ? inner_ip_hdr(skb)->protocol :
+   inner_ipv6_hdr(skb)->nexthdr;
+   } else {
+   ver = ip_hdr(skb)->version;
+   proto = (ver == 4) ? ip_hdr(skb)->protocol :
+   ipv6_hdr(skb)->nexthdr;
+   }
+
+   if (ver == 4) {
+   if (proto == IPPROTO_TCP)
csum_type = TX_CSUM_TCPIP;
-   else if (iph->protocol == IPPROTO_UDP)
+   else if (proto == IPPROTO_UDP)
csum_type = TX_CSUM_UDPIP;
else {
 nocsum:/*
@@ -1090,19 +1105,29 @@ static u64 hwcsum(enum chip_type chip, const struct 
sk_buff *skb)
/*
 * this doesn't work with extension headers
 */
-   const struct ipv6hdr *ip6h = (const struct ipv6hdr *)iph;
-
-   if (ip6h->nexthdr == IPPROTO_TCP)
+   if (proto == IPPROTO_TCP)
csum_type = TX_CSUM_TCPIP6;
-   else if (ip6h->nexthdr == IPPROTO_UDP)
+   else if (proto == IPPROTO_UDP)
csum_type = TX_CSUM_UDPIP6;
else
goto nocsum;
}
 
if (likely(csum_type >= TX_CSUM_TCPIP)) {
-   u64 hdr_len = TXPKT_IPHDR_LEN_V(skb_network_header_len(skb));
-   int eth_hdr_len = skb_network_offset(skb) - ETH_HLEN;
+   int eth_hdr_len, l4_len;
+   u64 hdr_len;
+
+   if (inner_hdr_csum) {
+   /* This allows checksum offload for all encapsulated
+* packets like GRE etc..
+*/
+   l4_len = skb_inner_network_header_len(skb);
+   eth_hdr_len = skb_inner_network_offset(skb) - ETH_HLEN;
+   } else {
+   l4_len = skb_network_header_len(skb);
+   eth_hdr_len = skb_network_offset(skb) - ETH_HLEN;
+   }
+   hdr_len = TXPKT_IPHDR_LEN_V(l4_len);
 
if (CHELSIO_CHIP_VERSION(chip) <= CHELSIO_T5)
hdr_len |= TXPKT_ETHHDR_LEN_V(eth_hdr_len);
@@ -1273,7 +1298,7 @@ static inline void t6_fill_tnl_lso(struct sk_buff *skb,
 netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev)
 {
u32 wr_mid, ctrl0, op;
-   u64 cntrl, *end;
+

[PATCH net-next 1/3] cxgb4: Fix {vxlan/geneve}_port initialization

2018-05-11 Thread Ganesh Goudar
From: Arjun Vynipadath 

adapter->rawf_cnt was not initialized, thereby
ndo_udp_tunnel_{add/del} was returning immediately
without initializing {vxlan/geneve}_port.
Also initializes mps_encap_entry refcnt.

Fixes: 846eac3fccec ("cxgb4: implement udp tunnel callbacks")
Signed-off-by: Arjun Vynipadath 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 21 +
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h   |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 5e33780..a8aa233 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4276,6 +4276,20 @@ static int adap_init0(struct adapter *adap)
adap->tids.nftids = val[4] - val[3] + 1;
adap->sge.ingr_start = val[5];
 
+   if (CHELSIO_CHIP_VERSION(adap->params.chip) > CHELSIO_T5) {
+   /* Read the raw mps entries. In T6, the last 2 tcam entries
+* are reserved for raw mac addresses (rawf = 2, one per port).
+*/
+   params[0] = FW_PARAM_PFVF(RAWF_START);
+   params[1] = FW_PARAM_PFVF(RAWF_END);
+   ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 2,
+ params, val);
+   if (ret == 0) {
+   adap->rawf_start = val[0];
+   adap->rawf_cnt = val[1] - val[0] + 1;
+   }
+   }
+
/* qids (ingress/egress) returned from firmware can be anywhere
 * in the range from EQ(IQFLINT)_START to EQ(IQFLINT)_END.
 * Hence driver needs to allocate memory for this range to
@@ -5181,6 +5195,7 @@ static void free_some_resources(struct adapter *adapter)
 {
unsigned int i;
 
+   kvfree(adapter->mps_encap);
kvfree(adapter->smt);
kvfree(adapter->l2t);
kvfree(adapter->srq);
@@ -5687,6 +5702,12 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
adapter->params.offload = 0;
}
 
+   adapter->mps_encap = kvzalloc(sizeof(struct mps_encap_entry) *
+ adapter->params.arch.mps_tcam_size,
+ GFP_KERNEL);
+   if (!adapter->mps_encap)
+   dev_warn(&pdev->dev, "could not allocate MPS Encap entries, 
continuing\n");
+
 #if IS_ENABLED(CONFIG_IPV6)
if ((CHELSIO_CHIP_VERSION(adapter->params.chip) <= CHELSIO_T5) &&
(!(t4_read_reg(adapter, LE_DB_CONFIG_A) & ASLIPCOMPEN_F))) {
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
index e3d4751..0e007ee 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
@@ -1305,6 +1305,8 @@ enum fw_params_param_pfvf {
FW_PARAMS_PARAM_PFVF_HPFILTER_END = 0x33,
FW_PARAMS_PARAM_PFVF_TLS_START = 0x34,
FW_PARAMS_PARAM_PFVF_TLS_END = 0x35,
+   FW_PARAMS_PARAM_PFVF_RAWF_START = 0x36,
+   FW_PARAMS_PARAM_PFVF_RAWF_END = 0x37,
FW_PARAMS_PARAM_PFVF_NCRYPTO_LOOKASIDE = 0x39,
FW_PARAMS_PARAM_PFVF_PORT_CAPS32 = 0x3A,
 };
-- 
2.1.0



[PATCH net-next] cxgb4: fix the wrong conversion of Mbps to Kbps

2018-05-10 Thread Ganesh Goudar
fix the wrong conversion where 1 Mbps was converted to
1024 Kbps.

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 32cad0a..5e33780 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2886,13 +2886,13 @@ static int cxgb_set_tx_maxrate(struct net_device *dev, 
int index, u32 rate)
}
 
/* Convert from Mbps to Kbps */
-   req_rate = rate << 10;
+   req_rate = rate * 1000;
 
/* Max rate is 100 Gbps */
-   if (req_rate >= SCHED_MAX_RATE_KBPS) {
+   if (req_rate > SCHED_MAX_RATE_KBPS) {
dev_err(adap->pdev_dev,
"Invalid rate %u Mbps, Max rate is %u Mbps\n",
-   rate, SCHED_MAX_RATE_KBPS >> 10);
+   rate, SCHED_MAX_RATE_KBPS / 1000);
return -ERANGE;
}
 
-- 
2.1.0



[PATCH net] cxgb4: copy mbox log size to PF0-3 adap instances

2018-05-09 Thread Ganesh Goudar
copy mbox size to adapter instances of PF0-3 to avoid
mbox log overflow. This fixes the possible protection
fault.

Fixes: baf5086840ab ("cxgb4: restructure VF mgmt code")
Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 8b34a7b..3f6d204 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5474,6 +5474,7 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
}
spin_lock_init(&adapter->mbox_lock);
INIT_LIST_HEAD(&adapter->mlist.list);
+   adapter->mbox_log->size = T4_OS_LOG_MBOX_CMDS;
pci_set_drvdata(pdev, adapter);
 
if (func != ent->driver_data) {
@@ -5508,8 +5509,6 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
goto out_free_adapter;
}
 
-   adapter->mbox_log->size = T4_OS_LOG_MBOX_CMDS;
-
/* PCI device has been enabled */
adapter->flags |= DEV_ENABLED;
memset(adapter->chan_map, 0xff, sizeof(adapter->chan_map));
-- 
2.1.0



[PATCH net] cxgb4: zero the HMA memory

2018-05-09 Thread Ganesh Goudar
firmware expects HMA memory to be zeroed, use __GFP_ZERO
for HMA memory allocation.

Fixes: 8b4e6b3ca2ed ("cxgb4: Add HMA support")
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 24d2865..c3ae575 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3433,8 +3433,8 @@ static int adap_config_hma(struct adapter *adapter)
sgl = adapter->hma.sgt->sgl;
node = dev_to_node(adapter->pdev_dev);
for_each_sg(sgl, iter, sgt->orig_nents, i) {
-   newpage = alloc_pages_node(node, __GFP_NOWARN | GFP_KERNEL,
-  page_order);
+   newpage = alloc_pages_node(node, __GFP_NOWARN | GFP_KERNEL |
+  __GFP_ZERO, page_order);
if (!newpage) {
dev_err(adapter->pdev_dev,
"Not enough memory for HMA page allocation\n");
-- 
2.1.0



[PATCH net-next] cxgb4: update latest firmware version supported

2018-05-02 Thread Ganesh Goudar
Change t4fw_version.h to update latest firmware version
number to 1.19.1.0.

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h
index 123e2c1..4eb15ce 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h
@@ -36,8 +36,8 @@
 #define __T4FW_VERSION_H__
 
 #define T4FW_VERSION_MAJOR 0x01
-#define T4FW_VERSION_MINOR 0x10
-#define T4FW_VERSION_MICRO 0x3F
+#define T4FW_VERSION_MINOR 0x13
+#define T4FW_VERSION_MICRO 0x01
 #define T4FW_VERSION_BUILD 0x00
 
 #define T4FW_MIN_VERSION_MAJOR 0x01
@@ -45,8 +45,8 @@
 #define T4FW_MIN_VERSION_MICRO 0x00
 
 #define T5FW_VERSION_MAJOR 0x01
-#define T5FW_VERSION_MINOR 0x10
-#define T5FW_VERSION_MICRO 0x3F
+#define T5FW_VERSION_MINOR 0x13
+#define T5FW_VERSION_MICRO 0x01
 #define T5FW_VERSION_BUILD 0x00
 
 #define T5FW_MIN_VERSION_MAJOR 0x00
@@ -54,8 +54,8 @@
 #define T5FW_MIN_VERSION_MICRO 0x00
 
 #define T6FW_VERSION_MAJOR 0x01
-#define T6FW_VERSION_MINOR 0x10
-#define T6FW_VERSION_MICRO 0x3F
+#define T6FW_VERSION_MINOR 0x13
+#define T6FW_VERSION_MICRO 0x01
 #define T6FW_VERSION_BUILD 0x00
 
 #define T6FW_MIN_VERSION_MAJOR 0x00
-- 
2.1.0



[PATCH net-next] cxgb4: add new T5 device id's

2018-05-01 Thread Ganesh Goudar
Add device id's 0x5019, 0x501a and 0x501b for T5
cards.

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
index 51b1803..90b5274 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
@@ -145,6 +145,9 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
CH_PCI_ID_TABLE_FENTRY(0x5016), /* T580-OCP-SO */
CH_PCI_ID_TABLE_FENTRY(0x5017), /* T520-OCP-SO */
CH_PCI_ID_TABLE_FENTRY(0x5018), /* T540-BT */
+   CH_PCI_ID_TABLE_FENTRY(0x5019), /* T540-LP-BT */
+   CH_PCI_ID_TABLE_FENTRY(0x501a), /* T540-SO-BT */
+   CH_PCI_ID_TABLE_FENTRY(0x501b), /* T540-SO-CR */
CH_PCI_ID_TABLE_FENTRY(0x5080), /* Custom T540-cr */
CH_PCI_ID_TABLE_FENTRY(0x5081), /* Custom T540-LL-cr */
CH_PCI_ID_TABLE_FENTRY(0x5082), /* Custom T504-cr */
-- 
2.1.0



[PATCH net-next] cxgb4vf: display pause settings

2018-04-17 Thread Ganesh Goudar
Add support to display pause settings

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c 
b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index 9a81b523..71f13bd 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -1419,6 +1419,22 @@ static int cxgb4vf_get_link_ksettings(struct net_device 
*dev,
base->duplex = DUPLEX_UNKNOWN;
}
 
+   if (pi->link_cfg.fc & PAUSE_RX) {
+   if (pi->link_cfg.fc & PAUSE_TX) {
+   ethtool_link_ksettings_add_link_mode(link_ksettings,
+advertising,
+Pause);
+   } else {
+   ethtool_link_ksettings_add_link_mode(link_ksettings,
+advertising,
+Asym_Pause);
+   }
+   } else if (pi->link_cfg.fc & PAUSE_TX) {
+   ethtool_link_ksettings_add_link_mode(link_ksettings,
+advertising,
+Asym_Pause);
+   }
+
base->autoneg = pi->link_cfg.autoneg;
if (pi->link_cfg.pcaps & FW_PORT_CAP32_ANEG)
ethtool_link_ksettings_add_link_mode(link_ksettings,
-- 
2.1.0



Re: [PATCH v14 net-next 08/12] crypto : chtls - CPL handler definition

2018-03-30 Thread Ganesh Goudar
On Friday, March 03/30/18, 2018 at 00:38:06 +0530, Atul Gupta wrote:
> 
> 
> On 3/29/2018 9:56 PM, Sabrina Dubroca wrote:
> > 2018-03-29, 21:27:50 +0530, Atul Gupta wrote:
> > ...
> >> +static void chtls_pass_accept_request(struct sock *sk,
> >> +struct sk_buff *skb)
> >> +{
> > ...
> >> +  if (chtls_get_module(newsk))
> >> +  goto reject;
> >> +  inet_csk_reqsk_queue_added(sk);
> >> +  reply_skb->sk = newsk;
> >> +  chtls_install_cpl_ops(newsk);
> > Function defined in patch 11, declared in patch 6, and used in patch
> > 8.  Are you actually listening to the comments we've been sending?
> Patch series is broken to make it bisectable, it ensures that existing 
> modules net, cxgb4, chcr compiles fine, since chtls is new module the 
> sequence of patches builds clean by virtue of having Makefile change in the 
> last patch. We have followed a similar approach in the past for new 
> submission of chcr, cxgbit drivers.
> >
>
I hope you are fine with this, we will take care of your other comment in V15
and submit.

Thanks


[PATCH net-next] cxgb4: support new ISSI flash parts

2018-03-23 Thread Ganesh Goudar
Add support for new 32MB and 64MB ISSI (Integrated Silicon
Solution, Inc.) FLASH parts.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index b862477..7cb3ef4 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -8604,6 +8604,25 @@ static int t4_get_flash_params(struct adapter *adap)
}
break;
}
+   case 0x9d: { /* ISSI -- Integrated Silicon Solution, Inc. */
+   /* This Density -> Size decoding table is taken from ISSI
+* Data Sheets.
+*/
+   density = (flashid >> 16) & 0xff;
+   switch (density) {
+   case 0x16: /* 32 MB */
+   size = 1 << 25;
+   break;
+   case 0x17: /* 64MB */
+   size = 1 << 26;
+   break;
+   default:
+   dev_err(adap->pdev_dev, "ISSI Flash Part has bad size, 
ID = %#x, Density code = %#x\n",
+   flashid, density);
+   return -EINVAL;
+   }
+   break;
+   }
case 0xc2: { /* Macronix */
/* This Density -> Size decoding table is taken from Macronix
 * Data Sheets.
-- 
2.1.0



[PATCH net-next] cxgb4: depend on firmware event for link status

2018-03-23 Thread Ganesh Goudar
Depend on the firmware sending us link status changes,
rather than assuming that the link goes down upon L1
configuration.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 38e38dc..b862477 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -4066,8 +4066,6 @@ int t4_link_l1cfg(struct adapter *adapter, unsigned int 
mbox,
unsigned int fw_mdi = FW_PORT_CAP32_MDI_V(FW_PORT_CAP32_MDI_AUTO);
fw_port_cap32_t fw_fc, cc_fec, fw_fec, rcap;
 
-   lc->link_ok = 0;
-
/* Convert driver coding of Pause Frame Flow Control settings into the
 * Firmware's API.
 */
-- 
2.1.0



[PATCH net-next] cxgb4: copy vlan_id in ndo_get_vf_config

2018-03-23 Thread Ganesh Goudar
From: Arjun Vynipadath 

Copy vlan_id to get it displayed in vf info.

Signed-off-by: Arjun Vynipadath 
Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudhar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 8f733ee..55f158f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2695,13 +2695,17 @@ static int cxgb4_mgmt_get_vf_config(struct net_device 
*dev,
 {
struct port_info *pi = netdev_priv(dev);
struct adapter *adap = pi->adapter;
+   struct vf_info *vfinfo;
 
if (vf >= adap->num_vfs)
return -EINVAL;
+   vfinfo = &adap->vfinfo[vf];
+
ivi->vf = vf;
-   ivi->max_tx_rate = adap->vfinfo[vf].tx_rate;
+   ivi->max_tx_rate = vfinfo->tx_rate;
ivi->min_tx_rate = 0;
-   ether_addr_copy(ivi->mac, adap->vfinfo[vf].vf_mac_addr);
+   ether_addr_copy(ivi->mac, vfinfo->vf_mac_addr);
+   ivi->vlan = vfinfo->vlan;
return 0;
 }
 
-- 
2.1.0



[PATCH net-next] cxgb4: Setup FW queues before registering netdev

2018-03-23 Thread Ganesh Goudar
From: Arjun Vynipadath 

When NetworkManager is enabled, there are chances that interface up
is called even before probe completes. This means we have not yet
allocated the FW sge queues, hence rest of ingress queue allocation
wont be proper. Fix this by calling setup_fw_sge_queues() before
register_netdev().

Fixes: 0fbc81b3ad51 ('chcr/cxgb4i/cxgbit/RDMA/cxgb4: Allocate resources 
dynamically for all cxgb4 ULD's')
Signed-off-by: Arjun Vynipadath 
Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index c4e0e47..8f733ee 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -841,8 +841,6 @@ static int setup_fw_sge_queues(struct adapter *adap)
 
err = t4_sge_alloc_rxq(adap, &s->fw_evtq, true, adap->port[0],
   adap->msi_idx, NULL, fwevtq_handler, NULL, -1);
-   if (err)
-   t4_free_sge_resources(adap);
return err;
 }
 
@@ -5750,6 +5748,13 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (err)
goto out_free_dev;
 
+   err = setup_fw_sge_queues(adapter);
+   if (err) {
+   dev_err(adapter->pdev_dev,
+   "FW sge queue allocation failed, err %d", err);
+   goto out_free_dev;
+   }
+
/*
 * The card is now ready to go.  If any errors occur during device
 * registration we do not fail the whole card but rather proceed only
@@ -5798,10 +5803,10 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
cxgb4_ptp_init(adapter);
 
print_adapter_info(adapter);
-   setup_fw_sge_queues(adapter);
return 0;
 
  out_free_dev:
+   t4_free_sge_resources(adapter);
free_some_resources(adapter);
if (adapter->flags & USING_MSIX)
free_msix_info(adapter);
-- 
2.1.0



[PATCH net-next] cxgb4: notify fatal error to uld drivers

2018-03-16 Thread Ganesh Goudar
notify uld drivers if the adapter encounters fatal
error.

Signed-off-by: Ganesh Goudar 
---
 drivers/infiniband/hw/cxgb4/device.c|  1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |  1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 10 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |  3 ++-
 4 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index 7a9d0de..e96771d 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -1217,6 +1217,7 @@ static int c4iw_uld_state_change(void *handle, enum 
cxgb4_state new_state)
if (ctx->dev)
c4iw_remove(ctx);
break;
+   case CXGB4_STATE_FATAL_ERROR:
case CXGB4_STATE_START_RECOVERY:
pr_info("%s: Fatal Error\n", pci_name(ctx->lldi.pdev));
if (ctx->dev) {
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index b2df0ff..a5c0a64 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -917,6 +917,7 @@ struct adapter {
struct work_struct tid_release_task;
struct work_struct db_full_task;
struct work_struct db_drop_task;
+   struct work_struct fatal_err_notify_task;
bool tid_release_task_busy;
 
/* lock for mailbox cmd list */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 5a349e15..72ec3f7 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3255,6 +3255,14 @@ static const struct ethtool_ops cxgb4_mgmt_ethtool_ops = 
{
.get_drvinfo   = cxgb4_mgmt_get_drvinfo,
 };
 
+static void notify_fatal_err(struct work_struct *work)
+{
+   struct adapter *adap;
+
+   adap = container_of(work, struct adapter, fatal_err_notify_task);
+   notify_ulds(adap, CXGB4_STATE_FATAL_ERROR);
+}
+
 void t4_fatal_err(struct adapter *adap)
 {
int port;
@@ -3279,6 +3287,7 @@ void t4_fatal_err(struct adapter *adap)
netif_carrier_off(dev);
}
dev_alert(adap->pdev_dev, "encountered fatal error, adapter stopped\n");
+   queue_work(adap->workq, &adap->fatal_err_notify_task);
 }
 
 static void setup_memwin(struct adapter *adap)
@@ -5479,6 +5488,7 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
INIT_WORK(&adapter->tid_release_task, process_tid_release_list);
INIT_WORK(&adapter->db_full_task, process_db_full);
INIT_WORK(&adapter->db_drop_task, process_db_drop);
+   INIT_WORK(&adapter->fatal_err_notify_task, notify_fatal_err);
 
err = t4_prep_adapter(adapter);
if (err)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
index a14e8db..788146c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
@@ -257,7 +257,8 @@ enum cxgb4_state {
CXGB4_STATE_UP,
CXGB4_STATE_START_RECOVERY,
CXGB4_STATE_DOWN,
-   CXGB4_STATE_DETACH
+   CXGB4_STATE_DETACH,
+   CXGB4_STATE_FATAL_ERROR
 };
 
 enum cxgb4_control {
-- 
2.1.0



[PATCH net-next] cxgb4: Fix queue free path of ULD drivers

2018-03-15 Thread Ganesh Goudar
From: Arjun Vynipadath 

Setting sge_uld_rxq_info to NULL in free_queues_uld().
We are referencing sge_uld_rxq_info in cxgb_up(). This
will fix a panic when interface is brought up after a
ULDq creation failure.

Fixes: 94cdb8bb993a (cxgb4: Add support for dynamic allocation
   of resources for ULD)
Signed-off-by: Arjun Vynipadath 
Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudhar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
index 6b5fea4..2d82714 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
@@ -342,6 +342,7 @@ static void free_queues_uld(struct adapter *adap, unsigned 
int uld_type)
 {
struct sge_uld_rxq_info *rxq_info = adap->sge.uld_rxq_info[uld_type];
 
+   adap->sge.uld_rxq_info[uld_type] = NULL;
kfree(rxq_info->rspq_id);
kfree(rxq_info->uldrxq);
kfree(rxq_info);
-- 
2.1.0



[PATCH net-next] cxgb4/cxgb4vf: check fw caps to set link mode mask

2018-03-10 Thread Ganesh Goudar
check firmware capabilities before setting ethtool
link mode mask, also add few missing speeds.

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 24 --
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c| 37 ++
 2 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index 7852d98..59d04d7 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -597,22 +597,22 @@ static void fw_caps_to_lmm(enum fw_port_type port_type,
 
case FW_PORT_TYPE_KR:
SET_LMM(Backplane);
-   SET_LMM(1baseKR_Full);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseKR_Full);
break;
 
case FW_PORT_TYPE_BP_AP:
SET_LMM(Backplane);
-   SET_LMM(1baseR_FEC);
-   SET_LMM(1baseKR_Full);
-   SET_LMM(1000baseKX_Full);
+   FW_CAPS_TO_LMM(SPEED_1G, 1000baseKX_Full);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseR_FEC);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseKR_Full);
break;
 
case FW_PORT_TYPE_BP4_AP:
SET_LMM(Backplane);
-   SET_LMM(1baseR_FEC);
-   SET_LMM(1baseKR_Full);
-   SET_LMM(1000baseKX_Full);
-   SET_LMM(1baseKX4_Full);
+   FW_CAPS_TO_LMM(SPEED_1G, 1000baseKX_Full);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseR_FEC);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseKR_Full);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseKX4_Full);
break;
 
case FW_PORT_TYPE_FIBER_XFI:
@@ -628,7 +628,9 @@ static void fw_caps_to_lmm(enum fw_port_type port_type,
case FW_PORT_TYPE_BP40_BA:
case FW_PORT_TYPE_QSFP:
SET_LMM(FIBRE);
-   SET_LMM(4baseSR4_Full);
+   FW_CAPS_TO_LMM(SPEED_1G, 1000baseT_Full);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseT_Full);
+   FW_CAPS_TO_LMM(SPEED_40G, 4baseSR4_Full);
break;
 
case FW_PORT_TYPE_CR_QSFP:
@@ -655,12 +657,14 @@ static void fw_caps_to_lmm(enum fw_port_type port_type,
 
case FW_PORT_TYPE_CR2_QSFP:
SET_LMM(FIBRE);
-   SET_LMM(5baseSR2_Full);
+   FW_CAPS_TO_LMM(SPEED_50G, 5baseSR2_Full);
break;
 
case FW_PORT_TYPE_KR4_100G:
case FW_PORT_TYPE_CR4_QSFP:
SET_LMM(FIBRE);
+   FW_CAPS_TO_LMM(SPEED_1G,  1000baseT_Full);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseSR_Full);
FW_CAPS_TO_LMM(SPEED_40G, 4baseSR4_Full);
FW_CAPS_TO_LMM(SPEED_25G, 25000baseCR_Full);
FW_CAPS_TO_LMM(SPEED_50G, 5baseCR2_Full);
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c 
b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index 361de86..7bd8497 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -1289,22 +1289,22 @@ static void fw_caps_to_lmm(enum fw_port_type port_type,
 
case FW_PORT_TYPE_KR:
SET_LMM(Backplane);
-   SET_LMM(1baseKR_Full);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseKR_Full);
break;
 
case FW_PORT_TYPE_BP_AP:
SET_LMM(Backplane);
-   SET_LMM(1baseR_FEC);
-   SET_LMM(1baseKR_Full);
-   SET_LMM(1000baseKX_Full);
+   FW_CAPS_TO_LMM(SPEED_1G, 1000baseKX_Full);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseR_FEC);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseKR_Full);
break;
 
case FW_PORT_TYPE_BP4_AP:
SET_LMM(Backplane);
-   SET_LMM(1baseR_FEC);
-   SET_LMM(1baseKR_Full);
-   SET_LMM(1000baseKX_Full);
-   SET_LMM(1baseKX4_Full);
+   FW_CAPS_TO_LMM(SPEED_1G, 1000baseKX_Full);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseR_FEC);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseKR_Full);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseKX4_Full);
break;
 
case FW_PORT_TYPE_FIBER_XFI:
@@ -1320,18 +1320,24 @@ static void fw_caps_to_lmm(enum fw_port_type port_type,
case FW_PORT_TYPE_BP40_BA:
case FW_PORT_TYPE_QSFP:
SET_LMM(FIBRE);
-   SET_LMM(4baseSR4_Full);
+   FW_CAPS_TO_LMM(SPEED_1G, 1000baseT_Full);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseT_Full);
+   FW_CAPS_TO_LMM(SPEED_40G, 4baseSR4_Full);
break;
 
case FW_PORT_TYPE_CR_QSFP:
case FW_PORT_TYPE_SFP28:
SET_LMM(FIBRE);
-   SET_LMM

[PATCH net-next] cxgb4: do not display 50Gbps as unsupported speed

2018-03-10 Thread Ganesh Goudar
50Gbps is a supported speed, Stop reporting it as
unsupported speed.

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 1b44652..78f5506 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -210,6 +210,9 @@ static void link_report(struct net_device *dev)
case 4:
s = "40Gbps";
break;
+   case 5:
+   s = "50Gbps";
+   break;
case 10:
s = "100Gbps";
break;
-- 
2.1.0



[PATCH net-next] cxgb4: increase max tx rate limit to 100 Gbps

2018-03-08 Thread Ganesh Goudar
T6 cards can support up to 100 G speeds. So, increase
max programmable tx rate limit to 100 Gbps.

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 6 +++---
 drivers/net/ethernet/chelsio/cxgb4/sched.h  | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 7b452e8..1b44652 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2870,11 +2870,11 @@ static int cxgb_set_tx_maxrate(struct net_device *dev, 
int index, u32 rate)
/* Convert from Mbps to Kbps */
req_rate = rate << 10;
 
-   /* Max rate is 10 Gbps */
+   /* Max rate is 100 Gbps */
if (req_rate >= SCHED_MAX_RATE_KBPS) {
dev_err(adap->pdev_dev,
-   "Invalid rate %u Mbps, Max rate is %u Gbps\n",
-   rate, SCHED_MAX_RATE_KBPS);
+   "Invalid rate %u Mbps, Max rate is %u Mbps\n",
+   rate, SCHED_MAX_RATE_KBPS >> 10);
return -ERANGE;
}
 
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sched.h 
b/drivers/net/ethernet/chelsio/cxgb4/sched.h
index 77b2b3f..3a49e00 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sched.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/sched.h
@@ -42,8 +42,8 @@
 
 #define FW_SCHED_CLS_NONE 0x
 
-/* Max rate that can be set to a scheduling class is 10 Gbps */
-#define SCHED_MAX_RATE_KBPS 1000U
+/* Max rate that can be set to a scheduling class is 100 Gbps */
+#define SCHED_MAX_RATE_KBPS 1U
 
 enum {
SCHED_STATE_ACTIVE,
-- 
2.1.0



[PATCH net] cxgb4: do not set needs_free_netdev for mgmt dev's

2018-03-06 Thread Ganesh Goudar
Do not set 'needs_free_netdev' as we do call free_netdev
for mgmt net devices, doing both hits BUG_ON.

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 33bc8418..61022b5 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4970,7 +4970,6 @@ static void cxgb4_mgmt_setup(struct net_device *dev)
/* Initialize the device structure. */
dev->netdev_ops = &cxgb4_mgmt_netdev_ops;
dev->ethtool_ops = &cxgb4_mgmt_ethtool_ops;
-   dev->needs_free_netdev = true;
 }
 
 static int cxgb4_iov_configure(struct pci_dev *pdev, int num_vfs)
-- 
2.1.0



[PATCH net] cxgb4: copy adap index to PF0-3 adapter instances

2018-03-06 Thread Ganesh Goudar
instantiation of VF's on different adapters fails, copy
adapter index and chip type to PF0-3 adapter instances
to fix the issue.

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 7b452e8..33bc8418 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5181,6 +5181,8 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
adapter->name = pci_name(pdev);
adapter->mbox = func;
adapter->pf = func;
+   adapter->params.chip = chip;
+   adapter->adap_idx = adap_idx;
adapter->msg_enable = DFLT_MSG_ENABLE;
adapter->mbox_log = kzalloc(sizeof(*adapter->mbox_log) +
(sizeof(struct mbox_cmd) *
-- 
2.1.0



[PATCH net-next] cxgb4: Add TP Congestion map entry for single-port

2018-03-02 Thread Ganesh Goudar
Add TP Congestion Map entry for single-port T6 cards.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index bd41f93..2c889ef 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -6091,6 +6091,7 @@ unsigned int t4_get_tp_ch_map(struct adapter *adap, int 
pidx)
 
case CHELSIO_T6:
switch (nports) {
+   case 1:
case 2: return 1 << pidx;
}
break;
-- 
2.1.0



[PATCH net-next] cxgb4: remove dead code when allocating filter

2018-03-02 Thread Ganesh Goudar
Error code is already returned earlier if filter exists
at specified location. So, remove dead code trying to
free existing filter.

Reported-by: Dan Carpenter 
Signed-off-by: Ganesh Goudar 
Signed-off-by: Rahul Lakkireddy 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
index 3177b0c..db92f18 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
@@ -1335,12 +1335,6 @@ int __cxgb4_set_filter(struct net_device *dev, int 
filter_id,
return ret;
}
 
-   /* Clear out any old resources being used by the filter before
-* we start constructing the new filter.
-*/
-   if (f->valid)
-   clear_filter(adapter, f);
-
if (is_t6(adapter->params.chip) && fs->type &&
ipv6_addr_type((const struct in6_addr *)fs->val.lip) !=
IPV6_ADDR_ANY) {
-- 
2.1.0



[PATCH net-next v2] cxgb4vf: Forcefully link up virtual interfaces

2018-03-01 Thread Ganesh Goudar
From: Arjun Vynipadath 

The Virtual Interfaces are connected to an internal switch on the chip
which allows VIs attached to the same port to talk to each other even
when the port link is down.  As a result, we generally want to always
report a VI's link as being "up".

Based on the original work by: Casey Leedom 
Signed-off-by: Arjun Vynipadath 
Signed-off-by: Ganesh Goudar 
---
V2: Doing force_link_up unconditionally
---
 drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c 
b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index b7e79e6..361de86 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -155,8 +155,6 @@ void t4vf_os_link_changed(struct adapter *adapter, int 
pidx, int link_ok)
const char *fc;
const struct port_info *pi = netdev_priv(dev);
 
-   netif_carrier_on(dev);
-
switch (pi->link_cfg.speed) {
case 100:
s = "100Mbps";
@@ -202,7 +200,6 @@ void t4vf_os_link_changed(struct adapter *adapter, int 
pidx, int link_ok)
 
netdev_info(dev, "link up, %s, full-duplex, %s PAUSE\n", s, fc);
} else {
-   netif_carrier_off(dev);
netdev_info(dev, "link down\n");
}
 }
@@ -278,6 +275,17 @@ static int link_start(struct net_device *dev)
 */
if (ret == 0)
ret = t4vf_enable_vi(pi->adapter, pi->viid, true, true);
+
+   /* The Virtual Interfaces are connected to an internal switch on the
+* chip which allows VIs attached to the same port to talk to each
+* other even when the port link is down.  As a result, we generally
+* want to always report a VI's link as being "up", provided there are
+* no errors in enabling vi.
+*/
+
+   if (ret == 0)
+   netif_carrier_on(dev);
+
return ret;
 }
 
-- 
2.1.0



[PATCH net-next] cxgb4vf: Forcefully link up virtual interfaces

2018-02-23 Thread Ganesh Goudar
From: Arjun Vynipadath 

The Virtual Interfaces are connected to an internal switch on the chip
which allows VIs attached to the same port to talk to each other even
when the port link is down.  As a result, we generally want to always
report a VI's link as being "up".

Based on the original work by: Casey Leedom 
Signed-off-by: Arjun Vynipadath 
Signed-off-by: Ganesh Goudar 
---
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c| 26 --
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c 
b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index b7e79e6..7fe8763 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -92,6 +92,18 @@ module_param(msi, int, 0644);
 MODULE_PARM_DESC(msi, "whether to use MSI-X or MSI");
 
 /*
+ * Logic controls.
+ * ===
+ */
+
+/* The Virtual Interfaces are connected to an internal switch on the chip
+ * which allows VIs attached to the same port to talk to each other even when
+ * the port link is down.  As a result, we generally want to always report a
+ * VI's link as being "up".
+ */
+#define force_link_up 1
+
+/*
  * Fundamental constants.
  * ==
  */
@@ -155,7 +167,8 @@ void t4vf_os_link_changed(struct adapter *adapter, int 
pidx, int link_ok)
const char *fc;
const struct port_info *pi = netdev_priv(dev);
 
-   netif_carrier_on(dev);
+   if (!force_link_up)
+   netif_carrier_on(dev);
 
switch (pi->link_cfg.speed) {
case 100:
@@ -202,7 +215,9 @@ void t4vf_os_link_changed(struct adapter *adapter, int 
pidx, int link_ok)
 
netdev_info(dev, "link up, %s, full-duplex, %s PAUSE\n", s, fc);
} else {
-   netif_carrier_off(dev);
+   if (!force_link_up)
+   netif_carrier_off(dev);
+
netdev_info(dev, "link down\n");
}
 }
@@ -278,6 +293,13 @@ static int link_start(struct net_device *dev)
 */
if (ret == 0)
ret = t4vf_enable_vi(pi->adapter, pi->viid, true, true);
+
+   /* If we didn't experience any error and we're always reporting the
+* link as being "up", tell the OS that the link is up.
+*/
+   if (ret == 0 && force_link_up)
+   netif_carrier_on(dev);
+
return ret;
 }
 
-- 
2.1.0



[PATCH] PCI/cxgb4: Extend T3 PCI quirk to T4+ devices

2018-02-15 Thread Ganesh Goudar
From: Casey Leedom 

We've run into a problem where our device is attached
to a Virtual Machine and the use of the new pci_set_vpd_size()
API doesn't help.  The VM kernel has been informed that
the accesses are okay, but all of the actual VPD Capability
Accesses are trapped down into the KVM Hypervisor where it
goes ahead and imposes the silent denials.

The right idea is to follow the kernel.org
commit 1c7de2b4ff88 ("PCI: Enable access to non-standard VPD for
Chelsio devices (cxgb3)") which Alexey Kardashevskiy authored
to establish a PCI Quirk for our T3-based adapters. This commit
extends that PCI Quirk to cover Chelsio T4 devices and later.

The advantage of this approach is that the VPD Size gets set early
in the Base OS/Hypervisor Boot and doesn't require that the cxgb4
driver even be available in the Base OS/Hypervisor.  Thus PF4 can
be exported to a Virtual Machine and everything should work.

Fixes: 67e658794ca1 ("cxgb4: Set VPD size so we can read both VPD structures")
Cc:   # v4.9+
Signed-off-by: Casey Leedom 
Signed-off-by: Arjun Vynipadath 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 10 
 drivers/pci/quirks.c   | 39 ++
 2 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 047609e..920bccd 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -2637,7 +2637,6 @@ void t4_get_regs(struct adapter *adap, void *buf, size_t 
buf_size)
 }
 
 #define EEPROM_STAT_ADDR   0x7bfc
-#define VPD_SIZE   0x800
 #define VPD_BASE   0x400
 #define VPD_BASE_OLD   0
 #define VPD_LEN1024
@@ -2704,15 +2703,6 @@ int t4_get_raw_vpd_params(struct adapter *adapter, 
struct vpd_params *p)
if (!vpd)
return -ENOMEM;
 
-   /* We have two VPD data structures stored in the adapter VPD area.
-* By default, Linux calculates the size of the VPD area by traversing
-* the first VPD area at offset 0x0, so we need to tell the OS what
-* our real VPD size is.
-*/
-   ret = pci_set_vpd_size(adapter->pdev, VPD_SIZE);
-   if (ret < 0)
-   goto out;
-
/* Card information normally starts at VPD_BASE but early cards had
 * it at 0.
 */
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index fc73401..8b14bd3 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3419,22 +3419,29 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 
PCI_DEVICE_ID_INTEL_PORT_RIDGE,
 
 static void quirk_chelsio_extend_vpd(struct pci_dev *dev)
 {
-   pci_set_vpd_size(dev, 8192);
-}
-
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x20, quirk_chelsio_extend_vpd);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x21, quirk_chelsio_extend_vpd);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x22, quirk_chelsio_extend_vpd);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x23, quirk_chelsio_extend_vpd);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x24, quirk_chelsio_extend_vpd);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x25, quirk_chelsio_extend_vpd);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x26, quirk_chelsio_extend_vpd);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x30, quirk_chelsio_extend_vpd);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x31, quirk_chelsio_extend_vpd);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x32, quirk_chelsio_extend_vpd);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x35, quirk_chelsio_extend_vpd);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x36, quirk_chelsio_extend_vpd);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x37, quirk_chelsio_extend_vpd);
+   int chip = (dev->device & 0xf000) >> 12;
+   int func = (dev->device & 0x0f00) >>  8;
+   int prod = (dev->device & 0x00ff) >>  0;
+
+   /*
+* If this is a T3-based adapter, there's a 1KB VPD area at offset
+* 0xc00 which contains the preferred VPD values.  If this is a T4 or
+* later based adapter, the special VPD is at offset 0x400 for the
+* Physical Functions (the SR-IOV Virtual Functions have no VPD
+* Capabilities).  The PCI VPD Access core routines will normally
+* compute the size of the VPD by parsing the VPD Data Structure at
+* offset 0x000.  This will result in silent failures when attempting
+* to accesses these other VPD areas which are beyond those computed
+* limits.
+*/
+   if (chip == 0x0 && prod >= 0x20)
+   pci_set_vpd_size(dev, 8192);
+   else if (chip >= 0x4 && func < 0x8)
+   pci_set_vpd_size(dev, 2048);
+}
+
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID,
+   quirk_chelsio_extend_vpd);
 
 #ifdef CONFIG_ACPI
 /*
-- 
2.1.0



[PATCH net] cxgb4: free up resources of pf 0-3

2018-02-15 Thread Ganesh Goudar
free pf 0-3 resources, commit baf5086840ab ("cxgb4:
restructure VF mgmt code") erroneously removed the
code which frees the pf 0-3 resources, causing the
probe of pf 0-3 to fail in case of driver reload.

Fixes: baf5086840ab ("cxgb4: restructure VF mgmt code")
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 56bc626..7b452e8 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4982,9 +4982,10 @@ static int cxgb4_iov_configure(struct pci_dev *pdev, int 
num_vfs)
 
pcie_fw = readl(adap->regs + PCIE_FW_A);
/* Check if cxgb4 is the MASTER and fw is initialized */
-   if (!(pcie_fw & PCIE_FW_INIT_F) ||
+   if (num_vfs &&
+   (!(pcie_fw & PCIE_FW_INIT_F) ||
!(pcie_fw & PCIE_FW_MASTER_VLD_F) ||
-   PCIE_FW_MASTER_G(pcie_fw) != CXGB4_UNIFIED_PF) {
+   PCIE_FW_MASTER_G(pcie_fw) != CXGB4_UNIFIED_PF)) {
dev_warn(&pdev->dev,
 "cxgb4 driver needs to be MASTER to support SRIOV\n");
return -EOPNOTSUPP;
@@ -5599,24 +5600,24 @@ static void remove_one(struct pci_dev *pdev)
 #if IS_ENABLED(CONFIG_IPV6)
t4_cleanup_clip_tbl(adapter);
 #endif
-   iounmap(adapter->regs);
if (!is_t4(adapter->params.chip))
iounmap(adapter->bar2);
-   pci_disable_pcie_error_reporting(pdev);
-   if ((adapter->flags & DEV_ENABLED)) {
-   pci_disable_device(pdev);
-   adapter->flags &= ~DEV_ENABLED;
-   }
-   pci_release_regions(pdev);
-   kfree(adapter->mbox_log);
-   synchronize_rcu();
-   kfree(adapter);
}
 #ifdef CONFIG_PCI_IOV
else {
cxgb4_iov_configure(adapter->pdev, 0);
}
 #endif
+   iounmap(adapter->regs);
+   pci_disable_pcie_error_reporting(pdev);
+   if ((adapter->flags & DEV_ENABLED)) {
+   pci_disable_device(pdev);
+   adapter->flags &= ~DEV_ENABLED;
+   }
+   pci_release_regions(pdev);
+   kfree(adapter->mbox_log);
+   synchronize_rcu();
+   kfree(adapter);
 }
 
 /* "Shutdown" quiesces the device, stopping Ingress Packet and Interrupt
-- 
2.1.0



[PATCH net-next] cxgb4: fix possible deadlock

2018-01-25 Thread Ganesh Goudar
t4_wr_mbox_meat_timeout() can be called from both softirq
context and process context, hence protect the mbox with
spin_lock_bh() instead of simple spin_lock()

Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 3405547..af27d2b 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -317,9 +317,9 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, 
const void *cmd,
 * wait [for a while] till we're at the front [or bail out with an
 * EBUSY] ...
 */
-   spin_lock(&adap->mbox_lock);
+   spin_lock_bh(&adap->mbox_lock);
list_add_tail(&entry.list, &adap->mlist.list);
-   spin_unlock(&adap->mbox_lock);
+   spin_unlock_bh(&adap->mbox_lock);
 
delay_idx = 0;
ms = delay[0];
@@ -332,9 +332,9 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, 
const void *cmd,
 */
pcie_fw = t4_read_reg(adap, PCIE_FW_A);
if (i > FW_CMD_MAX_TIMEOUT || (pcie_fw & PCIE_FW_ERR_F)) {
-   spin_lock(&adap->mbox_lock);
+   spin_lock_bh(&adap->mbox_lock);
list_del(&entry.list);
-   spin_unlock(&adap->mbox_lock);
+   spin_unlock_bh(&adap->mbox_lock);
ret = (pcie_fw & PCIE_FW_ERR_F) ? -ENXIO : -EBUSY;
t4_record_mbox(adap, cmd, size, access, ret);
return ret;
@@ -365,9 +365,9 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, 
const void *cmd,
for (i = 0; v == MBOX_OWNER_NONE && i < 3; i++)
v = MBOWNER_G(t4_read_reg(adap, ctl_reg));
if (v != MBOX_OWNER_DRV) {
-   spin_lock(&adap->mbox_lock);
+   spin_lock_bh(&adap->mbox_lock);
list_del(&entry.list);
-   spin_unlock(&adap->mbox_lock);
+   spin_unlock_bh(&adap->mbox_lock);
ret = (v == MBOX_OWNER_FW) ? -EBUSY : -ETIMEDOUT;
t4_record_mbox(adap, cmd, size, access, ret);
return ret;
@@ -418,9 +418,9 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, 
const void *cmd,
execute = i + ms;
t4_record_mbox(adap, cmd_rpl,
   MBOX_LEN, access, execute);
-   spin_lock(&adap->mbox_lock);
+   spin_lock_bh(&adap->mbox_lock);
list_del(&entry.list);
-   spin_unlock(&adap->mbox_lock);
+   spin_unlock_bh(&adap->mbox_lock);
return -FW_CMD_RETVAL_G((int)res);
}
}
@@ -430,9 +430,9 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, 
const void *cmd,
dev_err(adap->pdev_dev, "command %#x in mailbox %d timed out\n",
*(const u8 *)cmd, mbox);
t4_report_fw_error(adap);
-   spin_lock(&adap->mbox_lock);
+   spin_lock_bh(&adap->mbox_lock);
list_del(&entry.list);
-   spin_unlock(&adap->mbox_lock);
+   spin_unlock_bh(&adap->mbox_lock);
t4_fatal_err(adap);
return ret;
 }
-- 
2.1.0



[PATCH net-next V2] cxgb4/cxgb4vf: add support for ndo_set_vf_vlan

2018-01-24 Thread Ganesh Goudar
implement ndo_set_vf_vlan for mgmt netdevice to configure
the PCIe VF.

Original work by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
V2: changing htonl() to cpu_to_be32() to maintain consistency
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |  3 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c| 26 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 32 ++
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  | 16 ---
 drivers/net/ethernet/chelsio/cxgb4vf/adapter.h |  1 +
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|  2 ++
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c | 15 --
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h |  1 +
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c | 28 +++
 9 files changed, 116 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 3e02187..4294673 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -820,6 +820,7 @@ struct vf_info {
unsigned char vf_mac_addr[ETH_ALEN];
unsigned int tx_rate;
bool pf_set_mac;
+   u16 vlan;
 };
 
 struct mbox_list {
@@ -1738,4 +1739,6 @@ void free_rspq_fl(struct adapter *adap, struct sge_rspq 
*rq, struct sge_fl *fl);
 void free_tx_desc(struct adapter *adap, struct sge_txq *q,
  unsigned int n, bool unmap);
 void free_txq(struct adapter *adap, struct sge_txq *q);
+int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf,
+   u16 vlan);
 #endif /* __CXGB4_H__ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 4716387..f0fd2eb 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2783,7 +2783,30 @@ static int cxgb4_mgmt_set_vf_rate(struct net_device 
*dev, int vf,
return 0;
 }
 
-#endif
+static int cxgb4_mgmt_set_vf_vlan(struct net_device *dev, int vf,
+ u16 vlan, u8 qos, __be16 vlan_proto)
+{
+   struct port_info *pi = netdev_priv(dev);
+   struct adapter *adap = pi->adapter;
+   int ret;
+
+   if (vf >= adap->num_vfs || vlan > 4095 || qos > 7)
+   return -EINVAL;
+
+   if (vlan_proto != htons(ETH_P_8021Q) || qos != 0)
+   return -EPROTONOSUPPORT;
+
+   ret = t4_set_vlan_acl(adap, adap->mbox, vf + 1, vlan);
+   if (!ret) {
+   adap->vfinfo[vf].vlan = vlan;
+   return 0;
+   }
+
+   dev_err(adap->pdev_dev, "Err %d %s VLAN ACL for PF/VF %d/%d\n",
+   ret, (vlan ? "setting" : "clearing"), adap->pf, vf);
+   return ret;
+}
+#endif /* CONFIG_PCI_IOV */
 
 static int cxgb_set_mac_addr(struct net_device *dev, void *p)
 {
@@ -3207,6 +3230,7 @@ static const struct net_device_ops cxgb4_mgmt_netdev_ops 
= {
.ndo_get_vf_config= cxgb4_mgmt_get_vf_config,
.ndo_set_vf_rate  = cxgb4_mgmt_set_vf_rate,
.ndo_get_phys_port_id = cxgb4_mgmt_get_phys_port_id,
+   .ndo_set_vf_vlan  = cxgb4_mgmt_set_vf_vlan,
 };
 #endif
 
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 6d76851..3405547 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -9899,3 +9899,35 @@ int t4_i2c_rd(struct adapter *adap, unsigned int mbox, 
int port,
 
return ret;
 }
+
+/**
+ *  t4_set_vlan_acl - Set a VLAN id for the specified VF
+ *  @adapter: the adapter
+ *  @mbox: mailbox to use for the FW command
+ *  @vf: one of the VFs instantiated by the specified PF
+ *  @vlan: The vlanid to be set
+ */
+int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf,
+   u16 vlan)
+{
+   struct fw_acl_vlan_cmd vlan_cmd;
+   unsigned int enable;
+
+   enable = (vlan ? FW_ACL_VLAN_CMD_EN_F : 0);
+   memset(&vlan_cmd, 0, sizeof(vlan_cmd));
+   vlan_cmd.op_to_vfn = cpu_to_be32(FW_CMD_OP_V(FW_ACL_VLAN_CMD) |
+FW_CMD_REQUEST_F |
+FW_CMD_WRITE_F |
+FW_CMD_EXEC_F |
+FW_ACL_VLAN_CMD_PFN_V(adap->pf) |
+FW_ACL_VLAN_CMD_VFN_V(vf));
+   vlan_cmd.en_to_len16 = cpu_to_be32(enable | FW_LEN16(vlan_cmd));
+   /* Drop all packets that donot match vlan id */
+   vlan_cmd.dropnovlan_fm = FW_ACL_VLAN_CMD_FM_F;
+   if (enable != 0) {
+   vlan_cmd.nvlan = 1;
+   vlan_cmd.vlanid[0] = cpu_to_be16(vlan);
+   }
+
+   return t4_wr_mbox(adap, adap->mbox, &vlan_cmd, sizeof(vlan_cmd), NULL);
+

[PATCH net-next] cxgb4/cxgb4vf: add support for ndo_set_vf_vlan

2018-01-23 Thread Ganesh Goudar
implement ndo_set_vf_vlan for mgmt netdevice to configure
the PCIe VF.

Original work by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |  3 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c| 26 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 32 ++
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  | 16 ---
 drivers/net/ethernet/chelsio/cxgb4vf/adapter.h |  1 +
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|  2 ++
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c | 15 --
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h |  1 +
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c | 28 +++
 9 files changed, 116 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 3e02187..4294673 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -820,6 +820,7 @@ struct vf_info {
unsigned char vf_mac_addr[ETH_ALEN];
unsigned int tx_rate;
bool pf_set_mac;
+   u16 vlan;
 };
 
 struct mbox_list {
@@ -1738,4 +1739,6 @@ void free_rspq_fl(struct adapter *adap, struct sge_rspq 
*rq, struct sge_fl *fl);
 void free_tx_desc(struct adapter *adap, struct sge_txq *q,
  unsigned int n, bool unmap);
 void free_txq(struct adapter *adap, struct sge_txq *q);
+int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf,
+   u16 vlan);
 #endif /* __CXGB4_H__ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 4716387..f0fd2eb 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2783,7 +2783,30 @@ static int cxgb4_mgmt_set_vf_rate(struct net_device 
*dev, int vf,
return 0;
 }
 
-#endif
+static int cxgb4_mgmt_set_vf_vlan(struct net_device *dev, int vf,
+ u16 vlan, u8 qos, __be16 vlan_proto)
+{
+   struct port_info *pi = netdev_priv(dev);
+   struct adapter *adap = pi->adapter;
+   int ret;
+
+   if (vf >= adap->num_vfs || vlan > 4095 || qos > 7)
+   return -EINVAL;
+
+   if (vlan_proto != htons(ETH_P_8021Q) || qos != 0)
+   return -EPROTONOSUPPORT;
+
+   ret = t4_set_vlan_acl(adap, adap->mbox, vf + 1, vlan);
+   if (!ret) {
+   adap->vfinfo[vf].vlan = vlan;
+   return 0;
+   }
+
+   dev_err(adap->pdev_dev, "Err %d %s VLAN ACL for PF/VF %d/%d\n",
+   ret, (vlan ? "setting" : "clearing"), adap->pf, vf);
+   return ret;
+}
+#endif /* CONFIG_PCI_IOV */
 
 static int cxgb_set_mac_addr(struct net_device *dev, void *p)
 {
@@ -3207,6 +3230,7 @@ static const struct net_device_ops cxgb4_mgmt_netdev_ops 
= {
.ndo_get_vf_config= cxgb4_mgmt_get_vf_config,
.ndo_set_vf_rate  = cxgb4_mgmt_set_vf_rate,
.ndo_get_phys_port_id = cxgb4_mgmt_get_phys_port_id,
+   .ndo_set_vf_vlan  = cxgb4_mgmt_set_vf_vlan,
 };
 #endif
 
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 6d76851..3405547 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -9899,3 +9899,35 @@ int t4_i2c_rd(struct adapter *adap, unsigned int mbox, 
int port,
 
return ret;
 }
+
+/**
+ *  t4_set_vlan_acl - Set a VLAN id for the specified VF
+ *  @adapter: the adapter
+ *  @mbox: mailbox to use for the FW command
+ *  @vf: one of the VFs instantiated by the specified PF
+ *  @vlan: The vlanid to be set
+ */
+int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf,
+   u16 vlan)
+{
+   struct fw_acl_vlan_cmd vlan_cmd;
+   unsigned int enable;
+
+   enable = (vlan ? FW_ACL_VLAN_CMD_EN_F : 0);
+   memset(&vlan_cmd, 0, sizeof(vlan_cmd));
+   vlan_cmd.op_to_vfn = cpu_to_be32(FW_CMD_OP_V(FW_ACL_VLAN_CMD) |
+FW_CMD_REQUEST_F |
+FW_CMD_WRITE_F |
+FW_CMD_EXEC_F |
+FW_ACL_VLAN_CMD_PFN_V(adap->pf) |
+FW_ACL_VLAN_CMD_VFN_V(vf));
+   vlan_cmd.en_to_len16 = cpu_to_be32(enable | FW_LEN16(vlan_cmd));
+   /* Drop all packets that donot match vlan id */
+   vlan_cmd.dropnovlan_fm = FW_ACL_VLAN_CMD_FM_F;
+   if (enable != 0) {
+   vlan_cmd.nvlan = 1;
+   vlan_cmd.vlanid[0] = cpu_to_be16(vlan);
+   }
+
+   return t4_wr_mbox(adap, adap->mbox, &vlan_cmd, sizeof(vlan_cmd), NULL);
+}
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h 
b/driv

Re: [REGRESSION, bisect] pci: cxgb4 probe fails after commit 104daa71b3961434 ("PCI: Determine actual VPD size on first access")

2018-01-23 Thread Ganesh Goudar
+Hannes Reinecke

On Tuesday, January 01/23/18, 2018 at 17:59:09 +0530, Arjun Vynipadath wrote:
> Sending on behalf of "Casey Leedom "
> 
> Way back on April 11, 2016 we reported a regression in Linux kernel 4.6-rc2 
> brought on by kernel.org commit 104daa71b396. This commit calculates the 
> size of a PCI Device's VPD area by parsing the VPD Structure at offset 0x000, 
> and restricts accesses to the VPD to that computed size.
> 
> Our devices have a second VPD structure which is located starting at offset 
> 0x400 which is the "real" VPD[1].  The 104daa71b396 commit (plus a follow on 
> commit 408641e93aa5) caused efforts to read past the end of that computed 
> length of the VPD to return silently without error leaving stack junk in the 
> VPD read buffers.
> 
> We introduced kernel.org commit cb92148b to allow a driver to tell the 
> kernel how large the VPD area really is, introducing a new API 
> pci_set_vpd_size() for this purpose.
> 
> Now we've discovered a new subtlety to the problem.
> 
> We have a KVM Hypervisor running a 4.9.70 kernel.  So it has all of the 
> above commits.  When we attach our Physical Function 4 to a Virtual Machine 
> and attempt to run cxgb4 in that VM, we see the problem again.  The issue is 
> that all of the VM Guest OS's efforts to access the PCIe VPD Capability are 
> trapped into the KVM 4.9.70 kernel and executed there, with the results 
> routed back to the VM Guest OS.  The cxgb4 driver in the VM Guest OS uses 
> the new pci_set_vpd_size() to notify the OS of the true size of the VPD, but 
> that information of course is never sent to the KVM 4.9.70 Hypervisor. 
> (And, truth be told, if the Guest OS were older than 4.6, it wouldn't even 
> know that it needed to do this.)  The result is that again we get silent VPD 
> read failures with random stack garbage in the VPD read buffers. (sigh) 
> 
> It strikes me that the only way to handle this issue is to have KVM 
> circumvent the VPD-Size Restricted logic which was added in kernel.org 
> commits 104daa71b396 and 408641e93aa5.  Maybe via a __pci_read_vpd() or 
> similar API.  But we are open to other suggestions.
> 
> Thoughts?
> 
> Casey.
> 
> [1] Chelsio adapters actually have two VPD structures stored in the VPD.  An
> abbreviated on at Offset 0x0 and the complete VPD at Offset 0x400.  The
> abbreviated one only contains the PN, SN and EC Keywords, while the
> complete VPD contains those plus various adapter constants contained in
> V0, V1, etc.  And it also contains the Base Ethernet MAC Address in the
> "NA" Keyword which the cxgb4 driver needs when it can't contact the
> adapter firmware.  (We don't have the "NA" Keyword in the VPD Structure
> at Offset 0x000 because that's not an allowed VPD Keyword in the PCI-E
> 3.0 specification.)
> 
> Note that two other drivers look like they may also do something
> similar, the Broadcom bnx2x and tg3.


[PATCH net-next] cxgb4: add geneve offload support for T6

2018-01-22 Thread Ganesh Goudar
Add geneve segmentation offload support of T6 cards.

Original work by: Santosh Rastapur 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |  2 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 71 -
 drivers/net/ethernet/chelsio/cxgb4/sge.c|  3 ++
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h| 11 
 4 files changed, 63 insertions(+), 24 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index f05b58f..3e02187 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -846,6 +846,8 @@ struct adapter {
int msg_enable;
__be16 vxlan_port;
u8 vxlan_port_cnt;
+   __be16 geneve_port;
+   u8 geneve_port_cnt;
 
struct adapter_params params;
struct cxgb4_virt_res vres;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 11fe596..4716387 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3020,6 +3020,17 @@ static void cxgb_del_udp_tunnel(struct net_device 
*netdev,
adapter->vxlan_port = 0;
t4_write_reg(adapter, MPS_RX_VXLAN_TYPE_A, 0);
break;
+   case UDP_TUNNEL_TYPE_GENEVE:
+   if (!adapter->geneve_port_cnt ||
+   adapter->geneve_port != ti->port)
+   return; /* Invalid GENEVE destination port */
+
+   adapter->geneve_port_cnt--;
+   if (adapter->geneve_port_cnt)
+   return;
+
+   adapter->geneve_port = 0;
+   t4_write_reg(adapter, MPS_RX_GENEVE_TYPE_A, 0);
default:
return;
}
@@ -3055,17 +3066,11 @@ static void cxgb_add_udp_tunnel(struct net_device 
*netdev,
u8 match_all_mac[] = { 0, 0, 0, 0, 0, 0 };
int i, ret;
 
-   if (chip_ver < CHELSIO_T6)
+   if (chip_ver < CHELSIO_T6 || !adapter->rawf_cnt)
return;
 
switch (ti->type) {
case UDP_TUNNEL_TYPE_VXLAN:
-   /* For T6 fw reserves last 2 entries for
-* storing match all mac filter (config file entry).
-*/
-   if (!adapter->rawf_cnt)
-   return;
-
/* Callback for adding vxlan port can be called with the same
 * port for both IPv4 and IPv6. We should not disable the
 * offloading when the same port for both protocols is added
@@ -3091,6 +3096,26 @@ static void cxgb_add_udp_tunnel(struct net_device 
*netdev,
t4_write_reg(adapter, MPS_RX_VXLAN_TYPE_A,
 VXLAN_V(be16_to_cpu(ti->port)) | VXLAN_EN_F);
break;
+   case UDP_TUNNEL_TYPE_GENEVE:
+   if (adapter->geneve_port_cnt &&
+   adapter->geneve_port == ti->port) {
+   adapter->geneve_port_cnt++;
+   return;
+   }
+
+   /* We will support only one GENEVE port */
+   if (adapter->geneve_port_cnt) {
+   netdev_info(netdev, "UDP port %d already offloaded, not 
adding port %d\n",
+   be16_to_cpu(adapter->geneve_port),
+   be16_to_cpu(ti->port));
+   return;
+   }
+
+   adapter->geneve_port = ti->port;
+   adapter->geneve_port_cnt = 1;
+
+   t4_write_reg(adapter, MPS_RX_GENEVE_TYPE_A,
+GENEVE_V(be16_to_cpu(ti->port)) | GENEVE_EN_F);
default:
return;
}
@@ -3101,24 +3126,22 @@ static void cxgb_add_udp_tunnel(struct net_device 
*netdev,
 * we will remove this 'match all' entry and fallback to adding
 * exact match filters.
 */
-   if (adapter->rawf_cnt) {
-   for_each_port(adapter, i) {
-   pi = adap2pinfo(adapter, i);
-
-   ret = t4_alloc_raw_mac_filt(adapter, pi->viid,
-   match_all_mac,
-   match_all_mac,
-   adapter->rawf_start +
-   pi->port_id,
-   1, pi->port_id, true);
-   if (ret < 0) {
-   netdev_info(netdev, "Failed to allocate a mac 
filter entry, not adding port %d\n",
-   be16_to_cpu(ti->port));
-   cxgb_del_udp_tunnel(netdev, ti);
-

[PATCH net-next] cxgb3: assign port id to net_device->dev_port

2018-01-19 Thread Ganesh Goudar
From: Arjun Vynipadath 

T3 devices have different ports on same PCI function,
so using dev_port to identify ports.

Signed-off-by: Arjun Vynipadath 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c 
b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index 6a01536..185fe8d 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -3304,6 +3304,7 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
netdev->ethtool_ops = &cxgb_ethtool_ops;
netdev->min_mtu = 81;
netdev->max_mtu = ETH_MAX_MTU;
+   netdev->dev_port = pi->port_id;
}
 
pci_set_drvdata(pdev, adapter);
-- 
2.1.0



[PATCH net-next] cxgb4: IPv6 filter takes 2 tids

2018-01-16 Thread Ganesh Goudar
on T6, IPv6 filter would occupy 2 tids instead of 4.

Signed-off-by: Kumar Sanghvi 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 113 +++---
 1 file changed, 80 insertions(+), 33 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
index 677a3ba..3177b0c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
@@ -439,19 +439,32 @@ int cxgb4_get_free_ftid(struct net_device *dev, int 
family)
if (ftid >= t->nftids)
ftid = -1;
} else {
-   ftid = bitmap_find_free_region(t->ftid_bmap, t->nftids, 2);
-   if (ftid < 0)
-   goto out_unlock;
+   if (is_t6(adap->params.chip)) {
+   ftid = bitmap_find_free_region(t->ftid_bmap,
+  t->nftids, 1);
+   if (ftid < 0)
+   goto out_unlock;
+
+   /* this is only a lookup, keep the found region
+* unallocated
+*/
+   bitmap_release_region(t->ftid_bmap, ftid, 1);
+   } else {
+   ftid = bitmap_find_free_region(t->ftid_bmap,
+  t->nftids, 2);
+   if (ftid < 0)
+   goto out_unlock;
 
-   /* this is only a lookup, keep the found region unallocated */
-   bitmap_release_region(t->ftid_bmap, ftid, 2);
+   bitmap_release_region(t->ftid_bmap, ftid, 2);
+   }
}
 out_unlock:
spin_unlock_bh(&t->ftid_lock);
return ftid;
 }
 
-static int cxgb4_set_ftid(struct tid_info *t, int fidx, int family)
+static int cxgb4_set_ftid(struct tid_info *t, int fidx, int family,
+ unsigned int chip_ver)
 {
spin_lock_bh(&t->ftid_lock);
 
@@ -460,22 +473,31 @@ static int cxgb4_set_ftid(struct tid_info *t, int fidx, 
int family)
return -EBUSY;
}
 
-   if (family == PF_INET)
+   if (family == PF_INET) {
__set_bit(fidx, t->ftid_bmap);
-   else
-   bitmap_allocate_region(t->ftid_bmap, fidx, 2);
+   } else {
+   if (chip_ver < CHELSIO_T6)
+   bitmap_allocate_region(t->ftid_bmap, fidx, 2);
+   else
+   bitmap_allocate_region(t->ftid_bmap, fidx, 1);
+   }
 
spin_unlock_bh(&t->ftid_lock);
return 0;
 }
 
-static void cxgb4_clear_ftid(struct tid_info *t, int fidx, int family)
+static void cxgb4_clear_ftid(struct tid_info *t, int fidx, int family,
+unsigned int chip_ver)
 {
spin_lock_bh(&t->ftid_lock);
-   if (family == PF_INET)
+   if (family == PF_INET) {
__clear_bit(fidx, t->ftid_bmap);
-   else
-   bitmap_release_region(t->ftid_bmap, fidx, 2);
+   } else {
+   if (chip_ver < CHELSIO_T6)
+   bitmap_release_region(t->ftid_bmap, fidx, 2);
+   else
+   bitmap_release_region(t->ftid_bmap, fidx, 1);
+   }
spin_unlock_bh(&t->ftid_lock);
 }
 
@@ -1249,23 +1271,42 @@ int __cxgb4_set_filter(struct net_device *dev, int 
filter_id,
}
}
} else { /* IPv6 */
-   /* Ensure that the IPv6 filter is aligned on a
-* multiple of 4 boundary.
-*/
-   if (filter_id & 0x3) {
-   dev_err(adapter->pdev_dev,
-   "Invalid location. IPv6 must be aligned on a 
4-slot boundary\n");
-   return -EINVAL;
-   }
+   if (chip_ver < CHELSIO_T6) {
+   /* Ensure that the IPv6 filter is aligned on a
+* multiple of 4 boundary.
+*/
+   if (filter_id & 0x3) {
+   dev_err(adapter->pdev_dev,
+   "Invalid location. IPv6 must be aligned 
on a 4-slot boundary\n");
+   return -EINVAL;
+   }
 
-   /* Check all except the base overlapping IPv4 filter slots. */
-   for (fidx = filter_id + 1; fidx < filter_id + 4; fidx++) {
+   /* Check all except the base overlapping IPv4 filter
+* slots.
+*/
+   for (fidx = filter_id + 1; fidx < filter_id + 

[PATCH net-next] cxgb4: restructure VF mgmt code

2018-01-16 Thread Ganesh Goudar
restructure the code which adds support for configuring
PCIe VF via mgmt netdevice. which was added by
commit 7829451c695e ("cxgb4: Add control net_device for
configuring PCIe VF")

Original work by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |   1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 393 
 2 files changed, 190 insertions(+), 204 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index baa67d3..f05b58f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -312,6 +312,7 @@ struct vpd_params {
 };
 
 struct pci_params {
+   unsigned int vpd_cap_addr;
unsigned char speed;
unsigned char width;
 };
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 3293980..11fe596 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -102,7 +102,9 @@ const char cxgb4_driver_version[] = DRV_VERSION;
  */
 #define CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN \
static const struct pci_device_id cxgb4_pci_tbl[] = {
-#define CH_PCI_DEVICE_ID_FUNCTION 0x4
+#define CXGB4_UNIFIED_PF 0x4
+
+#define CH_PCI_DEVICE_ID_FUNCTION CXGB4_UNIFIED_PF
 
 /* Include PCI Device IDs for both PF4 and PF0-3 so our PCI probe() routine is
  * called for both.
@@ -110,7 +112,7 @@ const char cxgb4_driver_version[] = DRV_VERSION;
 #define CH_PCI_DEVICE_ID_FUNCTION2 0x0
 
 #define CH_PCI_ID_TABLE_ENTRY(devid) \
-   {PCI_VDEVICE(CHELSIO, (devid)), 4}
+   {PCI_VDEVICE(CHELSIO, (devid)), CXGB4_UNIFIED_PF}
 
 #define CH_PCI_DEVICE_ID_TABLE_DEFINE_END \
{ 0, } \
@@ -2605,7 +2607,7 @@ static int cxgb_change_mtu(struct net_device *dev, int 
new_mtu)
 }
 
 #ifdef CONFIG_PCI_IOV
-static int dummy_open(struct net_device *dev)
+static int cxgb4_mgmt_open(struct net_device *dev)
 {
/* Turn carrier off since we don't have to transmit anything on this
 * interface.
@@ -2615,39 +2617,44 @@ static int dummy_open(struct net_device *dev)
 }
 
 /* Fill MAC address that will be assigned by the FW */
-static void fill_vf_station_mac_addr(struct adapter *adap)
+static void cxgb4_mgmt_fill_vf_station_mac_addr(struct adapter *adap)
 {
-   unsigned int i;
u8 hw_addr[ETH_ALEN], macaddr[ETH_ALEN];
+   unsigned int i, vf, nvfs;
+   u16 a, b;
int err;
u8 *na;
-   u16 a, b;
 
+   adap->params.pci.vpd_cap_addr = pci_find_capability(adap->pdev,
+   PCI_CAP_ID_VPD);
err = t4_get_raw_vpd_params(adap, &adap->params.vpd);
-   if (!err) {
-   na = adap->params.vpd.na;
-   for (i = 0; i < ETH_ALEN; i++)
-   hw_addr[i] = (hex2val(na[2 * i + 0]) * 16 +
- hex2val(na[2 * i + 1]));
-   a = (hw_addr[0] << 8) | hw_addr[1];
-   b = (hw_addr[1] << 8) | hw_addr[2];
-   a ^= b;
-   a |= 0x0200;/* locally assigned Ethernet MAC address */
-   a &= ~0x0100;   /* not a multicast Ethernet MAC address */
-   macaddr[0] = a >> 8;
-   macaddr[1] = a & 0xff;
-
-   for (i = 2; i < 5; i++)
-   macaddr[i] = hw_addr[i + 1];
-
-   for (i = 0; i < adap->num_vfs; i++) {
-   macaddr[5] = adap->pf * 16 + i;
-   ether_addr_copy(adap->vfinfo[i].vf_mac_addr, macaddr);
-   }
+   if (err)
+   return;
+
+   na = adap->params.vpd.na;
+   for (i = 0; i < ETH_ALEN; i++)
+   hw_addr[i] = (hex2val(na[2 * i + 0]) * 16 +
+ hex2val(na[2 * i + 1]));
+
+   a = (hw_addr[0] << 8) | hw_addr[1];
+   b = (hw_addr[1] << 8) | hw_addr[2];
+   a ^= b;
+   a |= 0x0200;/* locally assigned Ethernet MAC address */
+   a &= ~0x0100;   /* not a multicast Ethernet MAC address */
+   macaddr[0] = a >> 8;
+   macaddr[1] = a & 0xff;
+
+   for (i = 2; i < 5; i++)
+   macaddr[i] = hw_addr[i + 1];
+
+   for (vf = 0, nvfs = pci_sriov_get_totalvfs(adap->pdev);
+   vf < nvfs; vf++) {
+   macaddr[5] = adap->pf * 16 + vf;
+   ether_addr_copy(adap->vfinfo[vf].vf_mac_addr, macaddr);
}
 }
 
-static int cxgb_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
+static int cxgb4_mgmt_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
 {
struct port_info *pi = netdev_priv(dev);
struct adapter *adap = pi->adapter;
@@ -2669,8 +2676,8 @@ static int cxgb_set_vf_mac(struct net_device *dev, int 
vf, 

[PATCH net-next 4/4] cxgb4: implement ndo_features_check

2018-01-10 Thread Ganesh Goudar
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index d0e08f6..3293980 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3115,6 +3115,24 @@ static void cxgb_add_udp_tunnel(struct net_device 
*netdev,
}
 }
 
+static netdev_features_t cxgb_features_check(struct sk_buff *skb,
+struct net_device *dev,
+netdev_features_t features)
+{
+   struct port_info *pi = netdev_priv(dev);
+   struct adapter *adapter = pi->adapter;
+
+   if (CHELSIO_CHIP_VERSION(adapter->params.chip) < CHELSIO_T6)
+   return features;
+
+   /* Check if hw supports offload for this packet */
+   if (!skb->encapsulation || cxgb_encap_offload_supported(skb))
+   return features;
+
+   /* Offload is not supported for this encapsulated packet */
+   return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
+}
+
 static netdev_features_t cxgb_fix_features(struct net_device *dev,
   netdev_features_t features)
 {
@@ -3148,6 +3166,7 @@ static const struct net_device_ops cxgb4_netdev_ops = {
.ndo_setup_tc = cxgb_setup_tc,
.ndo_udp_tunnel_add   = cxgb_add_udp_tunnel,
.ndo_udp_tunnel_del   = cxgb_del_udp_tunnel,
+   .ndo_features_check   = cxgb_features_check,
.ndo_fix_features = cxgb_fix_features,
 };
 
-- 
2.1.0



[PATCH net-next 3/4] cxgb4: add support for vxlan segmentation offload

2018-01-10 Thread Ganesh Goudar
add changes to t4_eth_xmit to enable vxlan segmentation
offload support.

Original work by: Santosh Rastapur 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |   1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   4 +
 drivers/net/ethernet/chelsio/cxgb4/sge.c| 218 
 3 files changed, 186 insertions(+), 37 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index f56e893..baa67d3 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -1314,6 +1314,7 @@ void t4_sge_start(struct adapter *adap);
 void t4_sge_stop(struct adapter *adap);
 void cxgb4_set_ethtool_ops(struct net_device *netdev);
 int cxgb4_write_rss(const struct port_info *pi, const u16 *queues);
+enum cpl_tx_tnl_lso_type cxgb_encap_offload_supported(struct sk_buff *skb);
 extern int dbfifo_int_thresh;
 
 #define for_each_port(adapter, iter) \
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 8097762..d0e08f6 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5210,6 +5210,10 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
NETIF_F_RXCSUM | NETIF_F_RXHASH |
NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
NETIF_F_HW_TC;
+
+   if (CHELSIO_CHIP_VERSION(chip) > CHELSIO_T5)
+   netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
+
if (highdma)
netdev->hw_features |= NETIF_F_HIGHDMA;
netdev->features |= netdev->hw_features;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 922f2f9..eab781f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -770,12 +770,19 @@ static inline unsigned int flits_to_desc(unsigned int n)
  * Returns whether an Ethernet packet is small enough to fit as
  * immediate data. Return value corresponds to headroom required.
  */
-static inline int is_eth_imm(const struct sk_buff *skb)
+static inline int is_eth_imm(const struct sk_buff *skb, unsigned int chip_ver)
 {
-   int hdrlen = skb_shinfo(skb)->gso_size ?
-   sizeof(struct cpl_tx_pkt_lso_core) : 0;
+   int hdrlen = 0;
 
-   hdrlen += sizeof(struct cpl_tx_pkt);
+   if (skb->encapsulation && skb_shinfo(skb)->gso_size &&
+   chip_ver > CHELSIO_T5) {
+   hdrlen = sizeof(struct cpl_tx_tnl_lso);
+   hdrlen += sizeof(struct cpl_tx_pkt_core);
+   } else {
+   hdrlen = skb_shinfo(skb)->gso_size ?
+sizeof(struct cpl_tx_pkt_lso_core) : 0;
+   hdrlen += sizeof(struct cpl_tx_pkt);
+   }
if (skb->len <= MAX_IMM_TX_PKT_LEN - hdrlen)
return hdrlen;
return 0;
@@ -788,10 +795,11 @@ static inline int is_eth_imm(const struct sk_buff *skb)
  * Returns the number of flits needed for a Tx WR for the given Ethernet
  * packet, including the needed WR and CPL headers.
  */
-static inline unsigned int calc_tx_flits(const struct sk_buff *skb)
+static inline unsigned int calc_tx_flits(const struct sk_buff *skb,
+unsigned int chip_ver)
 {
unsigned int flits;
-   int hdrlen = is_eth_imm(skb);
+   int hdrlen = is_eth_imm(skb, chip_ver);
 
/* If the skb is small enough, we can pump it out as a work request
 * with only immediate data.  In that case we just have to have the
@@ -810,13 +818,20 @@ static inline unsigned int calc_tx_flits(const struct 
sk_buff *skb)
 * with an embedded TX Packet Write CPL message.
 */
flits = sgl_len(skb_shinfo(skb)->nr_frags + 1);
-   if (skb_shinfo(skb)->gso_size)
-   flits += (sizeof(struct fw_eth_tx_pkt_wr) +
- sizeof(struct cpl_tx_pkt_lso_core) +
- sizeof(struct cpl_tx_pkt_core)) / sizeof(__be64);
-   else
+   if (skb_shinfo(skb)->gso_size) {
+   if (skb->encapsulation && chip_ver > CHELSIO_T5)
+   hdrlen = sizeof(struct fw_eth_tx_pkt_wr) +
+sizeof(struct cpl_tx_tnl_lso);
+   else
+   hdrlen = sizeof(struct fw_eth_tx_pkt_wr) +
+sizeof(struct cpl_tx_pkt_lso_core);
+
+   hdrlen += sizeof(struct cpl_tx_pkt_core);
+   flits += (hdrlen / sizeof(__be64));
+   } else {
flits += (sizeof(struct fw_eth_tx_pkt_wr) +
  sizeof(struct cpl_tx_pkt_core)) / sizeof(__be64);
+   }

[PATCH net-next 2/4] cxgb4: implement udp tunnel callbacks

2018-01-10 Thread Ganesh Goudar
Implement ndo_udp_tunnel_add and ndo_udp_tunnel_del
to support vxlan tunnelling.

Original work by: Santosh Rastapur 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |  15 +++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 130 
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c  | 106 +++
 3 files changed, 251 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 1ff7182..f56e893 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -825,6 +825,10 @@ struct mbox_list {
struct list_head list;
 };
 
+struct mps_encap_entry {
+   atomic_t refcnt;
+};
+
 struct adapter {
void __iomem *regs;
void __iomem *bar2;
@@ -839,6 +843,8 @@ struct adapter {
enum chip_type chip;
 
int msg_enable;
+   __be16 vxlan_port;
+   u8 vxlan_port_cnt;
 
struct adapter_params params;
struct cxgb4_virt_res vres;
@@ -868,7 +874,10 @@ struct adapter {
unsigned int clipt_start;
unsigned int clipt_end;
struct clip_tbl *clipt;
+   unsigned int rawf_start;
+   unsigned int rawf_cnt;
struct smt_data *smt;
+   struct mps_encap_entry *mps_encap;
struct cxgb4_uld_info *uld;
void *uld_handle[CXGB4_ULD_MAX];
unsigned int num_uld;
@@ -1637,6 +1646,12 @@ int t4_free_vi(struct adapter *adap, unsigned int mbox,
 int t4_set_rxmode(struct adapter *adap, unsigned int mbox, unsigned int viid,
int mtu, int promisc, int all_multi, int bcast, int vlanex,
bool sleep_ok);
+int t4_free_raw_mac_filt(struct adapter *adap, unsigned int viid,
+const u8 *addr, const u8 *mask, unsigned int idx,
+u8 lookup_type, u8 port_id, bool sleep_ok);
+int t4_alloc_raw_mac_filt(struct adapter *adap, unsigned int viid,
+ const u8 *addr, const u8 *mask, unsigned int idx,
+ u8 lookup_type, u8 port_id, bool sleep_ok);
 int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox,
  unsigned int viid, bool free, unsigned int naddr,
  const u8 **addr, u16 *idx, u64 *hash, bool sleep_ok);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 87ac1e4..8097762 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -65,6 +65,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "cxgb4.h"
 #include "cxgb4_filter.h"
@@ -2987,6 +2988,133 @@ static int cxgb_setup_tc(struct net_device *dev, enum 
tc_setup_type type,
}
 }
 
+static void cxgb_del_udp_tunnel(struct net_device *netdev,
+   struct udp_tunnel_info *ti)
+{
+   struct port_info *pi = netdev_priv(netdev);
+   struct adapter *adapter = pi->adapter;
+   unsigned int chip_ver = CHELSIO_CHIP_VERSION(adapter->params.chip);
+   u8 match_all_mac[] = { 0, 0, 0, 0, 0, 0 };
+   int ret = 0, i;
+
+   if (chip_ver < CHELSIO_T6)
+   return;
+
+   switch (ti->type) {
+   case UDP_TUNNEL_TYPE_VXLAN:
+   if (!adapter->vxlan_port_cnt ||
+   adapter->vxlan_port != ti->port)
+   return; /* Invalid VxLAN destination port */
+
+   adapter->vxlan_port_cnt--;
+   if (adapter->vxlan_port_cnt)
+   return;
+
+   adapter->vxlan_port = 0;
+   t4_write_reg(adapter, MPS_RX_VXLAN_TYPE_A, 0);
+   break;
+   default:
+   return;
+   }
+
+   /* Matchall mac entries can be deleted only after all tunnel ports
+* are brought down or removed.
+*/
+   if (!adapter->rawf_cnt)
+   return;
+   for_each_port(adapter, i) {
+   pi = adap2pinfo(adapter, i);
+   ret = t4_free_raw_mac_filt(adapter, pi->viid,
+  match_all_mac, match_all_mac,
+  adapter->rawf_start +
+   pi->port_id,
+  1, pi->port_id, true);
+   if (ret < 0) {
+   netdev_info(netdev, "Failed to free mac filter entry, 
for port %d\n",
+   i);
+   return;
+   }
+   atomic_dec(&adapter->mps_encap[adapter->rawf_start +
+  pi->port_id].refcnt);
+   }
+}
+
+static void cxgb_add_udp_tunnel(struct net_device *netdev,
+   struct udp_tunnel_info *ti)
+{
+   struct port_info *pi = netdev

[PATCH net-next 1/4] cxgb4: add data structures to support vxlan

2018-01-10 Thread Ganesh Goudar
Add data structures and macros to be used in vxlan
offload.

Original work by: Santosh Rastapur 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_msg.h   | 164 ++
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h  |  17 +++
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h |  27 +
 3 files changed, 208 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_msg.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4_msg.h
index 7e12f24..d0db442 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_msg.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_msg.h
@@ -107,6 +107,7 @@ enum {
 
CPL_FW6_MSG   = 0xE0,
CPL_FW6_PLD   = 0xE1,
+   CPL_TX_TNL_LSO= 0xEC,
CPL_TX_PKT_LSO= 0xED,
CPL_TX_PKT_XT = 0xEE,
 
@@ -1479,6 +1480,169 @@ struct ulp_txpkt {
 #define ULP_TXPKT_RO_V(x) ((x) << ULP_TXPKT_RO_S)
 #define ULP_TXPKT_RO_F ULP_TXPKT_RO_V(1U)
 
+enum cpl_tx_tnl_lso_type {
+   TX_TNL_TYPE_OPAQUE,
+   TX_TNL_TYPE_NVGRE,
+   TX_TNL_TYPE_VXLAN,
+   TX_TNL_TYPE_GENEVE,
+};
+
+struct cpl_tx_tnl_lso {
+   __be32 op_to_IpIdSplitOut;
+   __be16 IpIdOffsetOut;
+   __be16 UdpLenSetOut_to_TnlHdrLen;
+   __be64 r1;
+   __be32 Flow_to_TcpHdrLen;
+   __be16 IpIdOffset;
+   __be16 IpIdSplit_to_Mss;
+   __be32 TCPSeqOffset;
+   __be32 EthLenOffset_Size;
+   /* encapsulated CPL (TX_PKT_XT) follows here */
+};
+
+#define CPL_TX_TNL_LSO_OPCODE_S24
+#define CPL_TX_TNL_LSO_OPCODE_M0xff
+#define CPL_TX_TNL_LSO_OPCODE_V(x)  ((x) << CPL_TX_TNL_LSO_OPCODE_S)
+#define CPL_TX_TNL_LSO_OPCODE_G(x)  \
+   (((x) >> CPL_TX_TNL_LSO_OPCODE_S) & CPL_TX_TNL_LSO_OPCODE_M)
+
+#define CPL_TX_TNL_LSO_FIRST_S 23
+#define CPL_TX_TNL_LSO_FIRST_M 0x1
+#define CPL_TX_TNL_LSO_FIRST_V(x)  ((x) << CPL_TX_TNL_LSO_FIRST_S)
+#define CPL_TX_TNL_LSO_FIRST_G(x)  \
+   (((x) >> CPL_TX_TNL_LSO_FIRST_S) & CPL_TX_TNL_LSO_FIRST_M)
+#define CPL_TX_TNL_LSO_FIRST_F CPL_TX_TNL_LSO_FIRST_V(1U)
+
+#define CPL_TX_TNL_LSO_LAST_S  22
+#define CPL_TX_TNL_LSO_LAST_M  0x1
+#define CPL_TX_TNL_LSO_LAST_V(x)   ((x) << CPL_TX_TNL_LSO_LAST_S)
+#define CPL_TX_TNL_LSO_LAST_G(x)   \
+   (((x) >> CPL_TX_TNL_LSO_LAST_S) & CPL_TX_TNL_LSO_LAST_M)
+#define CPL_TX_TNL_LSO_LAST_F  CPL_TX_TNL_LSO_LAST_V(1U)
+
+#define CPL_TX_TNL_LSO_ETHHDRLENXOUT_S 21
+#define CPL_TX_TNL_LSO_ETHHDRLENXOUT_M 0x1
+#define CPL_TX_TNL_LSO_ETHHDRLENXOUT_V(x) \
+   ((x) << CPL_TX_TNL_LSO_ETHHDRLENXOUT_S)
+#define CPL_TX_TNL_LSO_ETHHDRLENXOUT_G(x) \
+   (((x) >> CPL_TX_TNL_LSO_ETHHDRLENXOUT_S) & \
+CPL_TX_TNL_LSO_ETHHDRLENXOUT_M)
+#define CPL_TX_TNL_LSO_ETHHDRLENXOUT_F CPL_TX_TNL_LSO_ETHHDRLENXOUT_V(1U)
+
+#define CPL_TX_TNL_LSO_IPV6OUT_S   20
+#define CPL_TX_TNL_LSO_IPV6OUT_M   0x1
+#define CPL_TX_TNL_LSO_IPV6OUT_V(x)((x) << CPL_TX_TNL_LSO_IPV6OUT_S)
+#define CPL_TX_TNL_LSO_IPV6OUT_G(x)\
+   (((x) >> CPL_TX_TNL_LSO_IPV6OUT_S) & CPL_TX_TNL_LSO_IPV6OUT_M)
+#define CPL_TX_TNL_LSO_IPV6OUT_FCPL_TX_TNL_LSO_IPV6OUT_V(1U)
+
+#define CPL_TX_TNL_LSO_ETHHDRLEN_S 16
+#define CPL_TX_TNL_LSO_ETHHDRLEN_M 0xf
+#define CPL_TX_TNL_LSO_ETHHDRLEN_V(x)  ((x) << CPL_TX_TNL_LSO_ETHHDRLEN_S)
+#define CPL_TX_TNL_LSO_ETHHDRLEN_G(x)  \
+   (((x) >> CPL_TX_TNL_LSO_ETHHDRLEN_S) & CPL_TX_TNL_LSO_ETHHDRLEN_M)
+
+#define CPL_TX_TNL_LSO_IPHDRLEN_S  4
+#define CPL_TX_TNL_LSO_IPHDRLEN_M  0xfff
+#define CPL_TX_TNL_LSO_IPHDRLEN_V(x)   ((x) << CPL_TX_TNL_LSO_IPHDRLEN_S)
+#define CPL_TX_TNL_LSO_IPHDRLEN_G(x)\
+   (((x) >> CPL_TX_TNL_LSO_IPHDRLEN_S) & CPL_TX_TNL_LSO_IPHDRLEN_M)
+
+#define CPL_TX_TNL_LSO_TCPHDRLEN_S 0
+#define CPL_TX_TNL_LSO_TCPHDRLEN_M 0xf
+#define CPL_TX_TNL_LSO_TCPHDRLEN_V(x)  ((x) << CPL_TX_TNL_LSO_TCPHDRLEN_S)
+#define CPL_TX_TNL_LSO_TCPHDRLEN_G(x)   \
+   (((x) >> CPL_TX_TNL_LSO_TCPHDRLEN_S) & CPL_TX_TNL_LSO_TCPHDRLEN_M)
+
+#define CPL_TX_TNL_LSO_MSS_S0
+#define CPL_TX_TNL_LSO_MSS_M0x3fff
+#define CPL_TX_TNL_LSO_MSS_V(x) ((x) << CPL_TX_TNL_LSO_MSS_S)
+#define CPL_TX_TNL_LSO_MSS_G(x) \
+   (((x) >> CPL_TX_TNL_LSO_MSS_S) & CPL_TX_TNL_LSO_MSS_M)
+
+#define CPL_TX_TNL_LSO_SIZE_S  0
+#define CPL_TX_TNL_LSO_SIZE_M  0xfff
+#define CPL_TX_TNL_LSO_SIZE_V(x)   ((x) << CPL_TX_TNL_LSO_SIZE_S)
+#define CPL_TX_TNL_LSO_SIZE_G(x)   \
+   (((x) >> CPL_TX_TNL_LSO_SIZE_S) & CPL_TX_TNL_LSO_SIZE_M)
+
+#define CPL_TX_TNL_LSO_ETHHDRLENOUT_S   16
+#define CPL_TX_TNL_LSO_ETHHDRLENOUT_M   0xf
+#define CPL_TX_TNL_LSO_ETHHDRLENOUT_V(x) \
+   ((x) << CPL_TX_TNL_LSO_ETHHDRLENOUT_S)
+#define CPL_TX_TNL_LSO_ETHHDRLENOUT_G(x) \
+   (((x) >> CPL_TX_TNL_LSO_

[PATCH net-next] cxgb4vf: Fix SGE FL buffer initialization logic for 64K pages

2018-01-09 Thread Ganesh Goudar
From: Arjun Vynipadath 

We'd come in with SGE_FL_BUFFER_SIZE[0] and [1] both equal to 64KB and
the extant logic would flag that as an error. This was already fixed in
cxgb4 driver with "92ddcc7 cxgb4: Fix some small bugs in
t4_sge_init_soft() when our Page Size is 64KB".

Original Work by: Casey Leedom 
Signed-off-by: Arjun Vynipadath 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c | 23 +--
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
index 14d7e67..129b914 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
@@ -2619,8 +2619,8 @@ void t4vf_sge_stop(struct adapter *adapter)
 int t4vf_sge_init(struct adapter *adapter)
 {
struct sge_params *sge_params = &adapter->params.sge;
-   u32 fl0 = sge_params->sge_fl_buffer_size[0];
-   u32 fl1 = sge_params->sge_fl_buffer_size[1];
+   u32 fl_small_pg = sge_params->sge_fl_buffer_size[0];
+   u32 fl_large_pg = sge_params->sge_fl_buffer_size[1];
struct sge *s = &adapter->sge;
 
/*
@@ -2628,9 +2628,20 @@ int t4vf_sge_init(struct adapter *adapter)
 * the Physical Function Driver.  Ideally we should be able to deal
 * with _any_ configuration.  Practice is different ...
 */
-   if (fl0 != PAGE_SIZE || (fl1 != 0 && fl1 <= fl0)) {
+
+   /* We only bother using the Large Page logic if the Large Page Buffer
+* is larger than our Page Size Buffer.
+*/
+   if (fl_large_pg <= fl_small_pg)
+   fl_large_pg = 0;
+
+   /* The Page Size Buffer must be exactly equal to our Page Size and the
+* Large Page Size Buffer should be 0 (per above) or a power of 2.
+*/
+   if (fl_small_pg != PAGE_SIZE ||
+   (fl_large_pg & (fl_large_pg - 1)) != 0) {
dev_err(adapter->pdev_dev, "bad SGE FL buffer sizes [%d, %d]\n",
-   fl0, fl1);
+   fl_small_pg, fl_large_pg);
return -EINVAL;
}
if ((sge_params->sge_control & RXPKTCPLMODE_F) !=
@@ -2642,8 +2653,8 @@ int t4vf_sge_init(struct adapter *adapter)
/*
 * Now translate the adapter parameters into our internal forms.
 */
-   if (fl1)
-   s->fl_pg_order = ilog2(fl1) - PAGE_SHIFT;
+   if (fl_large_pg)
+   s->fl_pg_order = ilog2(fl_large_pg) - PAGE_SHIFT;
s->stat_len = ((sge_params->sge_control & EGRSTATUSPAGESIZE_F)
? 128 : 64);
s->pktshift = PKTSHIFT_G(sge_params->sge_control);
-- 
2.1.0



[PATCH net v2] cxgb4: Fix FW flash errors

2018-01-02 Thread Ganesh Goudar
From: Arjun Vynipadath 

commit 96ac18f14a5a ("cxgb4: Add support for new flash parts")
removed initialization of adapter->params.sf_fw_start causing issues
while flashing firmware to card. We no longer need sf_fw_start
in adapter->params as we already have macros defined for FW flash
addresses.

Fixes: 96ac18f14a5a ("cxgb4: Add support for new flash parts")
Signed-off-by: Arjun Vynipadath 
Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
V2: Corrected the commit log
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |  1 -
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 17 -
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 69d0b64..1ff7182 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -345,7 +345,6 @@ struct adapter_params {
 
unsigned int sf_size; /* serial flash size in bytes */
unsigned int sf_nsec; /* # of flash sectors */
-   unsigned int sf_fw_start; /* start of FW image in flash */
 
unsigned int fw_vers; /* firmware version */
unsigned int bs_vers; /* bootstrap version */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index f2a60e0..0e9f64a 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -2847,8 +2847,6 @@ enum {
SF_RD_DATA_FAST = 0xb,/* read flash */
SF_RD_ID= 0x9f,   /* read ID */
SF_ERASE_SECTOR = 0xd8,   /* erase sector */
-
-   FW_MAX_SIZE = 16 * SF_SEC_SIZE,
 };
 
 /**
@@ -3561,8 +3559,9 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, 
unsigned int size)
const __be32 *p = (const __be32 *)fw_data;
const struct fw_hdr *hdr = (const struct fw_hdr *)fw_data;
unsigned int sf_sec_size = adap->params.sf_size / adap->params.sf_nsec;
-   unsigned int fw_img_start = adap->params.sf_fw_start;
-   unsigned int fw_start_sec = fw_img_start / sf_sec_size;
+   unsigned int fw_start_sec = FLASH_FW_START_SEC;
+   unsigned int fw_size = FLASH_FW_MAX_SIZE;
+   unsigned int fw_start = FLASH_FW_START;
 
if (!size) {
dev_err(adap->pdev_dev, "FW image has no data\n");
@@ -3578,9 +3577,9 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, 
unsigned int size)
"FW image size differs from size in FW header\n");
return -EINVAL;
}
-   if (size > FW_MAX_SIZE) {
+   if (size > fw_size) {
dev_err(adap->pdev_dev, "FW image too large, max is %u bytes\n",
-   FW_MAX_SIZE);
+   fw_size);
return -EFBIG;
}
if (!t4_fw_matches_chip(adap, hdr))
@@ -3607,11 +3606,11 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, 
unsigned int size)
 */
memcpy(first_page, fw_data, SF_PAGE_SIZE);
((struct fw_hdr *)first_page)->fw_ver = cpu_to_be32(0x);
-   ret = t4_write_flash(adap, fw_img_start, SF_PAGE_SIZE, first_page);
+   ret = t4_write_flash(adap, fw_start, SF_PAGE_SIZE, first_page);
if (ret)
goto out;
 
-   addr = fw_img_start;
+   addr = fw_start;
for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) {
addr += SF_PAGE_SIZE;
fw_data += SF_PAGE_SIZE;
@@ -3621,7 +3620,7 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, 
unsigned int size)
}
 
ret = t4_write_flash(adap,
-fw_img_start + offsetof(struct fw_hdr, fw_ver),
+fw_start + offsetof(struct fw_hdr, fw_ver),
 sizeof(hdr->fw_ver), (const u8 *)&hdr->fw_ver);
 out:
if (ret)
-- 
2.1.0



[PATCH net] cxgb4: Fix FW flash errors

2017-12-29 Thread Ganesh Goudar
From: Arjun Vynipadath 

Initialize adapter->params.sf_fw_start to fix firmware flash
issues. Use existing macros defined for FW flash addresses.

Fixes: 96ac18f14a5a ("cxgb4: Add support for new flash parts")
Signed-off-by: Arjun Vynipadath 
Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |  1 -
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 17 -
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 6f9fa6e..d8424ed 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -344,7 +344,6 @@ struct adapter_params {
 
unsigned int sf_size; /* serial flash size in bytes */
unsigned int sf_nsec; /* # of flash sectors */
-   unsigned int sf_fw_start; /* start of FW image in flash */
 
unsigned int fw_vers; /* firmware version */
unsigned int bs_vers; /* bootstrap version */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index f63210f..375ef86 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -2844,8 +2844,6 @@ enum {
SF_RD_DATA_FAST = 0xb,/* read flash */
SF_RD_ID= 0x9f,   /* read ID */
SF_ERASE_SECTOR = 0xd8,   /* erase sector */
-
-   FW_MAX_SIZE = 16 * SF_SEC_SIZE,
 };
 
 /**
@@ -3558,8 +3556,9 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, 
unsigned int size)
const __be32 *p = (const __be32 *)fw_data;
const struct fw_hdr *hdr = (const struct fw_hdr *)fw_data;
unsigned int sf_sec_size = adap->params.sf_size / adap->params.sf_nsec;
-   unsigned int fw_img_start = adap->params.sf_fw_start;
-   unsigned int fw_start_sec = fw_img_start / sf_sec_size;
+   unsigned int fw_start_sec = FLASH_FW_START_SEC;
+   unsigned int fw_size = FLASH_FW_MAX_SIZE;
+   unsigned int fw_start = FLASH_FW_START;
 
if (!size) {
dev_err(adap->pdev_dev, "FW image has no data\n");
@@ -3575,9 +3574,9 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, 
unsigned int size)
"FW image size differs from size in FW header\n");
return -EINVAL;
}
-   if (size > FW_MAX_SIZE) {
+   if (size > fw_size) {
dev_err(adap->pdev_dev, "FW image too large, max is %u bytes\n",
-   FW_MAX_SIZE);
+   fw_size);
return -EFBIG;
}
if (!t4_fw_matches_chip(adap, hdr))
@@ -3604,11 +3603,11 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, 
unsigned int size)
 */
memcpy(first_page, fw_data, SF_PAGE_SIZE);
((struct fw_hdr *)first_page)->fw_ver = cpu_to_be32(0x);
-   ret = t4_write_flash(adap, fw_img_start, SF_PAGE_SIZE, first_page);
+   ret = t4_write_flash(adap, fw_start, SF_PAGE_SIZE, first_page);
if (ret)
goto out;
 
-   addr = fw_img_start;
+   addr = fw_start;
for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) {
addr += SF_PAGE_SIZE;
fw_data += SF_PAGE_SIZE;
@@ -3618,7 +3617,7 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, 
unsigned int size)
}
 
ret = t4_write_flash(adap,
-fw_img_start + offsetof(struct fw_hdr, fw_ver),
+fw_start + offsetof(struct fw_hdr, fw_ver),
 sizeof(hdr->fw_ver), (const u8 *)&hdr->fw_ver);
 out:
if (ret)
-- 
2.1.0



[PATCH net-next] cxgb4: Check alignment constraint for T6

2017-12-28 Thread Ganesh Goudar
Update the check for setting  IPV4 filters and align filter_id
to multiple of 2, only for IPv6 filters in case of T6.

Signed-off-by: Arjun Vynipadath 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
index 5980f30..29178cf 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
@@ -1189,6 +1189,7 @@ int __cxgb4_set_filter(struct net_device *dev, int 
filter_id,
   struct filter_ctx *ctx)
 {
struct adapter *adapter = netdev2adap(dev);
+   unsigned int chip_ver = CHELSIO_CHIP_VERSION(adapter->params.chip);
unsigned int max_fidx, fidx;
struct filter_entry *f;
u32 iconf;
@@ -1225,12 +1226,18 @@ int __cxgb4_set_filter(struct net_device *dev, int 
filter_id,
 * insertion.
 */
if (fs->type == 0) { /* IPv4 */
-   /* If our IPv4 filter isn't being written to a
-* multiple of four filter index and there's an IPv6
-* filter at the multiple of 4 base slot, then we
-* prevent insertion.
+   /* For T6, If our IPv4 filter isn't being written to a
+* multiple of two filter index and there's an IPv6
+* filter at the multiple of 2 base slot, then we need
+* to delete that IPv6 filter ...
+* For adapters below T6, IPv6 filter occupies 4 entries.
+* Hence we need to delete the filter in multiple of 4 slot.
 */
-   fidx = filter_id & ~0x3;
+   if (chip_ver < CHELSIO_T6)
+   fidx = filter_id & ~0x3;
+   else
+   fidx = filter_id & ~0x1;
+
if (fidx != filter_id &&
adapter->tids.ftid_tab[fidx].fs.type) {
f = &adapter->tids.ftid_tab[fidx];
-- 
2.1.0



[PATCH net-next] cxgb4/cxgb4vf: support for XLAUI Port Type

2017-12-27 Thread Ganesh Goudar
Add support for new Backplane XLAUI port type.

Signed-off-by: Casey Leedom 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c  | 10 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c  |  1 +
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h   |  1 +
 drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 10 +-
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index 541419b..7852d98 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -517,7 +517,8 @@ static int from_fw_port_mod_type(enum fw_port_type 
port_type,
else
return PORT_OTHER;
} else if (port_type == FW_PORT_TYPE_KR4_100G ||
-  port_type == FW_PORT_TYPE_KR_SFP28) {
+  port_type == FW_PORT_TYPE_KR_SFP28 ||
+  port_type == FW_PORT_TYPE_KR_XLAUI) {
return PORT_NONE;
}
 
@@ -645,6 +646,13 @@ static void fw_caps_to_lmm(enum fw_port_type port_type,
FW_CAPS_TO_LMM(SPEED_25G, 25000baseKR_Full);
break;
 
+   case FW_PORT_TYPE_KR_XLAUI:
+   SET_LMM(Backplane);
+   FW_CAPS_TO_LMM(SPEED_1G, 1000baseKX_Full);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseKR_Full);
+   FW_CAPS_TO_LMM(SPEED_40G, 4baseKR4_Full);
+   break;
+
case FW_PORT_TYPE_CR2_QSFP:
SET_LMM(FIBRE);
SET_LMM(5baseSR2_Full);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 44930ca..f2a60e0 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -6084,6 +6084,7 @@ const char *t4_get_port_type_description(enum 
fw_port_type port_type)
"CR2_QSFP",
"SFP28",
"KR_SFP28",
+   "KR_XLAUI"
};
 
if (port_type < ARRAY_SIZE(port_type_description))
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
index 01f5a5e..427f252 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
@@ -2829,6 +2829,7 @@ enum fw_port_type {
FW_PORT_TYPE_CR2_QSFP,
FW_PORT_TYPE_SFP28,
FW_PORT_TYPE_KR_SFP28,
+   FW_PORT_TYPE_KR_XLAUI,
 
FW_PORT_TYPE_NONE = FW_PORT_CMD_PTYPE_M
 };
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c 
b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index b48361c..96f69f8 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -1229,7 +1229,8 @@ static int from_fw_port_mod_type(enum fw_port_type 
port_type,
else
return PORT_OTHER;
} else if (port_type == FW_PORT_TYPE_KR4_100G ||
-  port_type == FW_PORT_TYPE_KR_SFP28) {
+  port_type == FW_PORT_TYPE_KR_SFP28 ||
+  port_type == FW_PORT_TYPE_KR_XLAUI) {
return PORT_NONE;
}
 
@@ -1323,6 +1324,13 @@ static void fw_caps_to_lmm(enum fw_port_type port_type,
SET_LMM(25000baseKR_Full);
break;
 
+   case FW_PORT_TYPE_KR_XLAUI:
+   SET_LMM(Backplane);
+   FW_CAPS_TO_LMM(SPEED_1G, 1000baseKX_Full);
+   FW_CAPS_TO_LMM(SPEED_10G, 1baseKR_Full);
+   FW_CAPS_TO_LMM(SPEED_40G, 4baseKR4_Full);
+   break;
+
case FW_PORT_TYPE_CR2_QSFP:
SET_LMM(FIBRE);
SET_LMM(5baseSR2_Full);
-- 
2.1.0



[PATCH net-next] cxgb4: display VNI correctly

2017-12-27 Thread Ganesh Goudar
Fix incorrect VNI display in mps_tcam

Signed-off-by: Santosh Rastapur 
Signed-off-by: Ganesh Goudar 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index d3ced04..4ea76c1 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -1743,7 +1743,7 @@ static int mps_tcam_show(struct seq_file *seq, void *v)
 */
if (lookup_type && (lookup_type != DATALKPTYPE_M)) {
/* Inner header VNI */
-   vniy = ((data2 & DATAVIDH2_F) << 23) |
+   vniy = (data2 & DATAVIDH2_F) |
   (DATAVIDH1_G(data2) << 16) | VIDL_G(val);
dip_hit = data2 & DATADIPHIT_F;
} else {
@@ -1753,6 +1753,7 @@ static int mps_tcam_show(struct seq_file *seq, void *v)
port_num = DATAPORTNUM_G(data2);
 
/* Read tcamx. Change the control param */
+   vnix = 0;
ctl |= CTLXYBITSEL_V(1);
t4_write_reg(adap, MPS_CLS_TCAM_DATA2_CTL_A, ctl);
val = t4_read_reg(adap, MPS_CLS_TCAM_DATA1_A);
@@ -1761,7 +1762,7 @@ static int mps_tcam_show(struct seq_file *seq, void *v)
data2 = t4_read_reg(adap, MPS_CLS_TCAM_DATA2_CTL_A);
if (lookup_type && (lookup_type != DATALKPTYPE_M)) {
/* Inner header VNI mask */
-   vnix = ((data2 & DATAVIDH2_F) << 23) |
+   vnix = (data2 & DATAVIDH2_F) |
   (DATAVIDH1_G(data2) << 16) | VIDL_G(val);
}
} else {
@@ -1834,7 +1835,8 @@ static int mps_tcam_show(struct seq_file *seq, void *v)
   addr[1], addr[2], addr[3],
   addr[4], addr[5],
   (unsigned long long)mask,
-  vniy, vnix, dip_hit ? 'Y' : 'N',
+  vniy, (vnix | vniy),
+  dip_hit ? 'Y' : 'N',
   port_num,
   (cls_lo & T6_SRAM_VLD_F) ? 'Y' : 'N',
   PORTMAP_G(cls_hi),
-- 
2.1.0



  1   2   >