Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next 06/11] fjes: optimize timeout value
From: Taku Izumi @ 2016-04-11  8:10 UTC (permalink / raw)
  To: davem, netdev; +Cc: Taku Izumi
In-Reply-To: <1460362136-14968-1-git-send-email-izumi.taku@jp.fujitsu.com>

This patch optimizes the following timeout value.
  - FJES_DEVICE_RESET_TIMEOUT
  - FJES_COMMAND_REQ_TIMEOUT
  - FJES_COMMAND_REQ_BUFF_TIMEOUT

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
---
 drivers/net/fjes/fjes_hw.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/fjes/fjes_hw.h b/drivers/net/fjes/fjes_hw.h
index 41fe418..a1c3d65 100644
--- a/drivers/net/fjes/fjes_hw.h
+++ b/drivers/net/fjes/fjes_hw.h
@@ -34,9 +34,9 @@ struct fjes_hw;
 #define EP_BUFFER_INFO_SIZE 4096
 #define EP_TRACE_PAGE_SIZE 4096
 
-#define FJES_DEVICE_RESET_TIMEOUT  ((17 + 1) * 3) /* sec */
-#define FJES_COMMAND_REQ_TIMEOUT  (5 + 1) /* sec */
-#define FJES_COMMAND_REQ_BUFF_TIMEOUT	(8 * 3) /* sec */
+#define FJES_DEVICE_RESET_TIMEOUT  ((17 + 1) * 3 * 8) /* sec */
+#define FJES_COMMAND_REQ_TIMEOUT  ((5 + 1) * 3 * 8) /* sec */
+#define FJES_COMMAND_REQ_BUFF_TIMEOUT	(60 * 3) /* sec */
 #define FJES_COMMAND_EPSTOP_WAIT_TIMEOUT	(1) /* sec */
 
 #define FJES_CMD_REQ_ERR_INFO_PARAM  (0x0001)
-- 
2.4.3

^ permalink raw reply related

* [PATCH net-next 07/11] fjes: fix incorrect statistics information in fjes_xmit_frame()
From: Taku Izumi @ 2016-04-11  8:10 UTC (permalink / raw)
  To: davem, netdev; +Cc: Taku Izumi
In-Reply-To: <1460362136-14968-1-git-send-email-izumi.taku@jp.fujitsu.com>

There are bugs of acounting statistics in fjes_xmit_frame().
Accounting self stats is wrong. accounting stats of other
EPs to be transmitted  is right.
This patch fixes this bug.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
---
 drivers/net/fjes/fjes_main.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index f2327d8..e785d89 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -668,7 +668,7 @@ fjes_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 				&adapter->hw.ep_shm_info[dest_epid].rx, 0)) {
 			/* version is NOT 0 */
 			adapter->stats64.tx_carrier_errors += 1;
-			hw->ep_shm_info[my_epid].net_stats
+			hw->ep_shm_info[dest_epid].net_stats
 						.tx_carrier_errors += 1;
 			hw->ep_shm_info[dest_epid].ep_stats
 						  .tx_dropped_version_mismatch += 1;
@@ -678,9 +678,9 @@ fjes_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 				&adapter->hw.ep_shm_info[dest_epid].rx,
 				netdev->mtu)) {
 			adapter->stats64.tx_dropped += 1;
-			hw->ep_shm_info[my_epid].net_stats.tx_dropped += 1;
+			hw->ep_shm_info[dest_epid].net_stats.tx_dropped += 1;
 			adapter->stats64.tx_errors += 1;
-			hw->ep_shm_info[my_epid].net_stats.tx_errors += 1;
+			hw->ep_shm_info[dest_epid].net_stats.tx_errors += 1;
 			hw->ep_shm_info[dest_epid].ep_stats
 						  .tx_dropped_buffer_size_discrepancy += 1;
 
@@ -715,10 +715,10 @@ fjes_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 					    (long)adapter->tx_start_jiffies) >=
 					    FJES_TX_RETRY_TIMEOUT) {
 					adapter->stats64.tx_fifo_errors += 1;
-					hw->ep_shm_info[my_epid].net_stats
+					hw->ep_shm_info[dest_epid].net_stats
 								.tx_fifo_errors += 1;
 					adapter->stats64.tx_errors += 1;
-					hw->ep_shm_info[my_epid].net_stats
+					hw->ep_shm_info[dest_epid].net_stats
 								.tx_errors += 1;
 
 					ret = NETDEV_TX_OK;
@@ -737,10 +737,10 @@ fjes_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 			} else {
 				if (!is_multi) {
 					adapter->stats64.tx_packets += 1;
-					hw->ep_shm_info[my_epid].net_stats
+					hw->ep_shm_info[dest_epid].net_stats
 								.tx_packets += 1;
 					adapter->stats64.tx_bytes += len;
-					hw->ep_shm_info[my_epid].net_stats
+					hw->ep_shm_info[dest_epid].net_stats
 								.tx_bytes += len;
 				}
 
-- 
2.4.3

^ permalink raw reply related

* [PATCH net-next 05/11] fjes: show EP stats at statistics file in debugfs
From: Taku Izumi @ 2016-04-11  8:10 UTC (permalink / raw)
  To: davem, netdev; +Cc: Taku Izumi
In-Reply-To: <1460362136-14968-1-git-send-email-izumi.taku@jp.fujitsu.com>

This patch enriches information in
/sys/kernel/debug/fjes/fjes.N/statistics file.
By applying this patch, each EP's stats information
are displayed in this file.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
---
 drivers/net/fjes/fjes_debugfs.c | 27 ++++++++++++++++++++++++
 drivers/net/fjes/fjes_hw.c      |  9 ++++++++
 drivers/net/fjes/fjes_hw.h      | 18 ++++++++++++++++
 drivers/net/fjes/fjes_main.c    | 46 +++++++++++++++++++++++++++++++++++++----
 4 files changed, 96 insertions(+), 4 deletions(-)

diff --git a/drivers/net/fjes/fjes_debugfs.c b/drivers/net/fjes/fjes_debugfs.c
index b0807c2..fc6cfa6 100644
--- a/drivers/net/fjes/fjes_debugfs.c
+++ b/drivers/net/fjes/fjes_debugfs.c
@@ -81,6 +81,33 @@ static int fjes_dbg_stats_show(struct seq_file *m, void *v)
 	FJES_DEBUGFS_NET_STATS_ENTRY(rx_compressed);
 	FJES_DEBUGFS_NET_STATS_ENTRY(tx_compressed);
 
+#define FJES_DEBUGFS_EP_STATS_ENTRY(X) do {				\
+	seq_printf(m, "%-41s", #X);					\
+	for (epidx = 0; epidx < max_epid; epidx++) {			\
+		if (epidx == my_epid)					\
+			seq_printf(m, "          -");			\
+		else							\
+			seq_printf(m, " %10llu",			\
+				   hw->ep_shm_info[epidx].ep_stats.X);	\
+	}								\
+	seq_printf(m, "\n");						\
+} while (0)
+
+	FJES_DEBUGFS_EP_STATS_ENTRY(command_register_buffer_executed);
+	FJES_DEBUGFS_EP_STATS_ENTRY(command_unregister_buffer_executed);
+	FJES_DEBUGFS_EP_STATS_ENTRY(send_interrupts_rx);
+	FJES_DEBUGFS_EP_STATS_ENTRY(send_interrupts_unshare);
+	FJES_DEBUGFS_EP_STATS_ENTRY(send_interrupts_zoneupdate);
+	FJES_DEBUGFS_EP_STATS_ENTRY(receive_interrupts_rx);
+	FJES_DEBUGFS_EP_STATS_ENTRY(receive_interrupts_unshare);
+	FJES_DEBUGFS_EP_STATS_ENTRY(receive_interrupts_stop);
+	FJES_DEBUGFS_EP_STATS_ENTRY(receive_interrupts_zoneupdate);
+	FJES_DEBUGFS_EP_STATS_ENTRY(tx_buffer_full);
+	FJES_DEBUGFS_EP_STATS_ENTRY(tx_dropped_not_shared);
+	FJES_DEBUGFS_EP_STATS_ENTRY(tx_dropped_version_mismatch);
+	FJES_DEBUGFS_EP_STATS_ENTRY(tx_dropped_buffer_size_discrepancy);
+	FJES_DEBUGFS_EP_STATS_ENTRY(tx_dropped_vlan_id_mismatch);
+
 	return 0;
 }
 
diff --git a/drivers/net/fjes/fjes_hw.c b/drivers/net/fjes/fjes_hw.c
index 0b0795e..b2b11c3 100644
--- a/drivers/net/fjes/fjes_hw.c
+++ b/drivers/net/fjes/fjes_hw.c
@@ -745,6 +745,7 @@ void fjes_hw_raise_epstop(struct fjes_hw *hw)
 		case EP_PARTNER_SHARED:
 			fjes_hw_raise_interrupt(hw, epidx,
 						REG_ICTL_MASK_TXRX_STOP_REQ);
+			hw->ep_shm_info[epidx].ep_stats.send_interrupts_unshare += 1;
 			break;
 		default:
 			break;
@@ -1046,6 +1047,9 @@ static void fjes_hw_update_zone_task(struct work_struct *work)
 				break;
 			}
 			mutex_unlock(&hw->hw_info.lock);
+
+			hw->ep_shm_info[epidx].ep_stats
+					      .command_register_buffer_executed += 1;
 		}
 
 		if (test_bit(epidx, &unshare_bit)) {
@@ -1069,6 +1073,9 @@ static void fjes_hw_update_zone_task(struct work_struct *work)
 
 			mutex_unlock(&hw->hw_info.lock);
 
+			hw->ep_shm_info[epidx].ep_stats
+					      .command_unregister_buffer_executed += 1;
+
 			if (ret == 0)
 				fjes_hw_setup_epbuf(
 					&hw->ep_shm_info[epidx].tx,
@@ -1078,6 +1085,8 @@ static void fjes_hw_update_zone_task(struct work_struct *work)
 		if (test_bit(epidx, &irq_bit)) {
 			fjes_hw_raise_interrupt(hw, epidx,
 						REG_ICTL_MASK_TXRX_STOP_REQ);
+			hw->ep_shm_info[epidx].ep_stats
+					      .send_interrupts_unshare += 1;
 
 			set_bit(epidx, &hw->txrx_stop_req_bit);
 			hw->ep_shm_info[epidx].tx.
diff --git a/drivers/net/fjes/fjes_hw.h b/drivers/net/fjes/fjes_hw.h
index 38be7d9..41fe418 100644
--- a/drivers/net/fjes/fjes_hw.h
+++ b/drivers/net/fjes/fjes_hw.h
@@ -235,6 +235,23 @@ union ep_buffer_info {
 
 };
 
+struct fjes_drv_ep_stats {
+	u64 command_register_buffer_executed;
+	u64 command_unregister_buffer_executed;
+	u64 send_interrupts_rx;
+	u64 send_interrupts_unshare;
+	u64 send_interrupts_zoneupdate;
+	u64 receive_interrupts_rx;
+	u64 receive_interrupts_unshare;
+	u64 receive_interrupts_stop;
+	u64 receive_interrupts_zoneupdate;
+	u64 tx_buffer_full;
+	u64 tx_dropped_not_shared;
+	u64 tx_dropped_version_mismatch;
+	u64 tx_dropped_buffer_size_discrepancy;
+	u64 tx_dropped_vlan_id_mismatch;
+};
+
 /* buffer pair for Extended Partition */
 struct ep_share_mem_info {
 	struct epbuf_handler {
@@ -245,6 +262,7 @@ struct ep_share_mem_info {
 	} tx, rx;
 
 	struct rtnl_link_stats64 net_stats;
+	struct fjes_drv_ep_stats ep_stats;
 
 	u16 tx_status_work;
 
diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index 7595415..f2327d8 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -363,6 +363,8 @@ static int fjes_setup_resources(struct fjes_adapter *adapter)
 		     FJES_ZONING_STATUS_ENABLE)) {
 			fjes_hw_raise_interrupt(hw, epidx,
 						REG_ICTL_MASK_INFO_UPDATE);
+			hw->ep_shm_info[epidx].ep_stats
+					      .send_interrupts_zoneupdate += 1;
 		}
 	}
 
@@ -392,6 +394,9 @@ static int fjes_setup_resources(struct fjes_adapter *adapter)
 				adapter->force_reset = true;
 				return result;
 			}
+
+			hw->ep_shm_info[epidx].ep_stats
+					      .command_register_buffer_executed += 1;
 		}
 	}
 
@@ -419,6 +424,9 @@ static void fjes_free_resources(struct fjes_adapter *adapter)
 		if (result)
 			reset_flag = true;
 
+		hw->ep_shm_info[epidx].ep_stats
+				      .command_unregister_buffer_executed += 1;
+
 		buf_pair = &hw->ep_shm_info[epidx];
 
 		fjes_hw_setup_epbuf(&buf_pair->tx,
@@ -555,6 +563,7 @@ static void fjes_raise_intr_rxdata_task(struct work_struct *work)
 		    !(hw->ep_shm_info[epid].rx.info->v1i.rx_status)) {
 			fjes_hw_raise_interrupt(hw, epid,
 						REG_ICTL_MASK_RX_DATA);
+			hw->ep_shm_info[epid].ep_stats.send_interrupts_rx += 1;
 		}
 	}
 
@@ -651,6 +660,9 @@ fjes_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 
 		pstatus = fjes_hw_get_partner_ep_status(hw, dest_epid);
 		if (pstatus != EP_PARTNER_SHARED) {
+			if (!is_multi)
+				hw->ep_shm_info[dest_epid].ep_stats
+							  .tx_dropped_not_shared += 1;
 			ret = NETDEV_TX_OK;
 		} else if (!fjes_hw_check_epbuf_version(
 				&adapter->hw.ep_shm_info[dest_epid].rx, 0)) {
@@ -658,6 +670,8 @@ fjes_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 			adapter->stats64.tx_carrier_errors += 1;
 			hw->ep_shm_info[my_epid].net_stats
 						.tx_carrier_errors += 1;
+			hw->ep_shm_info[dest_epid].ep_stats
+						  .tx_dropped_version_mismatch += 1;
 
 			ret = NETDEV_TX_OK;
 		} else if (!fjes_hw_check_mtu(
@@ -667,12 +681,16 @@ fjes_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 			hw->ep_shm_info[my_epid].net_stats.tx_dropped += 1;
 			adapter->stats64.tx_errors += 1;
 			hw->ep_shm_info[my_epid].net_stats.tx_errors += 1;
+			hw->ep_shm_info[dest_epid].ep_stats
+						  .tx_dropped_buffer_size_discrepancy += 1;
 
 			ret = NETDEV_TX_OK;
 		} else if (vlan &&
 			   !fjes_hw_check_vlan_id(
 				&adapter->hw.ep_shm_info[dest_epid].rx,
 				vlan_id)) {
+			hw->ep_shm_info[dest_epid].ep_stats
+						  .tx_dropped_vlan_id_mismatch += 1;
 			ret = NETDEV_TX_OK;
 		} else {
 			if (len < VLAN_ETH_HLEN) {
@@ -706,6 +724,8 @@ fjes_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 					ret = NETDEV_TX_OK;
 				} else {
 					netdev->trans_start = jiffies;
+					hw->ep_shm_info[dest_epid].ep_stats
+								  .tx_buffer_full += 1;
 					netif_tx_stop_queue(cur_queue);
 
 					if (!work_pending(&adapter->tx_stall_task))
@@ -1117,21 +1137,33 @@ static irqreturn_t fjes_intr(int irq, void *data)
 	icr = fjes_hw_capture_interrupt_status(hw);
 
 	if (icr & REG_IS_MASK_IS_ASSERT) {
-		if (icr & REG_ICTL_MASK_RX_DATA)
+		if (icr & REG_ICTL_MASK_RX_DATA) {
 			fjes_rx_irq(adapter, icr & REG_IS_MASK_EPID);
+			hw->ep_shm_info[icr & REG_IS_MASK_EPID].ep_stats.
+				receive_interrupts_rx += 1;
+		}
 
-		if (icr & REG_ICTL_MASK_DEV_STOP_REQ)
+		if (icr & REG_ICTL_MASK_DEV_STOP_REQ) {
 			fjes_stop_req_irq(adapter, icr & REG_IS_MASK_EPID);
+			hw->ep_shm_info[icr & REG_IS_MASK_EPID].ep_stats.
+				receive_interrupts_stop += 1;
+		}
 
-		if (icr & REG_ICTL_MASK_TXRX_STOP_REQ)
+		if (icr & REG_ICTL_MASK_TXRX_STOP_REQ) {
 			fjes_txrx_stop_req_irq(adapter, icr & REG_IS_MASK_EPID);
+			hw->ep_shm_info[icr & REG_IS_MASK_EPID].ep_stats.
+				receive_interrupts_unshare += 1;
+		}
 
 		if (icr & REG_ICTL_MASK_TXRX_STOP_DONE)
 			fjes_hw_set_irqmask(hw,
 					    REG_ICTL_MASK_TXRX_STOP_DONE, true);
 
-		if (icr & REG_ICTL_MASK_INFO_UPDATE)
+		if (icr & REG_ICTL_MASK_INFO_UPDATE) {
 			fjes_update_zone_irq(adapter, icr & REG_IS_MASK_EPID);
+			hw->ep_shm_info[icr & REG_IS_MASK_EPID].ep_stats.
+				receive_interrupts_zoneupdate += 1;
+		}
 
 		ret = IRQ_HANDLED;
 	} else {
@@ -1506,6 +1538,9 @@ static void fjes_watch_unshare_task(struct work_struct *work)
 			}
 			mutex_unlock(&hw->hw_info.lock);
 
+			hw->ep_shm_info[epidx].ep_stats
+					      .command_unregister_buffer_executed += 1;
+
 			fjes_hw_setup_epbuf(&hw->ep_shm_info[epidx].tx,
 					    netdev->dev_addr, netdev->mtu);
 
@@ -1545,6 +1580,9 @@ static void fjes_watch_unshare_task(struct work_struct *work)
 				}
 				mutex_unlock(&hw->hw_info.lock);
 
+				hw->ep_shm_info[epidx].ep_stats
+						      .command_unregister_buffer_executed += 1;
+
 				fjes_hw_setup_epbuf(
 					&hw->ep_shm_info[epidx].tx,
 					netdev->dev_addr, netdev->mtu);
-- 
2.4.3

^ permalink raw reply related

* [PATCH net-next 04/11] fjes: Add debugfs entry for statistics
From: Taku Izumi @ 2016-04-11  8:10 UTC (permalink / raw)
  To: davem, netdev; +Cc: Taku Izumi
In-Reply-To: <1460362136-14968-1-git-send-email-izumi.taku@jp.fujitsu.com>

This patch introduces debugfs entry named "statistics"
for statistics information.
You can get net_stats information by reading
/sys/kernel/debug/fjes/fjes.N/statistics file.
This is useful for debugging.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
---
 drivers/net/fjes/fjes_debugfs.c | 72 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/drivers/net/fjes/fjes_debugfs.c b/drivers/net/fjes/fjes_debugfs.c
index d2fd892..b0807c2 100644
--- a/drivers/net/fjes/fjes_debugfs.c
+++ b/drivers/net/fjes/fjes_debugfs.c
@@ -31,6 +31,72 @@
 
 static struct dentry *fjes_debug_root;
 
+static int fjes_dbg_stats_show(struct seq_file *m, void *v)
+{
+	struct fjes_adapter *adapter = m->private;
+	struct fjes_hw *hw = &adapter->hw;
+	int max_epid = hw->max_epid;
+	int my_epid = hw->my_epid;
+	int epidx;
+
+	seq_printf(m, "%41s", " ");
+	for (epidx = 0; epidx < max_epid; epidx++)
+		seq_printf(m, "%10s%d",
+			   my_epid == epidx ? "(self)EP#" : "EP#", epidx);
+	seq_printf(m, "\n");
+
+#define FJES_DEBUGFS_NET_STATS_ENTRY(X) do {				\
+	seq_printf(m, "%-41s", #X);					\
+	for (epidx = 0; epidx < max_epid; epidx++) {			\
+		if (epidx == my_epid)					\
+			seq_printf(m, "          -");			\
+		else							\
+			seq_printf(m, " %10llu",			\
+				   hw->ep_shm_info[epidx].net_stats.X); \
+	}								\
+	seq_printf(m, "\n");						\
+} while (0)
+
+	FJES_DEBUGFS_NET_STATS_ENTRY(rx_packets);
+	FJES_DEBUGFS_NET_STATS_ENTRY(tx_packets);
+	FJES_DEBUGFS_NET_STATS_ENTRY(rx_bytes);
+	FJES_DEBUGFS_NET_STATS_ENTRY(tx_bytes);
+	FJES_DEBUGFS_NET_STATS_ENTRY(rx_errors);
+	FJES_DEBUGFS_NET_STATS_ENTRY(tx_errors);
+	FJES_DEBUGFS_NET_STATS_ENTRY(rx_dropped);
+	FJES_DEBUGFS_NET_STATS_ENTRY(tx_dropped);
+	FJES_DEBUGFS_NET_STATS_ENTRY(multicast);
+	FJES_DEBUGFS_NET_STATS_ENTRY(collisions);
+	FJES_DEBUGFS_NET_STATS_ENTRY(rx_length_errors);
+	FJES_DEBUGFS_NET_STATS_ENTRY(rx_over_errors);
+	FJES_DEBUGFS_NET_STATS_ENTRY(rx_crc_errors);
+	FJES_DEBUGFS_NET_STATS_ENTRY(rx_frame_errors);
+	FJES_DEBUGFS_NET_STATS_ENTRY(rx_fifo_errors);
+	FJES_DEBUGFS_NET_STATS_ENTRY(rx_missed_errors);
+	FJES_DEBUGFS_NET_STATS_ENTRY(tx_aborted_errors);
+	FJES_DEBUGFS_NET_STATS_ENTRY(tx_carrier_errors);
+	FJES_DEBUGFS_NET_STATS_ENTRY(tx_fifo_errors);
+	FJES_DEBUGFS_NET_STATS_ENTRY(tx_heartbeat_errors);
+	FJES_DEBUGFS_NET_STATS_ENTRY(tx_window_errors);
+	FJES_DEBUGFS_NET_STATS_ENTRY(rx_compressed);
+	FJES_DEBUGFS_NET_STATS_ENTRY(tx_compressed);
+
+	return 0;
+}
+
+static int fjes_dbg_stats_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, fjes_dbg_stats_show, inode->i_private);
+}
+
+static const struct file_operations fjes_dbg_stats_fops = {
+	.owner		= THIS_MODULE,
+	.open		= fjes_dbg_stats_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
 static int fjes_dbg_status_show(struct seq_file *m, void *v)
 {
 	struct fjes_adapter *adapter = m->private;
@@ -89,6 +155,12 @@ void fjes_dbg_adapter_init(struct fjes_adapter *adapter)
 	if (!pfile)
 		dev_err(&adapter->plat_dev->dev,
 			"debugfs status for %s failed\n", name);
+
+	pfile = debugfs_create_file("statistics", 0444, adapter->dbg_adapter,
+				    adapter, &fjes_dbg_stats_fops);
+	if (!pfile)
+		dev_err(&adapter->plat_dev->dev,
+			"debugfs status for %s failed\n", name);
 }
 
 void fjes_dbg_adapter_exit(struct fjes_adapter *adapter)
-- 
2.4.3

^ permalink raw reply related

* [PATCH net-next 03/11] fjes: Add debugs facility for fjes module
From: Taku Izumi @ 2016-04-11  8:10 UTC (permalink / raw)
  To: davem, netdev; +Cc: Taku Izumi
In-Reply-To: <1460362136-14968-1-git-send-email-izumi.taku@jp.fujitsu.com>

This patch introduces debugfs facility for fjes module.
You can get EP status information by reading
/sys/kernel/debug/fjes/fjes.N/status file.
This is useful for debugging.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
---
 drivers/net/fjes/Makefile       |   2 +-
 drivers/net/fjes/fjes.h         |  16 ++++++
 drivers/net/fjes/fjes_debugfs.c | 113 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/fjes/fjes_main.c    |  12 ++++-
 4 files changed, 141 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/fjes/fjes_debugfs.c

diff --git a/drivers/net/fjes/Makefile b/drivers/net/fjes/Makefile
index 523e3d7..51c20ce 100644
--- a/drivers/net/fjes/Makefile
+++ b/drivers/net/fjes/Makefile
@@ -27,4 +27,4 @@
 
 obj-$(CONFIG_FUJITSU_ES) += fjes.o
 
-fjes-objs := fjes_main.o fjes_hw.o fjes_ethtool.o
+fjes-objs := fjes_main.o fjes_hw.o fjes_ethtool.o fjes_debugfs.o
diff --git a/drivers/net/fjes/fjes.h b/drivers/net/fjes/fjes.h
index a592fe2..a528f75 100644
--- a/drivers/net/fjes/fjes.h
+++ b/drivers/net/fjes/fjes.h
@@ -66,6 +66,10 @@ struct fjes_adapter {
 	bool interrupt_watch_enable;
 
 	struct fjes_hw hw;
+
+#ifdef CONFIG_DEBUG_FS
+	struct dentry *dbg_adapter;
+#endif /* CONFIG_DEBUG_FS */
 };
 
 extern char fjes_driver_name[];
@@ -74,4 +78,16 @@ extern const u32 fjes_support_mtu[];
 
 void fjes_set_ethtool_ops(struct net_device *);
 
+#ifdef CONFIG_DEBUG_FS
+void fjes_dbg_adapter_init(struct fjes_adapter *adapter);
+void fjes_dbg_adapter_exit(struct fjes_adapter *adapter);
+void fjes_dbg_init(void);
+void fjes_dbg_exit(void);
+#else
+static inline void fjes_dbg_adapter_init(struct fjes_adapter *adapter) {}
+static inline void fjes_dbg_adapter_exit(struct fjes_adapter *adapter) {}
+static inline void fjes_dbg_init(void) {}
+static inline void fjes_dbg_exit(void) {}
+#endif /* CONFIG_DEBUF_FS */
+
 #endif /* FJES_H_ */
diff --git a/drivers/net/fjes/fjes_debugfs.c b/drivers/net/fjes/fjes_debugfs.c
new file mode 100644
index 0000000..d2fd892
--- /dev/null
+++ b/drivers/net/fjes/fjes_debugfs.c
@@ -0,0 +1,113 @@
+/*
+ *  FUJITSU Extended Socket Network Device driver
+ *  Copyright (c) 2015 FUJITSU LIMITED
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * The full GNU General Public License is included in this distribution in
+ * the file called "COPYING".
+ *
+ */
+
+/* debugfs support for fjes */
+
+#ifdef CONFIG_DEBUG_FS
+
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+#include <linux/platform_device.h>
+
+#include "fjes.h"
+
+static struct dentry *fjes_debug_root;
+
+static int fjes_dbg_status_show(struct seq_file *m, void *v)
+{
+	struct fjes_adapter *adapter = m->private;
+	struct fjes_hw *hw = &adapter->hw;
+	int max_epid = hw->max_epid;
+	int my_epid = hw->my_epid;
+	int epidx;
+
+	seq_printf(m,
+		   "status debug EP ID(n) n is partner status: UNSHARE(%d), SHARED(%d), WAITING(%d), COMPLETE(%d)\n",
+		   EP_PARTNER_UNSHARE, EP_PARTNER_SHARED, EP_PARTNER_WAITING,
+		   EP_PARTNER_COMPLETE);
+	seq_printf(m, "EP ID          SAME ZONE        CONNECTED\n");
+	for (epidx = 0; epidx < max_epid; epidx++) {
+		seq_printf(m, "%d", epidx);
+		if (epidx == my_epid)
+			seq_printf(m, "(self)        %c                %c\n",
+				   '-', '-');
+		else
+			seq_printf(m, "(%d)           %c                %c\n",
+				   fjes_hw_get_partner_ep_status(hw, epidx),
+				   fjes_hw_epid_is_same_zone(hw, epidx) ? 'Y' : 'N',
+				   fjes_hw_epid_is_shared(hw->hw_info.share, epidx) ? 'Y' : 'N');
+	}
+
+	return 0;
+}
+
+static int fjes_dbg_status_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, fjes_dbg_status_show, inode->i_private);
+}
+
+static const struct file_operations fjes_dbg_status_fops = {
+	.owner		= THIS_MODULE,
+	.open		= fjes_dbg_status_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+void fjes_dbg_adapter_init(struct fjes_adapter *adapter)
+{
+	const char *name = dev_name(&adapter->plat_dev->dev);
+	struct dentry *pfile;
+
+	adapter->dbg_adapter = debugfs_create_dir(name, fjes_debug_root);
+	if (!adapter->dbg_adapter) {
+		dev_err(&adapter->plat_dev->dev,
+			"debugfs entry for %s failed\n", name);
+		return;
+	}
+
+	pfile = debugfs_create_file("status", 0444, adapter->dbg_adapter,
+				    adapter, &fjes_dbg_status_fops);
+	if (!pfile)
+		dev_err(&adapter->plat_dev->dev,
+			"debugfs status for %s failed\n", name);
+}
+
+void fjes_dbg_adapter_exit(struct fjes_adapter *adapter)
+{
+	debugfs_remove_recursive(adapter->dbg_adapter);
+	adapter->dbg_adapter = NULL;
+}
+
+void fjes_dbg_init(void)
+{
+	fjes_debug_root = debugfs_create_dir(fjes_driver_name, NULL);
+	if (!fjes_debug_root)
+		pr_info("init of debugfs failed\n");
+}
+
+void fjes_dbg_exit(void)
+{
+	debugfs_remove_recursive(fjes_debug_root);
+	fjes_debug_root = NULL;
+}
+
+#endif /* CONFIG_DEBUG_FS */
diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index 40cf65d..7595415 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -1359,6 +1359,8 @@ static int fjes_probe(struct platform_device *plat_dev)
 
 	netif_carrier_off(netdev);
 
+	fjes_dbg_adapter_init(adapter);
+
 	return 0;
 
 err_hw_exit:
@@ -1376,6 +1378,8 @@ static int fjes_remove(struct platform_device *plat_dev)
 	struct fjes_adapter *adapter = netdev_priv(netdev);
 	struct fjes_hw *hw = &adapter->hw;
 
+	fjes_dbg_adapter_exit(adapter);
+
 	cancel_delayed_work_sync(&adapter->interrupt_watch_task);
 	cancel_work_sync(&adapter->unshare_watch_task);
 	cancel_work_sync(&adapter->raise_intr_rxdata_task);
@@ -1566,9 +1570,13 @@ static int __init fjes_init_module(void)
 	pr_info("%s - version %s - %s\n",
 		fjes_driver_string, fjes_driver_version, fjes_copyright);
 
+	fjes_dbg_init();
+
 	result = platform_driver_register(&fjes_driver);
-	if (result < 0)
+	if (result < 0) {
+		fjes_dbg_exit();
 		return result;
+	}
 
 	result = acpi_bus_register_driver(&fjes_acpi_driver);
 	if (result < 0)
@@ -1578,6 +1586,7 @@ static int __init fjes_init_module(void)
 
 fail_acpi_driver:
 	platform_driver_unregister(&fjes_driver);
+	fjes_dbg_exit();
 	return result;
 }
 
@@ -1588,6 +1597,7 @@ static void __exit fjes_exit_module(void)
 {
 	acpi_bus_unregister_driver(&fjes_acpi_driver);
 	platform_driver_unregister(&fjes_driver);
+	fjes_dbg_exit();
 }
 
 module_exit(fjes_exit_module);
-- 
2.4.3

^ permalink raw reply related

* [PATCH net-next 01/11] fjes: Add trace-gathering facility
From: Taku Izumi @ 2016-04-11  8:09 UTC (permalink / raw)
  To: davem, netdev; +Cc: Taku Izumi
In-Reply-To: <1460362136-14968-1-git-send-email-izumi.taku@jp.fujitsu.com>

This patch introduces trace-gathering facility via ioctl.
This data is useful for debugging this module and firmware.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
---
 drivers/net/fjes/fjes_hw.c    | 140 ++++++++++++++++++++++++++++++++++
 drivers/net/fjes/fjes_hw.h    |  16 ++++
 drivers/net/fjes/fjes_ioctl.h |  86 +++++++++++++++++++++
 drivers/net/fjes/fjes_main.c  | 171 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 413 insertions(+)
 create mode 100644 drivers/net/fjes/fjes_ioctl.h

diff --git a/drivers/net/fjes/fjes_hw.c b/drivers/net/fjes/fjes_hw.c
index b103adb..0b0795e 100644
--- a/drivers/net/fjes/fjes_hw.c
+++ b/drivers/net/fjes/fjes_hw.c
@@ -1121,3 +1121,143 @@ static void fjes_hw_epstop_task(struct work_struct *work)
 		}
 	}
 }
+
+int fjes_hw_alloc_trace_buf(struct fjes_hw *hw, u64 trace_size, u32 mode)
+{
+	if (trace_size % EP_TRACE_PAGE_SIZE)
+		return -EINVAL;
+
+	if (FJES_DEV_COMMAND_START_TRACE_REQ_LEN(trace_size) >
+	    hw->hw_info.req_buf_size)
+		return -EINVAL;
+
+	hw->hw_info.trace = vmalloc(trace_size);
+	if (!hw->hw_info.trace)
+		return -ENOMEM;
+
+	hw->hw_info.trace_size = trace_size;
+	hw->trace_mode = mode;
+
+	return 0;
+}
+
+void fjes_hw_free_trace_buf(struct fjes_hw *hw)
+{
+	vfree(hw->hw_info.trace);
+	hw->hw_info.trace = NULL;
+	hw->hw_info.trace_size = 0;
+	hw->trace_mode = 0;
+}
+
+bool fjes_hw_trace_is_started(struct fjes_hw *hw)
+{
+	return hw->trace_started;
+}
+
+int fjes_hw_start_trace(struct fjes_hw *hw)
+{
+	union fjes_device_command_req *req_buf = hw->hw_info.req_buf;
+	union fjes_device_command_res *res_buf = hw->hw_info.res_buf;
+	enum fjes_dev_command_response_e ret;
+	int page_count;
+	int result = 0;
+	void *addr;
+	int i;
+
+	memset(req_buf, 0, hw->hw_info.req_buf_size);
+	memset(res_buf, 0, hw->hw_info.res_buf_size);
+
+	req_buf->start_trace.length =
+		FJES_DEV_COMMAND_START_TRACE_REQ_LEN(hw->hw_info.trace_size);
+	req_buf->start_trace.mode = hw->trace_mode;
+	req_buf->start_trace.buffer_len = hw->hw_info.trace_size;
+	page_count = hw->hw_info.trace_size / EP_TRACE_PAGE_SIZE;
+
+	for (i = 0; i < page_count; i++) {
+		addr = ((u8 *)hw->hw_info.trace) + i * EP_TRACE_PAGE_SIZE;
+		req_buf->start_trace.buffer[i] =
+			(__le64)(page_to_phys(vmalloc_to_page(addr)) +
+			offset_in_page(addr));
+	}
+	res_buf->start_trace.length = 0;
+	res_buf->start_trace.code = 0;
+
+	ret = fjes_hw_issue_request_command(hw, FJES_CMD_REQ_START_TRACE);
+
+	if (res_buf->start_trace.length !=
+	    FJES_DEV_COMMAND_START_TRACE_RES_LEN)
+		result = -ENOMSG;
+	else if (ret == FJES_CMD_STATUS_NORMAL) {
+		switch (res_buf->start_trace.code) {
+		case FJES_CMD_REQ_RES_CODE_NORMAL:
+			result = 0;
+			hw->trace_started = true;
+			break;
+		default:
+			result = -EPERM;
+			break;
+		}
+	} else {
+		switch (ret) {
+		case FJES_CMD_STATUS_UNKNOWN:
+			result = -EPERM;
+			break;
+		case FJES_CMD_STATUS_TIMEOUT:
+			result = -EBUSY;
+			break;
+		case FJES_CMD_STATUS_ERROR_PARAM:
+		case FJES_CMD_STATUS_ERROR_STATUS:
+		default:
+			result = -EPERM;
+			break;
+		}
+	}
+
+	return result;
+}
+
+int fjes_hw_stop_trace(struct fjes_hw *hw)
+{
+	union fjes_device_command_req *req_buf = hw->hw_info.req_buf;
+	union fjes_device_command_res *res_buf = hw->hw_info.res_buf;
+	enum fjes_dev_command_response_e ret;
+	int result = 0;
+
+	memset(req_buf, 0, hw->hw_info.req_buf_size);
+	memset(res_buf, 0, hw->hw_info.res_buf_size);
+	req_buf->stop_trace.length = FJES_DEV_COMMAND_STOP_TRACE_RES_LEN;
+	res_buf->stop_trace.length = 0;
+	res_buf->stop_trace.code = 0;
+
+	ret = fjes_hw_issue_request_command(hw, FJES_CMD_REQ_STOP_TRACE);
+
+	if (res_buf->stop_trace.length != FJES_DEV_COMMAND_STOP_TRACE_RES_LEN) {
+		result = -ENOMSG;
+	} else if (ret == FJES_CMD_STATUS_NORMAL) {
+		switch (res_buf->stop_trace.code) {
+		case FJES_CMD_REQ_RES_CODE_NORMAL:
+			result = 0;
+			hw->trace_started = false;
+			break;
+		default:
+			result = -EPERM;
+			break;
+		}
+	} else {
+		switch (ret) {
+		case FJES_CMD_STATUS_UNKNOWN:
+			result = -EPERM;
+			break;
+		case FJES_CMD_STATUS_TIMEOUT:
+			result = -EBUSY;
+			break;
+		case FJES_CMD_STATUS_ERROR_PARAM:
+		case FJES_CMD_STATUS_ERROR_STATUS:
+		default:
+			result = -EPERM;
+			break;
+		}
+	}
+
+	return result;
+}
diff --git a/drivers/net/fjes/fjes_hw.h b/drivers/net/fjes/fjes_hw.h
index 6d57b89..38be7d9 100644
--- a/drivers/net/fjes/fjes_hw.h
+++ b/drivers/net/fjes/fjes_hw.h
@@ -32,6 +32,7 @@ struct fjes_hw;
 
 #define EP_BUFFER_SUPPORT_VLAN_MAX 4
 #define EP_BUFFER_INFO_SIZE 4096
+#define EP_TRACE_PAGE_SIZE 4096
 
 #define FJES_DEVICE_RESET_TIMEOUT  ((17 + 1) * 3) /* sec */
 #define FJES_COMMAND_REQ_TIMEOUT  (5 + 1) /* sec */
@@ -93,6 +94,11 @@ struct fjes_hw;
 #define FJES_DEV_RES_BUF_SIZE(maxep) \
 	FJES_DEV_COMMAND_INFO_RES_LEN(maxep)
 
+#define FJES_DEV_COMMAND_START_TRACE_REQ_LEN(byte) (16 + (8 * (byte) / EP_TRACE_PAGE_SIZE))
+#define FJES_DEV_COMMAND_START_TRACE_RES_LEN (8)
+#define FJES_DEV_COMMAND_STOP_TRACE_REQ_LEN (4)
+#define FJES_DEV_COMMAND_STOP_TRACE_RES_LEN (8)
+
 /* Frame & MTU */
 struct esmem_frame {
 	__le32 frame_size;
@@ -172,6 +178,8 @@ enum fjes_dev_command_request_type {
 	FJES_CMD_REQ_INFO		= 0x0001,
 	FJES_CMD_REQ_SHARE_BUFFER	= 0x0002,
 	FJES_CMD_REQ_UNSHARE_BUFFER	= 0x0004,
+	FJES_CMD_REQ_START_TRACE        = 0x0100,
+	FJES_CMD_REQ_STOP_TRACE         = 0x0200,
 };
 
 /* parameter for command control */
@@ -299,6 +307,9 @@ struct fjes_hw {
 	u8 *base;
 
 	struct fjes_hw_info hw_info;
+
+	bool trace_started;
+	u32 trace_mode;
 };
 
 int fjes_hw_init(struct fjes_hw *);
@@ -331,4 +342,9 @@ void *fjes_hw_epbuf_rx_curpkt_get_addr(struct epbuf_handler *, size_t *);
 void fjes_hw_epbuf_rx_curpkt_drop(struct epbuf_handler *);
 int fjes_hw_epbuf_tx_pkt_send(struct epbuf_handler *, void *, size_t);
 
+int fjes_hw_alloc_trace_buf(struct fjes_hw *, u64, u32);
+void fjes_hw_free_trace_buf(struct fjes_hw *);
+bool fjes_hw_trace_is_started(struct fjes_hw *);
+int fjes_hw_start_trace(struct fjes_hw *);
+int fjes_hw_stop_trace(struct fjes_hw *);
 #endif /* FJES_HW_H_ */
diff --git a/drivers/net/fjes/fjes_ioctl.h b/drivers/net/fjes/fjes_ioctl.h
new file mode 100644
index 0000000..35adfda
--- /dev/null
+++ b/drivers/net/fjes/fjes_ioctl.h
@@ -0,0 +1,86 @@
+/*
+ *  FUJITSU Extended Socket Network Device driver
+ *  Copyright (c) 2015 FUJITSU LIMITED
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * The full GNU General Public License is included in this distribution in
+ * the file called "COPYING".
+ *
+ */
+
+#ifndef FJES_IOCTL_H_
+#define FJES_IOCTL_H_
+
+#define FJES_IOCTL_TRACE_START		(SIOCDEVPRIVATE + 1)
+#define FJES_IOCTL_TRACE_STOP		(SIOCDEVPRIVATE + 2)
+#define FJES_IOCTL_TRACE_GETCFG		(SIOCDEVPRIVATE + 3)
+
+struct fjes_ioctl_trace_start_req_val {
+	u32	mode;
+	u32	reserved;
+	u64	trace_size;
+};
+
+struct fjes_ioctl_trace_stop_req_val {
+	u64	trace_buff_size;
+};
+
+union fjes_ioctl_trace_req_val {
+	struct fjes_ioctl_trace_start_req_val	start;
+	struct fjes_ioctl_trace_stop_req_val	stop;
+};
+
+struct fjes_ioctl_trace_start_res_val {
+	u32	err_code;
+	u32	reserved;
+};
+
+struct fjes_ioctl_trace_getcfg_res_val {
+	u32	err_code;
+	u32	mode;
+	u64	trace_size;
+};
+
+struct fjes_ioctl_trace_stop_res_val {
+	u32	err_code;
+	u32	reserve;
+	u64	written_size;
+	u16	trace_data_buff[];
+};
+
+union fjes_ioctl_trace_res_val {
+	struct fjes_ioctl_trace_start_res_val	start;
+	struct fjes_ioctl_trace_getcfg_res_val	getcfg;
+	struct fjes_ioctl_trace_stop_res_val	stop;
+};
+
+struct fjes_ioctl_trace_param {
+	union fjes_ioctl_trace_req_val	req;
+	union fjes_ioctl_trace_res_val	res;
+};
+
+#define FJES_IOCTL_TRACE_START_ERR_NORMAL		(0x0000)
+#define FJES_IOCTL_TRACE_START_ERR_BUSY			(0x0001)
+#define FJES_IOCTL_TRACE_START_ERR_PARAM		(0x0100)
+#define FJES_IOCTL_TRACE_START_ERR_ALREADY_STARTED	(0x0200)
+#define FJES_IOCTL_TRACE_START_ERR_MEMORY		(0x0400)
+
+#define FJES_IOCTL_TRACE_STOP_ERR_NORMAL		(0x0000)
+#define FJES_IOCTL_TRACE_STOP_ERR_BUSY			(0x0001)
+#define FJES_IOCTL_TRACE_STOP_ERR_BEFORE_START		(0x0300)
+
+#define FJES_IOCTL_TRACE_GETCFG_ERR_NORMAL		(0x0000)
+#define FJES_IOCTL_TRACE_GETCFG_ERR_BEFORE_START	(0x0300)
+
+#endif /* FJES_IOCTL_H_ */
diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index 0ddb54f..bc6e31d 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -27,6 +27,7 @@
 #include <linux/interrupt.h>
 
 #include "fjes.h"
+#include "fjes_ioctl.h"
 
 #define MAJ 1
 #define MIN 0
@@ -61,6 +62,7 @@ fjes_get_stats64(struct net_device *, struct rtnl_link_stats64 *);
 static int fjes_change_mtu(struct net_device *, int);
 static int fjes_vlan_rx_add_vid(struct net_device *, __be16 proto, u16);
 static int fjes_vlan_rx_kill_vid(struct net_device *, __be16 proto, u16);
+static int fjes_ioctl(struct net_device *, struct ifreq *, int cmd);
 static void fjes_tx_retry(struct net_device *);
 
 static int fjes_acpi_add(struct acpi_device *);
@@ -242,6 +244,7 @@ static const struct net_device_ops fjes_netdev_ops = {
 	.ndo_tx_timeout		= fjes_tx_retry,
 	.ndo_vlan_rx_add_vid	= fjes_vlan_rx_add_vid,
 	.ndo_vlan_rx_kill_vid = fjes_vlan_rx_kill_vid,
+	.ndo_do_ioctl		= fjes_ioctl,
 };
 
 /* fjes_open - Called when a network interface is made active */
@@ -820,6 +823,174 @@ static int fjes_vlan_rx_kill_vid(struct net_device *netdev,
 	return 0;
 }
 
+static int fjes_ioctl_trace_start(struct net_device *netdev, struct ifreq *rq)
+{
+	struct fjes_adapter *adapter = netdev_priv(netdev);
+	struct fjes_ioctl_trace_param param;
+	struct fjes_hw *hw = &adapter->hw;
+	u64 trace_size;
+	int ret = 0;
+	u32 mode;
+
+	if (copy_from_user(&param, rq->ifr_data, sizeof(param)))
+		return -EFAULT;
+
+	if (fjes_hw_trace_is_started(hw)) {
+		param.res.start.err_code =
+			FJES_IOCTL_TRACE_START_ERR_ALREADY_STARTED;
+	}
+
+	trace_size = param.req.start.trace_size;
+	mode = param.req.start.mode;
+
+	ret = fjes_hw_alloc_trace_buf(hw, trace_size, mode);
+	switch (ret) {
+	case 0:
+		break;
+	case -EINVAL:
+		param.res.start.err_code = FJES_IOCTL_TRACE_START_ERR_PARAM;
+		goto out;
+	case -ENOMEM:
+		param.res.start.err_code = FJES_IOCTL_TRACE_START_ERR_MEMORY;
+		goto out;
+	default:
+		break;
+	}
+
+	mutex_lock(&hw->hw_info.lock);
+	ret = fjes_hw_start_trace(hw);
+	mutex_unlock(&hw->hw_info.lock);
+
+	switch (ret) {
+	case 0:
+		param.res.start.err_code = FJES_IOCTL_TRACE_START_ERR_NORMAL;
+		break;
+	case -ENOMSG:
+	case -EBUSY:
+		param.res.start.err_code = FJES_IOCTL_TRACE_START_ERR_BUSY;
+		break;
+	default:
+		param.res.start.err_code =
+			hw->hw_info.res_buf->start_trace.code;
+		break;
+	}
+
+out:
+	if (copy_to_user(rq->ifr_data, &param, sizeof(param)))
+		return -EFAULT;
+
+	return 0;
+}
+
+static int fjes_ioctl_trace_stop(struct net_device *netdev, struct ifreq *rq)
+{
+	struct fjes_adapter *adapter = netdev_priv(netdev);
+	struct fjes_ioctl_trace_param param;
+	struct fjes_hw *hw = &adapter->hw;
+	struct es_device_trace *trace;
+	u32 start_trace_buff_size;
+	u32 stop_trace_buff_size;
+	bool trace_done = false;
+	u32 buff_size;
+	int ret;
+
+	if (copy_from_user(&param, rq->ifr_data, sizeof(param)))
+		return -EFAULT;
+
+	if (!fjes_hw_trace_is_started(hw)) {
+		param.res.stop.err_code =
+			FJES_IOCTL_TRACE_STOP_ERR_BEFORE_START;
+		goto out;
+	}
+
+	mutex_lock(&hw->hw_info.lock);
+	ret = fjes_hw_stop_trace(hw);
+	mutex_unlock(&hw->hw_info.lock);
+
+	switch (ret) {
+	case 0:
+		param.res.stop.err_code = FJES_IOCTL_TRACE_STOP_ERR_NORMAL;
+		trace_done = true;
+		break;
+	case -ENOMSG:
+	case -EBUSY:
+		param.res.stop.err_code = FJES_IOCTL_TRACE_STOP_ERR_BUSY;
+		break;
+	default:
+		param.res.stop.err_code = hw->hw_info.res_buf->stop_trace.code;
+		break;
+	}
+
+out:
+	if (copy_to_user(rq->ifr_data, &param, sizeof(param))) {
+		if (trace_done)
+			fjes_hw_free_trace_buf(hw);
+		return -EFAULT;
+	}
+
+	if (!trace_done)
+		return 0;
+
+	start_trace_buff_size = hw->hw_info.trace_size;
+	stop_trace_buff_size = param.req.stop.trace_buff_size;
+
+	trace = hw->hw_info.trace;
+	buff_size = min(start_trace_buff_size, stop_trace_buff_size);
+
+	param.res.stop.written_size = buff_size;
+	ret = copy_to_user(rq->ifr_data, &param,
+			   sizeof(union fjes_ioctl_trace_req_val) +
+			   sizeof(struct fjes_ioctl_trace_stop_res_val));
+
+	ret = copy_to_user((rq->ifr_data +
+			    sizeof(union fjes_ioctl_trace_req_val) +
+			    sizeof(struct fjes_ioctl_trace_stop_res_val)),
+			   trace,
+			   buff_size);
+
+	fjes_hw_free_trace_buf(hw);
+
+	return ret;
+}
+
+static int fjes_ioctl_trace_getcfg(struct net_device *netdev, struct ifreq *rq)
+{
+	struct fjes_adapter *adapter = netdev_priv(netdev);
+	struct fjes_ioctl_trace_param param;
+	struct fjes_hw *hw = &adapter->hw;
+
+	if (copy_from_user(&param, rq->ifr_data, sizeof(param)))
+		return -EFAULT;
+
+	if (fjes_hw_trace_is_started(hw)) {
+		param.res.getcfg.err_code = FJES_IOCTL_TRACE_GETCFG_ERR_NORMAL;
+		param.res.getcfg.mode = hw->trace_mode;
+		param.res.getcfg.trace_size = hw->hw_info.trace_size;
+	} else {
+		param.res.getcfg.err_code =
+			FJES_IOCTL_TRACE_GETCFG_ERR_BEFORE_START;
+	}
+
+	if (copy_to_user(rq->ifr_data, &param, sizeof(param)))
+		return -EFAULT;
+
+	return 0;
+}
+
+static int fjes_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
+{
+	switch (cmd) {
+	case FJES_IOCTL_TRACE_START:
+		return fjes_ioctl_trace_start(netdev, rq);
+	case FJES_IOCTL_TRACE_STOP:
+		return fjes_ioctl_trace_stop(netdev, rq);
+	case FJES_IOCTL_TRACE_GETCFG:
+		return fjes_ioctl_trace_getcfg(netdev, rq);
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
 static void fjes_txrx_stop_req_irq(struct fjes_adapter *adapter,
 				   int src_epid)
 {
-- 
2.4.3

^ permalink raw reply related

* [PATCH net-next 02/11] fjes: Add setting/getting register value feature via ioctl
From: Taku Izumi @ 2016-04-11  8:10 UTC (permalink / raw)
  To: davem, netdev; +Cc: Taku Izumi
In-Reply-To: <1460362136-14968-1-git-send-email-izumi.taku@jp.fujitsu.com>

This patch introduces setting/getting register value feature
via ioctl. This feature is useful for debugging.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
---
 drivers/net/fjes/fjes_ioctl.h |  7 +++++++
 drivers/net/fjes/fjes_main.c  | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/drivers/net/fjes/fjes_ioctl.h b/drivers/net/fjes/fjes_ioctl.h
index 35adfda..61619f7 100644
--- a/drivers/net/fjes/fjes_ioctl.h
+++ b/drivers/net/fjes/fjes_ioctl.h
@@ -25,6 +25,8 @@
 #define FJES_IOCTL_TRACE_START		(SIOCDEVPRIVATE + 1)
 #define FJES_IOCTL_TRACE_STOP		(SIOCDEVPRIVATE + 2)
 #define FJES_IOCTL_TRACE_GETCFG		(SIOCDEVPRIVATE + 3)
+#define FJES_IOCTL_DEV_GETREG		(SIOCDEVPRIVATE + 4)
+#define FJES_IOCTL_DEV_SETREG		(SIOCDEVPRIVATE + 5)
 
 struct fjes_ioctl_trace_start_req_val {
 	u32	mode;
@@ -70,6 +72,11 @@ struct fjes_ioctl_trace_param {
 	union fjes_ioctl_trace_res_val	res;
 };
 
+struct fjes_ioctl_dev_reg_param {
+	u32	offset;
+	u32	val;
+};
+
 #define FJES_IOCTL_TRACE_START_ERR_NORMAL		(0x0000)
 #define FJES_IOCTL_TRACE_START_ERR_BUSY			(0x0001)
 #define FJES_IOCTL_TRACE_START_ERR_PARAM		(0x0100)
diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index bc6e31d..40cf65d 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -977,6 +977,40 @@ static int fjes_ioctl_trace_getcfg(struct net_device *netdev, struct ifreq *rq)
 	return 0;
 }
 
+static int fjes_ioctl_reg_read(struct net_device *netdev, struct ifreq *rq)
+{
+	struct fjes_adapter *adapter = netdev_priv(netdev);
+	struct fjes_ioctl_dev_reg_param reg;
+	struct fjes_hw *hw = &adapter->hw;
+
+	if (copy_from_user(&reg, rq->ifr_data, sizeof(reg)))
+		return -EFAULT;
+
+	reg.val = rd32(reg.offset);
+
+	if (copy_to_user(rq->ifr_data, &reg, sizeof(reg)))
+		return -EFAULT;
+
+	return 0;
+}
+
+static int fjes_ioctl_reg_write(struct net_device *netdev, struct ifreq *rq)
+{
+	struct fjes_adapter *adapter = netdev_priv(netdev);
+	struct fjes_ioctl_dev_reg_param reg;
+	struct fjes_hw *hw = &adapter->hw;
+
+	if (copy_from_user(&reg, rq->ifr_data, sizeof(reg)))
+		return -EFAULT;
+
+	wr32(reg.offset, reg.val);
+
+	if (copy_to_user(rq->ifr_data, &reg, sizeof(reg)))
+		return -EFAULT;
+
+	return 0;
+}
+
 static int fjes_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
 {
 	switch (cmd) {
@@ -986,7 +1020,12 @@ static int fjes_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
 		return fjes_ioctl_trace_stop(netdev, rq);
 	case FJES_IOCTL_TRACE_GETCFG:
 		return fjes_ioctl_trace_getcfg(netdev, rq);
+	case FJES_IOCTL_DEV_GETREG:
+		return fjes_ioctl_reg_read(netdev, rq);
+	case FJES_IOCTL_DEV_SETREG:
+		return fjes_ioctl_reg_write(netdev, rq);
 	default:
+
 		return -EOPNOTSUPP;
 	}
 }
-- 
2.4.3

^ permalink raw reply related

* [PATCH net-next 00/11] FUJITSU Extended Socket driver version 1.1
From: Taku Izumi @ 2016-04-11  8:08 UTC (permalink / raw)
  To: davem, netdev; +Cc: Taku Izumi

This patchsets update FUJITSU Extended Socket network driver into version 1.1.
This mainly includes debugging feature and some minor bugfix. 


Taku Izumi (11):
  fjes: Add trace-gathering facility
  fjes: Add setting/getting register value feature via ioctl
  fjes: Add debugs facility for fjes module
  fjes: Add debugfs entry for statistics
  fjes: show EP stats at statistics file in debugfs
  fjes: optimize timeout value
  fjes: fix incorrect statistics information in fjes_xmit_frame()
  fjes: fix bitwise check bug in fjes_raise_intr_rxdata_task
  fjes: Enhance changing MTU related work
  fjes: Introduce spinlock for rx_status
  fjes: Update fjes driver version : 1.1

 drivers/net/fjes/Makefile       |   2 +-
 drivers/net/fjes/fjes.h         |  16 ++
 drivers/net/fjes/fjes_debugfs.c | 212 +++++++++++++++++++++
 drivers/net/fjes/fjes_hw.c      | 179 +++++++++++++++++-
 drivers/net/fjes/fjes_hw.h      |  43 ++++-
 drivers/net/fjes/fjes_ioctl.h   |  93 ++++++++++
 drivers/net/fjes/fjes_main.c    | 400 +++++++++++++++++++++++++++++++++++++---
 7 files changed, 909 insertions(+), 36 deletions(-)
 create mode 100644 drivers/net/fjes/fjes_debugfs.c
 create mode 100644 drivers/net/fjes/fjes_ioctl.h

-- 
2.4.3

^ permalink raw reply

* [PATCH net-next 4/4] bnxt_en: Add async event handling for speed config changes.
From: Michael Chan @ 2016-04-11  8:11 UTC (permalink / raw)
  To: davem; +Cc: netdev
In-Reply-To: <1460362274-21771-1-git-send-email-michael.chan@broadcom.com>

On some dual port cards, link speeds on both ports have to be compatible.
Firmware will inform the driver when a certain speed is no longer
supported if the other port has linked up at a certain speed.  Add
logic to handle this event by logging a message and getting the
updated list of supported speeds.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index c83a5a1..4645c44 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -122,6 +122,7 @@ static const u16 bnxt_async_events_arr[] = {
 	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE,
 	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD,
 	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE,
 };
 
 static bool bnxt_vf_pciid(enum board_idx idx)
@@ -1257,6 +1258,21 @@ static int bnxt_async_event_process(struct bnxt *bp,
 
 	/* TODO CHIMP_FW: Define event id's for link change, error etc */
 	switch (event_id) {
+	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE: {
+		u32 data1 = le32_to_cpu(cmpl->event_data1);
+		struct bnxt_link_info *link_info = &bp->link_info;
+
+		if (BNXT_VF(bp))
+			goto async_event_process_exit;
+		if (data1 & 0x20000) {
+			u16 fw_speed = link_info->force_link_speed;
+			u32 speed = bnxt_fw_to_ethtool_speed(fw_speed);
+
+			netdev_warn(bp->dev, "Link speed %d no longer supported\n",
+				    speed);
+		}
+		/* fall thru */
+	}
 	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE:
 		set_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event);
 		break;
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH net-next 3/4] bnxt_en: Call firmware to approve VF MAC address change.
From: Michael Chan @ 2016-04-11  8:11 UTC (permalink / raw)
  To: davem; +Cc: netdev
In-Reply-To: <1460362274-21771-1-git-send-email-michael.chan@broadcom.com>

Some hypervisors (e.g. ESX) require the VF MAC address to be forwarded to
the PF for approval.  In Linux PF, the call is not forwarded and the
firmware will simply check and approve the MAC address if the PF has not
previously administered a valid MAC address for this VF.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c       |  7 +++---
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 30 +++++++++++++++++++++++++
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h |  1 +
 3 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index e874a56..c83a5a1 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -5696,10 +5696,9 @@ static int bnxt_change_mac_addr(struct net_device *dev, void *p)
 	if (!is_valid_ether_addr(addr->sa_data))
 		return -EADDRNOTAVAIL;
 
-#ifdef CONFIG_BNXT_SRIOV
-	if (BNXT_VF(bp) && is_valid_ether_addr(bp->vf.mac_addr))
-		return -EADDRNOTAVAIL;
-#endif
+	rc = bnxt_approve_mac(bp, addr->sa_data);
+	if (rc)
+		return rc;
 
 	if (ether_addr_equal(addr->sa_data, dev->dev_addr))
 		return 0;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
index 8457850..363884d 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
@@ -865,6 +865,31 @@ update_vf_mac_exit:
 	mutex_unlock(&bp->hwrm_cmd_lock);
 }
 
+int bnxt_approve_mac(struct bnxt *bp, u8 *mac)
+{
+	struct hwrm_func_vf_cfg_input req = {0};
+	int rc = 0;
+
+	if (!BNXT_VF(bp))
+		return 0;
+
+	if (bp->hwrm_spec_code < 0x10202) {
+		if (is_valid_ether_addr(bp->vf.mac_addr))
+			rc = -EADDRNOTAVAIL;
+		goto mac_done;
+	}
+	bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_CFG, -1, -1);
+	req.enables = cpu_to_le32(FUNC_VF_CFG_REQ_ENABLES_DFLT_MAC_ADDR);
+	memcpy(req.dflt_mac_addr, mac, ETH_ALEN);
+	rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
+mac_done:
+	if (rc) {
+		rc = -EADDRNOTAVAIL;
+		netdev_warn(bp->dev, "VF MAC address %pM not approved by the PF\n",
+			    mac);
+	}
+	return rc;
+}
 #else
 
 void bnxt_sriov_disable(struct bnxt *bp)
@@ -879,4 +904,9 @@ void bnxt_hwrm_exec_fwd_req(struct bnxt *bp)
 void bnxt_update_vf_mac(struct bnxt *bp)
 {
 }
+
+int bnxt_approve_mac(struct bnxt *bp, u8 *mac)
+{
+	return 0;
+}
 #endif
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h
index 3f08354..0392670 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h
@@ -20,4 +20,5 @@ int bnxt_sriov_configure(struct pci_dev *pdev, int num_vfs);
 void bnxt_sriov_disable(struct bnxt *);
 void bnxt_hwrm_exec_fwd_req(struct bnxt *);
 void bnxt_update_vf_mac(struct bnxt *);
+int bnxt_approve_mac(struct bnxt *, u8 *);
 #endif
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH net-next 0/4] bnxt_en: Update for net-next
From: Michael Chan @ 2016-04-11  8:11 UTC (permalink / raw)
  To: davem; +Cc: netdev

Misc. changes for link speed and VF MAC address change.

Michael Chan (4):
  bnxt_en: Disallow forced speed for 10GBaseT devices.
  bnxt_en: Shutdown link when device is closed.
  bnxt_en: Call firmware to approve VF MAC address change.
  bnxt_en: Add async event handling for speed config changes.

 drivers/net/ethernet/broadcom/bnxt/bnxt.c         | 40 ++++++++++++++++++++---
 drivers/net/ethernet/broadcom/bnxt/bnxt.h         |  1 +
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c |  8 +++++
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c   | 30 +++++++++++++++++
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h   |  1 +
 5 files changed, 76 insertions(+), 4 deletions(-)

-- 
1.8.3.1

^ permalink raw reply

* [PATCH net-next 2/4] bnxt_en: Shutdown link when device is closed.
From: Michael Chan @ 2016-04-11  8:11 UTC (permalink / raw)
  To: davem; +Cc: netdev
In-Reply-To: <1460362274-21771-1-git-send-email-michael.chan@broadcom.com>

Let firmware know that the driver is giving up control of the link so that
it can be shutdown if no management firmware is running.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index a06dcaa..e874a56 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -4790,6 +4790,21 @@ int bnxt_hwrm_set_link_setting(struct bnxt *bp, bool set_pause, bool set_eee)
 	return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
 }
 
+static int bnxt_hwrm_shutdown_link(struct bnxt *bp)
+{
+	struct hwrm_port_phy_cfg_input req = {0};
+
+	if (BNXT_VF(bp))
+		return 0;
+
+	if (pci_num_vf(bp->pdev))
+		return 0;
+
+	bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_PHY_CFG, -1, -1);
+	req.flags = cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE_LINK_DOWN);
+	return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
+}
+
 static bool bnxt_eee_config_ok(struct bnxt *bp)
 {
 	struct ethtool_eee *eee = &bp->eee;
@@ -5044,6 +5059,7 @@ static int bnxt_close(struct net_device *dev)
 	struct bnxt *bp = netdev_priv(dev);
 
 	bnxt_close_nic(bp, true, true);
+	bnxt_hwrm_shutdown_link(bp);
 	return 0;
 }
 
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH net-next 1/4] bnxt_en: Disallow forced speed for 10GBaseT devices.
From: Michael Chan @ 2016-04-11  8:11 UTC (permalink / raw)
  To: davem; +Cc: netdev
In-Reply-To: <1460362274-21771-1-git-send-email-michael.chan@broadcom.com>

10GBaseT devices must autonegotiate to determine master/slave clocking.
Disallow forced speed in ethtool .set_settings() for these devices.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c         | 1 +
 drivers/net/ethernet/broadcom/bnxt/bnxt.h         | 1 +
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 8 ++++++++
 3 files changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 597e472..a06dcaa 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -4611,6 +4611,7 @@ static int bnxt_update_link(struct bnxt *bp, bool chng_link_state)
 	link_info->phy_ver[1] = resp->phy_min;
 	link_info->phy_ver[2] = resp->phy_bld;
 	link_info->media_type = resp->media_type;
+	link_info->phy_type = resp->phy_type;
 	link_info->transceiver = resp->xcvr_pkg_type;
 	link_info->phy_addr = resp->eee_config_phy_addr &
 			      PORT_PHY_QCFG_RESP_PHY_ADDR_MASK;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index cc8e38a..26dac2f 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -759,6 +759,7 @@ struct bnxt_ntuple_filter {
 };
 
 struct bnxt_link_info {
+	u8			phy_type;
 	u8			media_type;
 	u8			transceiver;
 	u8			phy_addr;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index a2e9324..d6e41f2 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -850,7 +850,15 @@ static int bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 		set_pause = true;
 	} else {
 		u16 fw_speed;
+		u8 phy_type = link_info->phy_type;
 
+		if (phy_type == PORT_PHY_QCFG_RESP_PHY_TYPE_BASET  ||
+		    phy_type == PORT_PHY_QCFG_RESP_PHY_TYPE_BASETE ||
+		    link_info->media_type == PORT_PHY_QCFG_RESP_MEDIA_TYPE_TP) {
+			netdev_err(dev, "10GBase-T devices must autoneg\n");
+			rc = -EINVAL;
+			goto set_setting_exit;
+		}
 		/* TODO: currently don't support half duplex */
 		if (cmd->duplex == DUPLEX_HALF) {
 			netdev_err(dev, "HALF DUPLEX is not supported!\n");
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH net v2] net: sched: do not requeue a NULL skb
From: Lars Persson @ 2016-04-11  6:24 UTC (permalink / raw)
  To: netdev; +Cc: jhs, linux-kernel, xiyou.wangcong, Lars Persson

A failure in validate_xmit_skb_list() triggered an unconditional call
to dev_requeue_skb with skb=NULL. This slowly grows the queue
discipline's qlen count until all traffic through the queue stops.

By introducing a NULL check in dev_requeue_skb it was also necessary
to make the __netif_schedule call conditional to avoid scheduling an
empty queue.

Fixes: 55a93b3ea780 ("qdisc: validate skb without holding lock")
Signed-off-by: Lars Persson <larper@axis.com>
---
 net/sched/sch_generic.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index f18c350..4e6a79c 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -47,10 +47,13 @@ EXPORT_SYMBOL(default_qdisc_ops);
 
 static inline int dev_requeue_skb(struct sk_buff *skb, struct Qdisc *q)
 {
-	q->gso_skb = skb;
-	q->qstats.requeues++;
-	q->q.qlen++;	/* it's still part of the queue */
-	__netif_schedule(q);
+	if (skb) {
+		q->gso_skb = skb;
+		q->qstats.requeues++;
+		q->q.qlen++;	/* it's still part of the queue */
+	}
+	if (qdisc_qlen(q))
+		__netif_schedule(q);
 
 	return 0;
 }
-- 
2.1.4

^ permalink raw reply related

* [PATCH net] cxgb4: Stop Rx Queues before freeing it up
From: Hariprasad Shenai @ 2016-04-11  5:37 UTC (permalink / raw)
  To: davem; +Cc: netdev, leedom, nirranjan, Hariprasad Shenai

Stop all Ethernet RX Queues before freeing up various Ingress/Egress
Queues, etc. We were seeing cases of Ingress Queues not getting serviced
during the shutdown process leading to Ingress Paths jamming up through
the chip and blocking the shutdown effort itself.

One such case involved the Firmware sending a "Flush Token" through the
ULP-TX -> ULP-RX path for an Ethernet TX Queue being freed in order to
make sure there weren't any remaining TX Work Requests in the pipeline.
But the return path was stalled by Ingress Data unable to be delivered to
the Host because those Ingress Queues were no longer being serviced.

Based on original work by Casey Leedom <leedom@chelsio.com>

Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |  3 +++
 drivers/net/ethernet/chelsio/cxgb4/sge.c   | 20 +++++++++++++++---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 33 ++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 984a3cc26f86..326d4009525e 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -1451,6 +1451,9 @@ int t4_mdio_rd(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
 	       unsigned int mmd, unsigned int reg, u16 *valp);
 int t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
 	       unsigned int mmd, unsigned int reg, u16 val);
+int t4_iq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf,
+	       unsigned int vf, unsigned int iqtype, unsigned int iqid,
+	       unsigned int fl0id, unsigned int fl1id);
 int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
 	       unsigned int vf, unsigned int iqtype, unsigned int iqid,
 	       unsigned int fl0id, unsigned int fl1id);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 13b144bcf725..6278e5a74b74 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -2981,14 +2981,28 @@ void t4_free_ofld_rxqs(struct adapter *adap, int n, struct sge_ofld_rxq *q)
 void t4_free_sge_resources(struct adapter *adap)
 {
 	int i;
-	struct sge_eth_rxq *eq = adap->sge.ethrxq;
-	struct sge_eth_txq *etq = adap->sge.ethtxq;
+	struct sge_eth_rxq *eq;
+	struct sge_eth_txq *etq;
+
+	/* stop all Rx queues in order to start them draining */
+	for (i = 0; i < adap->sge.ethqsets; i++) {
+		eq = &adap->sge.ethrxq[i];
+		if (eq->rspq.desc)
+			t4_iq_stop(adap, adap->mbox, adap->pf, 0,
+				   FW_IQ_TYPE_FL_INT_CAP,
+				   eq->rspq.cntxt_id,
+				   eq->fl.size ? eq->fl.cntxt_id : 0xffff,
+				   0xffff);
+	}
 
 	/* clean up Ethernet Tx/Rx queues */
-	for (i = 0; i < adap->sge.ethqsets; i++, eq++, etq++) {
+	for (i = 0; i < adap->sge.ethqsets; i++) {
+		eq = &adap->sge.ethrxq[i];
 		if (eq->rspq.desc)
 			free_rspq_fl(adap, &eq->rspq,
 				     eq->fl.size ? &eq->fl : NULL);
+
+		etq = &adap->sge.ethtxq[i];
 		if (etq->q.desc) {
 			t4_eth_eq_free(adap, adap->mbox, adap->pf, 0,
 				       etq->q.cntxt_id);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index cc1736bece0f..520ffcaef6d8 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -6940,6 +6940,39 @@ int t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid,
 }
 
 /**
+ *	t4_iq_stop - stop an ingress queue and its FLs
+ *	@adap: the adapter
+ *	@mbox: mailbox to use for the FW command
+ *	@pf: the PF owning the queues
+ *	@vf: the VF owning the queues
+ *	@iqtype: the ingress queue type (FW_IQ_TYPE_FL_INT_CAP, etc.)
+ *	@iqid: ingress queue id
+ *	@fl0id: FL0 queue id or 0xffff if no attached FL0
+ *	@fl1id: FL1 queue id or 0xffff if no attached FL1
+ *
+ *	Stops an ingress queue and its associated FLs, if any.  This causes
+ *	any current or future data/messages destined for these queues to be
+ *	tossed.
+ */
+int t4_iq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf,
+	       unsigned int vf, unsigned int iqtype, unsigned int iqid,
+	       unsigned int fl0id, unsigned int fl1id)
+{
+	struct fw_iq_cmd c;
+
+	memset(&c, 0, sizeof(c));
+	c.op_to_vfn = cpu_to_be32(FW_CMD_OP_V(FW_IQ_CMD) | FW_CMD_REQUEST_F |
+				  FW_CMD_EXEC_F | FW_IQ_CMD_PFN_V(pf) |
+				  FW_IQ_CMD_VFN_V(vf));
+	c.alloc_to_len16 = cpu_to_be32(FW_IQ_CMD_IQSTOP_F | FW_LEN16(c));
+	c.type_to_iqandstindex = cpu_to_be32(FW_IQ_CMD_TYPE_V(iqtype));
+	c.iqid = cpu_to_be16(iqid);
+	c.fl0id = cpu_to_be16(fl0id);
+	c.fl1id = cpu_to_be16(fl1id);
+	return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
  *	t4_iq_free - free an ingress queue and its FLs
  *	@adap: the adapter
  *	@mbox: mailbox to use for the FW command
-- 
2.3.4

^ permalink raw reply related

* Re: Backport Security Fix for CVE-2015-8787 to v4.1
From: Yuki Machida @ 2016-04-11  4:58 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: davem, netdev, kamatam
In-Reply-To: <570B2B4E.2080303@jp.fujitsu.com>

Hi Pablo,

On 2016年04月11日 13:42, Yuki Machida wrote:
> Hi Pablo,
>
> On 2016年04月07日 23:46, Pablo Neira Ayuso wrote:
>> On Thu, Apr 07, 2016 at 03:40:30PM +0900, Yuki Machida wrote:
>>> Hi David,
>>>
>>> I conformed that a patch of CVE-2015-8787 not applied at v4.1.21.
>>> Could you please apply a patch for 4.1-stable ?
>>>
>>> CVE-2015-8787
>>> Upstream commit 94f9cd81436c85d8c3a318ba92e236ede73752fc
>>
>> I'll request again, this time to Sasha Levin to include this in
>> -stable 4.1.
> Thank you for your help.
David said "Please send to the netfilter team".
Therefore, I will send above patch to netfilter team.

Thank you.
>> Thanks.
>>
>

^ permalink raw reply

* Re: Backport Security Fix for CVE-2015-8787 to v4.1
From: Yuki Machida @ 2016-04-11  4:42 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: davem, netdev, kamatam
In-Reply-To: <20160407144628.GA1137@salvia>

Hi Pablo,

On 2016年04月07日 23:46, Pablo Neira Ayuso wrote:
> On Thu, Apr 07, 2016 at 03:40:30PM +0900, Yuki Machida wrote:
>> Hi David,
>>
>> I conformed that a patch of CVE-2015-8787 not applied at v4.1.21.
>> Could you please apply a patch for 4.1-stable ?
>>
>> CVE-2015-8787
>> Upstream commit 94f9cd81436c85d8c3a318ba92e236ede73752fc
>
> I'll request again, this time to Sasha Levin to include this in
> -stable 4.1.
Thank you for your help.

> Thanks.
>

^ permalink raw reply

* Re: [PATCH 1/1] net: stmmac: socfgpa: Ensure emac bit set in System Manger for PTP
From: David Miller @ 2016-04-11  3:44 UTC (permalink / raw)
  To: preid; +Cc: peppe.cavallaro, netdev
In-Reply-To: <1460015735-8946-2-git-send-email-preid@electromag.com.au>

From: Phil Reid <preid@electromag.com.au>
Date: Thu,  7 Apr 2016 15:55:35 +0800

> When using the PTP fpga to hps clock source for the stmmac module
> the appropriate bit in the System Manager FPGA Interface Group register
> needs to be set. This is not set by the bootloader setup  when the
> HPS emac pins are being for this emac module.
> 
> This allows the PTP clock to be sourced from the FPGA and also connects
> the PTP pps and ext trig signals to the stmmac PTP hardware.
> 
> Patch proposed by Phil Collins.
> 
> Signed-off-by: Phil Reid <preid@electromag.com.au>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH] netlink: don't send NETLINK_URELEASE for unbound sockets
From: David Miller @ 2016-04-11  3:33 UTC (permalink / raw)
  To: johannes-cdvu00un1VgdHxzADdlk8Q
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, dmitrijs.ivanovs-NO1NBkfNQUg,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1460014298-30293-1-git-send-email-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>

From: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
Date: Thu,  7 Apr 2016 09:31:38 +0200

> From: Dmitry Ivanov <dmitrijs.ivanovs-NO1NBkfNQUg@public.gmane.org>
> 
> All existing users of NETLINK_URELEASE use it to clean up resources that
> were previously allocated to a socket via some command. As a result, no
> users require getting this notification for unbound sockets.
> 
> Sending it for unbound sockets, however, is a problem because any user
> (including unprivileged users) can create a socket that uses the same ID
> as an existing socket. Binding this new socket will fail, but if the
> NETLINK_URELEASE notification is generated for such sockets, the users
> thereof will be tricked into thinking the socket that they allocated the
> resources for is closed.
> 
> In the nl80211 case, this will cause destruction of virtual interfaces
> that still belong to an existing hostapd process; this is the case that
> Dmitry noticed. In the NFC case, it will cause a poll abort. In the case
> of netlink log/queue it will cause them to stop reporting events, as if
> NFULNL_CFG_CMD_UNBIND/NFQNL_CFG_CMD_UNBIND had been called.
> 
> Fix this problem by checking that the socket is bound before generating
> the NETLINK_URELEASE notification.
> 
> Cc: stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Signed-off-by: Dmitry Ivanov <dima-NO1NBkfNQUg@public.gmane.org>
> Signed-off-by: Johannes Berg <johannes.berg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Applied and queued up for -stable, thanks everyone.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH net-next WIP] ethtool: generic netlink policy
From: Roopa Prabhu @ 2016-04-11  3:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, eladr, idosch

From: Roopa Prabhu <roopa@cumulusnetworks.com>

netlink for ethtool came up at netconf/netdev and we had promised to
send some of the ethtool netlink code we have.
We use a generic netlink channel for ethtool between our kernel and
user space driver. This ethtool channel nicely wraps most ethtool
commands into genl messages. And is capable of handling delayed
remote ops to userspace in some cases (dropping rtnl etc). We use
this channel to also cache some of this ethtool data in the kernel.
In this patch I have included just the genl policy for ethtool which
will apply to the generic usecase. We can certainly share the rest of
it if we see a usecase. Especially the remote handling of ethtool ops
for delayed hw operations maybe useful in other cases (today they are
tied to our remote driver in userspace). The ethtool handlers for
genl use the existing ethtool structs and call into the
respective driver handlers.

This came up again at the switchdev discussion recently and I had
promised to get this out this weekend :). This patch does not include
changes to compile the code.

We should move ethtool to netlink at some point: And I think we
should also explore the possibility of including it into the existing
new devlink generic netlink infrastructure. And ethtool stats should
move to the new stats infrastructure.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
---
 net/core/ethtool_netlink.c | 200 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 200 insertions(+)
 create mode 100644 net/core/ethtool_netlink.c

diff --git a/net/core/ethtool_netlink.c b/net/core/ethtool_netlink.c
new file mode 100644
index 0000000..f5445f3
--- /dev/null
+++ b/net/core/ethtool_netlink.c
@@ -0,0 +1,200 @@
+/*
+ *  net/core/ethtool_netlink.c - generic ethtool netlink handler
+ *  Copyright (C) 2015 Cumulus Networks
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *  GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/capability.h>
+#include <linux/errno.h>
+#include <linux/ethtool.h>
+#include <linux/port.h>
+#include <linux/netdevice.h>
+#include <linux/list.h>
+#include <linux/rtnetlink.h>
+#include <linux/hashtable.h>
+#include <linux/rcupdate.h>
+#include <linux/nsproxy.h>
+#include <net/net_namespace.h>
+#include <net/netns/generic.h>
+#include <net/genetlink.h>
+
+static const struct nla_policy ethtool_policy[ETHTOOL_ATTR_MAX + 1] = {
+	[ETHTOOL_ATTR_IFINDEX]		= { .type = NLA_U32 },
+	[ETHTOOL_ATTR_FLAGS]		= { .type = NLA_U32 },
+	[ETHTOOL_ATTR_PHYS_ID_STATE]	= { .type = NLA_U8 },
+	[ETHTOOL_ATTR_SETTINGS]		= { .type = NLA_BINARY,
+		.len = sizeof(struct ethtool_cmd) },
+	[ETHTOOL_ATTR_PAUSE]		= { .type = NLA_BINARY,
+		.len = sizeof(struct ethtool_pauseparam) },
+	[ETHTOOL_ATTR_MODINFO]		= { .type = NLA_BINARY,
+		.len = sizeof(struct ethtool_modinfo) },
+	[ETHTOOL_ATTR_EEPROM]		= { .type = NLA_BINARY,
+		.len = sizeof(struct ethtool_eeprom) },
+	[ETHTOOL_ATTR_EEPROM_DATA]		= { .type = NLA_BINARY },
+	[ETHTOOL_ATTR_STATS]		= { .type = NLA_NESTED },
+	[ETHTOOL_ATTR_STAT]		= { .type = NLA_U32 },
+	[ETHTOOL_ATTR_STRINGS]		= { .type = NLA_NESTED },
+	[ETHTOOL_ATTR_STRING]		= { .type = NLA_STRING,
+		.len = ETH_GSTRING_LEN },
+	[ETHTOOL_ATTR_SSET]		= { .type = NLA_U32 },
+	[ETHTOOL_ATTR_SSET_COUNT]		= { .type = NLA_U32 },
+};
+
+static struct genl_family ethtool_family = {
+	.id = GENL_ID_GENERATE,
+	.name = "ethtool_family",
+	.version = 1,
+	.maxattr = ETHTOOL_ATTR_MAX,
+};
+
+static struct genl_multicast_group ethtool_mcgrp[] = {
+	{ .name = "port_mc", },
+};
+
+static LIST_HEAD(wq_list);
+
+static struct genl_ops ethtool_ops[] = {
+	{
+		.cmd = ETHTOOL_CMD_GET_SETTINGS,
+		.policy = ethtool_policy,
+		.doit = ethtool_get_settings,
+	},
+	{
+		.cmd = ETHTOOL_CMD_SET_SETTINGS,
+		.policy = ethtool_policy,
+		.doit = ethtool_set_settings,
+	},
+	{
+		.cmd = ETHTOOL_CMD_GET_PAUSE,
+		.policy = ethtool_policy,
+		.doit = ethtool_get_pause,
+	},
+	{
+		.cmd = ETHTOOL_CMD_SET_PAUSE,
+		.policy = ethtool_policy,
+		.doit = ethtool_set_pause,
+	},
+	{
+		.cmd = ETHTOOL_CMD_GET_MODULE_INFO,
+		.policy = ethtool_policy,
+		.doit = ethtool_get_module_info,
+	},
+	{
+		.cmd = ETHTOOL_CMD_SET_MODULE_INFO,
+		.policy = ethtool_policy,
+		.doit = ethtool_set_module_info,
+	},
+};
+
+int ethtool_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ethtool_get_settings);
+
+int ethtool_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ethtool_set_settings);
+
+void ethtool_get_pauseparam(struct net_device *dev,
+			    struct ethtool_pauseparam *pause)
+{
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ethtool_get_pauseparam);
+
+int ethtool_set_pauseparam(struct net_device *dev,
+			   struct ethtool_pauseparam *pause)
+{
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ethtool_set_pauseparam);
+
+void ethtool_get_ethtool_stats(struct net_device *dev,
+			       struct ethtool_stats *stats,
+			       u64 *data)
+{
+
+	/* example the driver handler would do the below
+	 *
+	err = nla_put_u32(msg, PORT_ATTR_IFINDEX, ifindex);
+	if (err < 0)
+		goto err_out;
+
+	err = nla_put_u32(msg, PORT_ATTR_FLAGS, flags);
+	if (err < 0)
+		goto err_out;
+
+	err = nla_put_u32(msg, PORT_ATTR_SSET_COUNT,
+			  count);
+	if (err < 0)
+		goto err_out;
+
+	nest = nla_nest_start(msg, PORT_ATTR_STATS);
+	for (i = 0; i < count; i++)
+		nla_put_u64(msg, PORT_ATTR_STAT, data[i]);
+			    nla_nest_end(msg, nest);
+
+	 */
+}
+EXPORT_SYMBOL_GPL(ethtool_get_ethtool_stats);
+
+void ethtool_get_strings(struct net_device *dev, u32 stringset, u8 *data)
+{
+	return;
+}
+EXPORT_SYMBOL_GPL(ethtool_get_strings);
+
+int ethtool_get_sset_count(struct net_device *dev, int sset)
+{
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ethtool_get_sset_count);
+
+int ethtool_set_phys_id(struct net_device *dev, enum ethtool_phys_id_state state)
+{
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ethtool_set_phys_id);
+
+int ethtool_get_module_info(struct net_device *dev, struct ethtool_modinfo *info)
+{
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ethtool_get_module_info);
+
+int ethtool_get_module_eeprom(struct net_device *dev,
+			      struct ethtool_eeprom *eeprom, u8 *data)
+{
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ethtool_get_module_eeprom);
+
+static int __init ethtool_init(void)
+{
+	int err;
+
+	err = genl_register_family_with_ops_groups(&ethtool_family, ethtool_ops,
+						   ethtool_mcgrp);
+	if (err) {
+		genl_unregister_family(&port_family);
+		return err;
+	}
+	pr_debug("ethtool netlink family register OK\n");
+
+	return 0;
+}
+late_initcall(ethtool_init);
-- 
1.9.1

^ permalink raw reply related

* Re: [PATCH] net: mark DECnet as broken
From: David Miller @ 2016-04-11  3:02 UTC (permalink / raw)
  To: vegard.nossum; +Cc: netdev, linux-kernel, eric.dumazet, sasha.levin
In-Reply-To: <1460013763-22985-1-git-send-email-vegard.nossum@oracle.com>

From: Vegard Nossum <vegard.nossum@oracle.com>
Date: Thu,  7 Apr 2016 09:22:43 +0200

> There are NULL pointer dereference bugs in DECnet which can be triggered
> by unprivileged users and have been reported multiple times to LKML,
> however nobody seems confident enough in the proposed fixes to merge them
> and the consensus seems to be that nobody cares enough about DECnet to
> see it fixed anyway.
> 
> To shield unsuspecting users from the possible DOS, we should mark this
> BROKEN until somebody who actually uses this code can fix it.
> 
> Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
> Link: https://lkml.org/lkml/2015/12/17/666

As stated, I'm not applying this, and rather I am fixing this as
below:

====================
[PATCH] decnet: Do not build routes to devices without decnet private data.

In particular, make sure we check for decnet private presence
for loopback devices.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/decnet/dn_route.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 607a14f..b1dc096 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -1034,10 +1034,13 @@ source_ok:
 	if (!fld.daddr) {
 		fld.daddr = fld.saddr;
 
-		err = -EADDRNOTAVAIL;
 		if (dev_out)
 			dev_put(dev_out);
+		err = -EINVAL;
 		dev_out = init_net.loopback_dev;
+		if (!dev_out->dn_ptr)
+			goto out;
+		err = -EADDRNOTAVAIL;
 		dev_hold(dev_out);
 		if (!fld.daddr) {
 			fld.daddr =
@@ -1110,6 +1113,8 @@ source_ok:
 		if (dev_out == NULL)
 			goto out;
 		dn_db = rcu_dereference_raw(dev_out->dn_ptr);
+		if (!dn_db)
+			goto e_inval;
 		/* Possible improvement - check all devices for local addr */
 		if (dn_dev_islocal(dev_out, fld.daddr)) {
 			dev_put(dev_out);
@@ -1151,6 +1156,8 @@ select_source:
 			dev_put(dev_out);
 		dev_out = init_net.loopback_dev;
 		dev_hold(dev_out);
+		if (!dev_out->dn_ptr)
+			goto e_inval;
 		fld.flowidn_oif = dev_out->ifindex;
 		if (res.fi)
 			dn_fib_info_put(res.fi);
-- 
2.1.0

^ permalink raw reply related

* RE: [v7, 0/5] Fix eSDHC host version register bug
From: Yangbo Lu @ 2016-04-11  2:54 UTC (permalink / raw)
  To: Scott Wood, Yang-Leo Li
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Ulf Hansson,
	Zhao Qiang, Russell King, Bhupesh Sharma,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Santosh Shilimkar,
	linux-mmc, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Jochen Friedrich, Xiaobo Xie,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	Rob Herring, linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Claudiu Manoil, Kumar Gala,
	linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"linux-arm-kernel-IAPFreCvJWNGWvitb5QawA@public.gmane.org
In-Reply-To: <CAPDyKFp8GDzSkpbTKoRL=rwiBrsWmsgN95zB-QJwfZTnq4M8BA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Hi Leo and Scott,


> -----Original Message-----
> From: Ulf Hansson [mailto:ulf.hansson@linaro.org]
> Sent: Wednesday, April 06, 2016 4:15 PM
> To: Yangbo Lu; Scott Wood
> Cc: devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org;
> linux-kernel@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; linux-
> clk@vger.kernel.org; linux-i2c@vger.kernel.org; iommu@lists.linux-
> foundation.org; netdev@vger.kernel.org; linux-mmc; Rob Herring; Russell
> King; Jochen Friedrich; Joerg Roedel; Claudiu Manoil; Bhupesh Sharma;
> Zhao Qiang; Kumar Gala; Santosh Shilimkar; Yang-Leo Li; Xiaobo Xie
> Subject: Re: [v7, 0/5] Fix eSDHC host version register bug
> 
> >>
> >> I was about to queue this for next, when I noticed that checkpatch is
> >> complaining/warning lots about these patches. Can you please a round
> >> of checkpatch and fix what makes sense.
> >>
> >> Kind regards
> >> Uffe
> >
> > [Lu Yangbo-B47093] Sorry about this, Uffe...
> 
> No worries!
> 
> > Should I ignore the warnings that update MAINTAINERS?
> 
> drivers/soc/fsl/guts.c isn't part of the MAINTAINERS file, it should be.
> 
> I also realize that the FREESCALE QUICC ENGINE LIBRARY section
> drivers/soc/fsl/qe/* also need an active maintainer, as it's currently
> orphan.
> 
> Perhaps we should have create a new section for drivers/soc/fsl/* instead
> that covers all of the above? Maybe you or Scott are interested to pick
> it up?
> 
> I also noted that, "include/linux/fsl/" isn't present in MAINTAINERS,
> please add that as well.

[Lu Yangbo-B47093] Could give some advice on the MAINTAINERS for these 'fsl' files
since I really don’t know who should be the right person?
I will appreciate that!

Thanks a lot.

> 
> > Regarding the 'undocumented' warning, I will added a patch updates doc
> before all the patches, Ok?
> 
> Yes, good!
> 
> >
> > Thanks a lot :)
> >
> 
> Kind regards
> Uffe
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply

* Re: [PATCH net-next] bpf: simplify verifier register state assignments
From: David Miller @ 2016-04-11  2:43 UTC (permalink / raw)
  To: ast; +Cc: daniel, netdev
In-Reply-To: <1459996761-2926623-1-git-send-email-ast@fb.com>

From: Alexei Starovoitov <ast@fb.com>
Date: Wed, 6 Apr 2016 19:39:21 -0700

> verifier is using the following structure to track the state of registers:
> struct reg_state {
>     enum bpf_reg_type type;
>     union {
>         int imm;
>         struct bpf_map *map_ptr;
>     };
> };
> and later on in states_equal() does memcmp(&old->regs[i], &cur->regs[i],..)
> to find equivalent states.
> Throughout the code of verifier there are assignements to 'imm' and 'map_ptr'
> fields and it's not obvious that most of the assignments into 'imm' don't
> need to clear extra 4 bytes (like mark_reg_unknown_value() does) to make sure
> that memcmp doesn't go over junk left from 'map_ptr' assignment.
> 
> Simplify the code by converting 'int' into 'long'
> 
> Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>

Applied, thanks Daniel.

^ permalink raw reply

* Re: [PATCH RFT 2/2] macb: kill PHY reset code
From: Andrew Lunn @ 2016-04-11  2:28 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: nicolas.ferre, netdev, linux-kernel
In-Reply-To: <2811962.eGX2i5RJbZ@wasted.cogentembedded.com>

On Sat, Apr 09, 2016 at 01:25:03AM +0300, Sergei Shtylyov wrote:
> With  the 'phylib' now  being aware of  the "reset-gpios" PHY node property,
> there should be no need to frob the PHY reset in this  driver anymore...
> 
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
> 
> ---
>  drivers/net/ethernet/cadence/macb.c |   17 -----------------
>  drivers/net/ethernet/cadence/macb.h |    1 -
>  2 files changed, 18 deletions(-)
> 
> Index: net-next/drivers/net/ethernet/cadence/macb.c
> ===================================================================
> --- net-next.orig/drivers/net/ethernet/cadence/macb.c
> +++ net-next/drivers/net/ethernet/cadence/macb.c
> @@ -2884,7 +2884,6 @@ static int macb_probe(struct platform_de
>  					      = macb_clk_init;
>  	int (*init)(struct platform_device *) = macb_init;
>  	struct device_node *np = pdev->dev.of_node;
> -	struct device_node *phy_node;
>  	const struct macb_config *macb_config = NULL;
>  	struct clk *pclk, *hclk = NULL, *tx_clk = NULL;
>  	unsigned int queue_mask, num_queues;
> @@ -2977,18 +2976,6 @@ static int macb_probe(struct platform_de
>  	else
>  		macb_get_hwaddr(bp);
>  
> -	/* Power up the PHY if there is a GPIO reset */
> -	phy_node =  of_get_next_available_child(np, NULL);
> -	if (phy_node) {
> -		int gpio = of_get_named_gpio(phy_node, "reset-gpios", 0);
> -
> -		if (gpio_is_valid(gpio)) {
> -			bp->reset_gpio = gpio_to_desc(gpio);
> -			gpiod_direction_output(bp->reset_gpio, 1);

Hi Sergei

The code you are deleting would of ignored the flags in the gpio
property, i.e. active low. The new code in the previous patch does
however take the flags into account. Did you check if there are any
device trees which have flags, which were never used, but are now
going to be used and thus break...

      Andrew

^ permalink raw reply

* Re: [PATCH 1/3] bonding: do not allow rlb updates to invalid mac
From: David Miller @ 2016-04-11  2:26 UTC (permalink / raw)
  To: dbanerje; +Cc: j.vosburgh, vfalico, gospo, netdev, linux-kernel
In-Reply-To: <1459974275-24944-1-git-send-email-dbanerje@akamai.com>


Please resubmit this patch series with a proper cover letter.

It should have "[PATCH 0/3] ..." as the subject line and explain
at a high level what your patch series is doing, how it is doing
it, and why it is doing it that way.

You must also be explicit about which of my trees your changes
are targetting.

Thanks.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox