Re: ICMPv6 too big Packet will makes the network unreachable

2015-10-13 Thread Li RongQing
On Tue, Oct 13, 2015 at 10:26 PM, Hannes Frederic Sowa
 wrote:
>>root@du1:~# ip route get 2001:1b70:82a8:18:650:65:0:2
>>2001:1b70:82a8:18:650:65:0:2 dev eth10.650  src
>> 2001:1b70:82a8:18:650:65:0:2  metric 0
>>cache
>>root@du1:~#
>
> Which kernel version did you test this on?
>
> Thanks,
> Hannes


I think it is all version

-Roy
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [bug report or not] ping6 will lost packets when ping6 lots of ipv6 address

2015-10-13 Thread Li RongQing
On Wed, Oct 14, 2015 at 12:11 AM, Martin KaFai Lau  wrote:
> On Tue, Oct 13, 2015 at 08:46:49PM +0800, Li RongQing wrote:
>> 1. in a machine, configure 3000 ipv6 address in one interface
>>
>> for i in {1..3000}; do ip -6 addr add 4001:5013::$i/0 dev eth0; done
>>
>>
>> 2. in other machine, ping6 the upper configured ipv6 address, then
>> lots of lost packets
>>
>> ip -6 addr add 4001:5013::0/64 dev eth0
>> for i in {1..2000}; do ping6 -q -c1 4001:5013::$i; done;
>>
>> 3. increasing the gc thresh can handles these lost
>>
>> sysctl -w  net.ipv6.neigh.default.gc_thresh1=2000
>> sysctl -w  net.ipv6.neigh.default.gc_thresh2=3000
>> sysctl -w  net.ipv6.neigh.default.gc_thresh3=4000
>> sysctl -w net.ipv6.route.gc_thresh=3000
>> sysctl -w net.ipv6.route.max_size =3000
> Which kernel is used in this test?

all version, I think this should not a bug, this test will lead to
that the neigh number is
larger than net.ipv6.neigh.default.gc_thresh3, and can not allocate
new neigh, and ping
will lost packets.

Thanks


-Roy
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v6 06/10] qede: classification configuration

2015-10-13 Thread Yuval Mintz
From: Sudarsana Kalluru 

Add the ability to configure basic classification in driver by
implementing ndo_set_mac_address() and ndo_set_rx_mode().

Signed-off-by: Sudarsana Kalluru 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qede/qede.h  |  10 ++
 drivers/net/ethernet/qlogic/qede/qede_main.c | 241 +++
 2 files changed, 251 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qede/qede.h 
b/drivers/net/ethernet/qlogic/qede/qede.h
index 424ef4a..7947942 100644
--- a/drivers/net/ethernet/qlogic/qede/qede.h
+++ b/drivers/net/ethernet/qlogic/qede/qede.h
@@ -87,6 +87,9 @@ struct qede_dev {
struct qed_update_vport_rss_params  rss_params;
u16 q_num_rx_buffers; /* Must be a power of two */
u16 q_num_tx_buffers; /* Must be a power of two */
+
+   struct delayed_work sp_task;
+   unsigned long   sp_flags;
 };
 
 enum QEDE_STATE {
@@ -184,6 +187,13 @@ struct qede_fastpath {
 
 #define QEDE_CSUM_ERRORBIT(0)
 #define QEDE_CSUM_UNNECESSARY  BIT(1)
+
+#define QEDE_SP_RX_MODE1
+
+union qede_reload_args {
+   u16 mtu;
+};
+
 #define RX_RING_SIZE_POW   13
 #define RX_RING_SIZE   BIT(RX_RING_SIZE_POW)
 #define NUM_RX_BDS_MAX (RX_RING_SIZE - 1)
diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c 
b/drivers/net/ethernet/qlogic/qede/qede_main.c
index 81c8b15..7720571 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -1030,10 +1030,31 @@ static irqreturn_t qede_msix_fp_int(int irq, void 
*fp_cookie)
 
 static int qede_open(struct net_device *ndev);
 static int qede_close(struct net_device *ndev);
+static int qede_set_mac_addr(struct net_device *ndev, void *p);
+static void qede_set_rx_mode(struct net_device *ndev);
+static void qede_config_rx_mode(struct net_device *ndev);
+
+static int qede_set_ucast_rx_mac(struct qede_dev *edev,
+enum qed_filter_xcast_params_type opcode,
+unsigned char mac[ETH_ALEN])
+{
+   struct qed_filter_params filter_cmd;
+
+   memset(&filter_cmd, 0, sizeof(filter_cmd));
+   filter_cmd.type = QED_FILTER_TYPE_UCAST;
+   filter_cmd.filter.ucast.type = opcode;
+   filter_cmd.filter.ucast.mac_valid = 1;
+   ether_addr_copy(filter_cmd.filter.ucast.mac, mac);
+
+   return edev->ops->filter_config(edev->cdev, &filter_cmd);
+}
+
 static const struct net_device_ops qede_netdev_ops = {
.ndo_open = qede_open,
.ndo_stop = qede_close,
.ndo_start_xmit = qede_start_xmit,
+   .ndo_set_rx_mode = qede_set_rx_mode,
+   .ndo_set_mac_address = qede_set_mac_addr,
.ndo_validate_addr = eth_validate_addr,
 };
 
@@ -1198,6 +1219,20 @@ err:
return -ENOMEM;
 }
 
+static void qede_sp_task(struct work_struct *work)
+{
+   struct qede_dev *edev = container_of(work, struct qede_dev,
+sp_task.work);
+   mutex_lock(&edev->qede_lock);
+
+   if (edev->state == QEDE_STATE_OPEN) {
+   if (test_and_clear_bit(QEDE_SP_RX_MODE, &edev->sp_flags))
+   qede_config_rx_mode(edev->ndev);
+   }
+
+   mutex_unlock(&edev->qede_lock);
+}
+
 static void qede_update_pf_params(struct qed_dev *cdev)
 {
struct qed_pf_params pf_params;
@@ -1269,6 +1304,9 @@ static int __qede_probe(struct pci_dev *pdev, u32 
dp_module, u8 dp_level,
 
edev->ops->common->set_id(cdev, edev->ndev->name, DRV_MODULE_VERSION);
 
+   INIT_DELAYED_WORK(&edev->sp_task, qede_sp_task);
+   mutex_init(&edev->qede_lock);
+
DP_INFO(edev, "Ending successfully qede probe\n");
 
return 0;
@@ -1306,6 +1344,7 @@ static void __qede_remove(struct pci_dev *pdev, enum 
qede_remove_mode mode)
 
DP_INFO(edev, "Starting qede_remove\n");
 
+   cancel_delayed_work_sync(&edev->sp_task);
unregister_netdev(ndev);
 
edev->ops->common->set_power_state(cdev, PCI_D0);
@@ -2025,6 +2064,24 @@ static int qede_start_queues(struct qede_dev *edev)
return 0;
 }
 
+static int qede_set_mcast_rx_mac(struct qede_dev *edev,
+enum qed_filter_xcast_params_type opcode,
+unsigned char *mac, int num_macs)
+{
+   struct qed_filter_params filter_cmd;
+   int i;
+
+   memset(&filter_cmd, 0, sizeof(filter_cmd));
+   filter_cmd.type = QED_FILTER_TYPE_MCAST;
+   filter_cmd.filter.mcast.type = opcode;
+   filter_cmd.filter.mcast.num = num_macs;
+
+   for (i = 0; i < num_macs; i++, mac += ETH_ALEN)
+   ether_addr_copy(filter_cmd.filter.mcast.mac[i], mac);
+
+   return edev->ops->filter_config(edev->cdev, &filter_cmd);
+}
+
 enum qede_unload_mode {
QEDE_UNLOAD_NORMAL,
 };
@@ -2035,6 +2092,9 @@ static void q

[PATCH net-next v6 07/10] qed: Add link support

2015-10-13 Thread Yuval Mintz
Physical link is handled by the management Firmware.
This patch lays the infrastructure for attention handling in the driver,
as link change notifications arrive via async. attentions,
as well the handling of such notifications.

This patch also extends the API with the protocol drivers by adding registered
callbacks which the protocol driver passes to qed in order to be notified
of async. events originating from the FW/HW.

Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed.h  |  20 ++
 drivers/net/ethernet/qlogic/qed/qed_dev.c  | 106 -
 drivers/net/ethernet/qlogic/qed/qed_int.c  | 336 -
 drivers/net/ethernet/qlogic/qed/qed_l2.c   |   9 +
 drivers/net/ethernet/qlogic/qed/qed_main.c | 211 ++
 drivers/net/ethernet/qlogic/qed/qed_mcp.c  | 295 +
 drivers/net/ethernet/qlogic/qed/qed_mcp.h  | 126 ++-
 include/linux/qed/qed_eth_if.h |   4 +
 8 files changed, 1102 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed.h 
b/drivers/net/ethernet/qlogic/qed/qed.h
index e82fef1..b046f55 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -107,6 +107,18 @@ enum QED_FEATURE {
QED_MAX_FEATURES,
 };
 
+enum QED_PORT_MODE {
+   QED_PORT_MODE_DE_2X40G,
+   QED_PORT_MODE_DE_2X50G,
+   QED_PORT_MODE_DE_1X100G,
+   QED_PORT_MODE_DE_4X10G_F,
+   QED_PORT_MODE_DE_4X10G_E,
+   QED_PORT_MODE_DE_4X20G,
+   QED_PORT_MODE_DE_1X40G,
+   QED_PORT_MODE_DE_2X25G,
+   QED_PORT_MODE_DE_1X25G
+};
+
 struct qed_hw_info {
/* PCI personality */
enum qed_pci_personalitypersonality;
@@ -403,6 +415,13 @@ struct qed_dev {
u8  protocol;
 #define IS_QED_ETH_IF(cdev) ((cdev)->protocol == QED_PROTOCOL_ETH)
 
+   /* Callbacks to protocol driver */
+   union {
+   struct qed_common_cb_ops*common;
+   struct qed_eth_cb_ops   *eth;
+   } protocol_ops;
+   void*ops_cookie;
+
const struct firmware   *firmware;
 };
 
@@ -452,6 +471,7 @@ static inline u8 qed_concrete_to_sw_fid(struct qed_dev 
*cdev,
 /* Prototypes */
 int qed_fill_dev_info(struct qed_dev   *cdev,
  struct qed_dev_info   *dev_info);
+void qed_link_update(struct qed_hwfn *hwfn);
 u32 qed_unzip_data(struct qed_hwfn *p_hwfn,
   u32 input_len, u8 *input_buf,
   u32 max_size, u8 *unzip_buf);
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 200cde2..079cbfa 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -1034,8 +1034,9 @@ static void qed_hw_get_resc(struct qed_hwfn *p_hwfn)
 static int qed_hw_get_nvm_info(struct qed_hwfn *p_hwfn,
   struct qed_ptt   *p_ptt)
 {
-   u32 nvm_cfg1_offset, mf_mode, addr, generic_cont0, nvm_cfg_addr;
-   u32 val;
+   u32 nvm_cfg1_offset, mf_mode, addr, generic_cont0, core_cfg;
+   u32 port_cfg_addr, link_temp, val, nvm_cfg_addr;
+   struct qed_mcp_link_params *link;
 
/* Read global nvm_cfg address */
nvm_cfg_addr = qed_rd(p_hwfn, p_ptt, MISC_REG_GEN_PURP_CR0);
@@ -1055,6 +1056,48 @@ static int qed_hw_get_nvm_info(struct qed_hwfn   *p_hwfn,
   offsetof(struct nvm_cfg1_glob, pci_id);
p_hwfn->hw_info.vendor_id = qed_rd(p_hwfn, p_ptt, addr) &
NVM_CFG1_GLOB_VENDOR_ID_MASK;
+
+   addr = MCP_REG_SCRATCH + nvm_cfg1_offset +
+  offsetof(struct nvm_cfg1, glob) +
+  offsetof(struct nvm_cfg1_glob, core_cfg);
+
+   core_cfg = qed_rd(p_hwfn, p_ptt, addr);
+
+   switch ((core_cfg & NVM_CFG1_GLOB_NETWORK_PORT_MODE_MASK) >>
+   NVM_CFG1_GLOB_NETWORK_PORT_MODE_OFFSET) {
+   case NVM_CFG1_GLOB_NETWORK_PORT_MODE_DE_2X40G:
+   p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_2X40G;
+   break;
+   case NVM_CFG1_GLOB_NETWORK_PORT_MODE_DE_2X50G:
+   p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_2X50G;
+   break;
+   case NVM_CFG1_GLOB_NETWORK_PORT_MODE_DE_1X100G:
+   p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_1X100G;
+   break;
+   case NVM_CFG1_GLOB_NETWORK_PORT_MODE_DE_4X10G_F:
+   p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_4X10G_F;
+   break;
+   case NVM_CFG1_GLOB_NETWORK_PORT_MODE_DE_4X10G_E:
+   p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_4X10G_E;
+   break;
+   case NVM_CFG1_GLOB_NETWORK_PORT_MODE_DE_4X20G:
+   p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_4X20G;
+   break;
+   case NVM_CFG1_GLOB_NETWORK_PORT_MODE_DE_1X40G:
+   p_hwfn->hw_info.port_

[PATCH net-next v6 10/10] qede: Add basic ethtool support

2015-10-13 Thread Yuval Mintz
From: Sudarsana Kalluru 

This adds basic ethtool operations to the qed driver, allowing support in:
 - Statistics gathering [ethtool -S]
 - Setting of debug level [ethtool -s  msglvl]
 - Getting basic information [ethtool, ethtool -i]

In addition it adds the ability to change the MTU.

Signed-off-by: Sudarsana Kalluru 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qede/Makefile   |   2 +-
 drivers/net/ethernet/qlogic/qede/qede.h |  74 +
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 385 
 drivers/net/ethernet/qlogic/qede/qede_main.c| 137 -
 4 files changed, 596 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ethernet/qlogic/qede/qede_ethtool.c

diff --git a/drivers/net/ethernet/qlogic/qede/Makefile 
b/drivers/net/ethernet/qlogic/qede/Makefile
index bedfe9f..06ff90d 100644
--- a/drivers/net/ethernet/qlogic/qede/Makefile
+++ b/drivers/net/ethernet/qlogic/qede/Makefile
@@ -1,3 +1,3 @@
 obj-$(CONFIG_QEDE) := qede.o
 
-qede-y := qede_main.o
+qede-y := qede_main.o qede_ethtool.o
diff --git a/drivers/net/ethernet/qlogic/qede/qede.h 
b/drivers/net/ethernet/qlogic/qede/qede.h
index 7947942..ea00d5f 100644
--- a/drivers/net/ethernet/qlogic/qede/qede.h
+++ b/drivers/net/ethernet/qlogic/qede/qede.h
@@ -36,6 +36,70 @@
 
 #define DRV_MODULE_SYM qede
 
+struct qede_stats {
+   u64 no_buff_discards;
+   u64 rx_ucast_bytes;
+   u64 rx_mcast_bytes;
+   u64 rx_bcast_bytes;
+   u64 rx_ucast_pkts;
+   u64 rx_mcast_pkts;
+   u64 rx_bcast_pkts;
+   u64 mftag_filter_discards;
+   u64 mac_filter_discards;
+   u64 tx_ucast_bytes;
+   u64 tx_mcast_bytes;
+   u64 tx_bcast_bytes;
+   u64 tx_ucast_pkts;
+   u64 tx_mcast_pkts;
+   u64 tx_bcast_pkts;
+   u64 tx_err_drop_pkts;
+   u64 coalesced_pkts;
+   u64 coalesced_events;
+   u64 coalesced_aborts_num;
+   u64 non_coalesced_pkts;
+   u64 coalesced_bytes;
+
+   /* port */
+   u64 rx_64_byte_packets;
+   u64 rx_127_byte_packets;
+   u64 rx_255_byte_packets;
+   u64 rx_511_byte_packets;
+   u64 rx_1023_byte_packets;
+   u64 rx_1518_byte_packets;
+   u64 rx_1522_byte_packets;
+   u64 rx_2047_byte_packets;
+   u64 rx_4095_byte_packets;
+   u64 rx_9216_byte_packets;
+   u64 rx_16383_byte_packets;
+   u64 rx_crc_errors;
+   u64 rx_mac_crtl_frames;
+   u64 rx_pause_frames;
+   u64 rx_pfc_frames;
+   u64 rx_align_errors;
+   u64 rx_carrier_errors;
+   u64 rx_oversize_packets;
+   u64 rx_jabbers;
+   u64 rx_undersize_packets;
+   u64 rx_fragments;
+   u64 tx_64_byte_packets;
+   u64 tx_65_to_127_byte_packets;
+   u64 tx_128_to_255_byte_packets;
+   u64 tx_256_to_511_byte_packets;
+   u64 tx_512_to_1023_byte_packets;
+   u64 tx_1024_to_1518_byte_packets;
+   u64 tx_1519_to_2047_byte_packets;
+   u64 tx_2048_to_4095_byte_packets;
+   u64 tx_4096_to_9216_byte_packets;
+   u64 tx_9217_to_16383_byte_packets;
+   u64 tx_pause_frames;
+   u64 tx_pfc_frames;
+   u64 tx_lpi_entry_count;
+   u64 tx_total_collisions;
+   u64 brb_truncates;
+   u64 brb_discards;
+   u64 tx_mac_ctrl_frames;
+};
+
 struct qede_dev {
struct qed_dev  *cdev;
struct net_device   *ndev;
@@ -84,6 +148,7 @@ struct qede_dev {
max_t(u64, 1UL << QEDE_RX_ALIGN_SHIFT,  \
  SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
 
+   struct qede_stats   stats;
struct qed_update_vport_rss_params  rss_params;
u16 q_num_rx_buffers; /* Must be a power of two */
u16 q_num_tx_buffers; /* Must be a power of two */
@@ -194,6 +259,15 @@ union qede_reload_args {
u16 mtu;
 };
 
+void qede_config_debug(uint debug, u32 *p_dp_module, u8 *p_dp_level);
+void qede_set_ethtool_ops(struct net_device *netdev);
+void qede_reload(struct qede_dev *edev,
+void (*func)(struct qede_dev *edev,
+ union qede_reload_args *args),
+union qede_reload_args *args);
+int qede_change_mtu(struct net_device *dev, int new_mtu);
+void qede_fill_by_demand_stats(struct qede_dev *edev);
+
 #define RX_RING_SIZE_POW   13
 #define RX_RING_SIZE   BIT(RX_RING_SIZE_POW)
 #define NUM_RX_BDS_MAX (RX_RING_SIZE - 1)
diff --git a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c 
b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
new file mode 100644
index 000..3a36247
--- /dev/null
+++ b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
@@ -0,0 +1,385 @@
+/* QLogic qede NIC Driver
+* Copyright (c) 2015 QLogic Corporation
+*
+* This software is available under the terms of the GNU General Public License
+* (GPL) Version 2, available from the file COPYING in the main directory of
+* this source tre

[PATCH net-next v6 04/10] qed: Add slowpath L2 support

2015-10-13 Thread Yuval Mintz
From: Manish Chopra 

This patch adds to the qed the support to configure various L2 elements,
such as channels and basic filtering conditions.
It also enhances its public API to allow qede to later utilize this
functionality.

Signed-off-by: Manish Chopra 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_dev.c |  114 ++
 drivers/net/ethernet/qlogic/qed/qed_dev_api.h |   58 +
 drivers/net/ethernet/qlogic/qed/qed_hsi.h |  294 +
 drivers/net/ethernet/qlogic/qed/qed_l2.c  | 1660 +
 drivers/net/ethernet/qlogic/qed/qed_main.c|   10 +
 drivers/net/ethernet/qlogic/qed/qed_mcp.c |   16 +
 drivers/net/ethernet/qlogic/qed/qed_mcp.h |   13 +
 drivers/net/ethernet/qlogic/qed/qed_sp.h  |   27 +
 drivers/net/ethernet/qlogic/qed/qed_spq.c |   29 +
 include/linux/qed/qed_eth_if.h|  115 ++
 10 files changed, 2336 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index e00bf6b..200cde2 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -794,6 +794,60 @@ int qed_hw_stop(struct qed_dev *cdev)
return rc;
 }
 
+void qed_hw_stop_fastpath(struct qed_dev *cdev)
+{
+   int i, j;
+
+   for_each_hwfn(cdev, j) {
+   struct qed_hwfn *p_hwfn = &cdev->hwfns[j];
+   struct qed_ptt *p_ptt   = p_hwfn->p_main_ptt;
+
+   DP_VERBOSE(p_hwfn,
+  NETIF_MSG_IFDOWN,
+  "Shutting down the fastpath\n");
+
+   qed_wr(p_hwfn, p_ptt,
+  NIG_REG_RX_LLH_BRB_GATE_DNTFWD_PERPF, 0x1);
+
+   qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_TCP, 0x0);
+   qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_UDP, 0x0);
+   qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_FCOE, 0x0);
+   qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_ROCE, 0x0);
+   qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_OPENFLOW, 0x0);
+
+   qed_wr(p_hwfn, p_ptt, TM_REG_PF_ENABLE_CONN, 0x0);
+   qed_wr(p_hwfn, p_ptt, TM_REG_PF_ENABLE_TASK, 0x0);
+   for (i = 0; i < QED_HW_STOP_RETRY_LIMIT; i++) {
+   if ((!qed_rd(p_hwfn, p_ptt,
+TM_REG_PF_SCAN_ACTIVE_CONN)) &&
+   (!qed_rd(p_hwfn, p_ptt,
+TM_REG_PF_SCAN_ACTIVE_TASK)))
+   break;
+
+   usleep_range(1000, 2000);
+   }
+   if (i == QED_HW_STOP_RETRY_LIMIT)
+   DP_NOTICE(p_hwfn,
+ "Timers linear scans are not over [Connection 
%02x Tasks %02x]\n",
+ (u8)qed_rd(p_hwfn, p_ptt,
+TM_REG_PF_SCAN_ACTIVE_CONN),
+ (u8)qed_rd(p_hwfn, p_ptt,
+TM_REG_PF_SCAN_ACTIVE_TASK));
+
+   qed_int_igu_init_pure_rt(p_hwfn, p_ptt, false, false);
+
+   /* Need to wait 1ms to guarantee SBs are cleared */
+   usleep_range(1000, 2000);
+   }
+}
+
+void qed_hw_start_fastpath(struct qed_hwfn *p_hwfn)
+{
+   /* Re-open incoming traffic */
+   qed_wr(p_hwfn, p_hwfn->p_main_ptt,
+  NIG_REG_RX_LLH_BRB_GATE_DNTFWD_PERPF, 0x0);
+}
+
 static int qed_reg_assert(struct qed_hwfn *hwfn,
  struct qed_ptt *ptt, u32 reg,
  bool expected)
@@ -1343,3 +1397,63 @@ void qed_chain_free(struct qed_dev *cdev,
  p_chain->p_virt_addr,
  p_chain->p_phys_addr);
 }
+
+int qed_fw_l2_queue(struct qed_hwfn *p_hwfn,
+   u16 src_id, u16 *dst_id)
+{
+   if (src_id >= RESC_NUM(p_hwfn, QED_L2_QUEUE)) {
+   u16 min, max;
+
+   min = (u16)RESC_START(p_hwfn, QED_L2_QUEUE);
+   max = min + RESC_NUM(p_hwfn, QED_L2_QUEUE);
+   DP_NOTICE(p_hwfn,
+ "l2_queue id [%d] is not valid, available indices [%d 
- %d]\n",
+ src_id, min, max);
+
+   return -EINVAL;
+   }
+
+   *dst_id = RESC_START(p_hwfn, QED_L2_QUEUE) + src_id;
+
+   return 0;
+}
+
+int qed_fw_vport(struct qed_hwfn *p_hwfn,
+u8 src_id, u8 *dst_id)
+{
+   if (src_id >= RESC_NUM(p_hwfn, QED_VPORT)) {
+   u8 min, max;
+
+   min = (u8)RESC_START(p_hwfn, QED_VPORT);
+   max = min + RESC_NUM(p_hwfn, QED_VPORT);
+   DP_NOTICE(p_hwfn,
+ "vport id [%d] is not valid, available indices [%d - 
%d]\n",
+ src_id, min, max);
+
+   return -EINVAL;
+   }
+
+   *dst_id = RESC_START(p_hwfn, QED_VPORT) + src_id;
+
+   return 0;
+}
+
+int qed_fw_rss_eng(struct

[PATCH net-next v6 03/10] qede: Add basic Network driver

2015-10-13 Thread Yuval Mintz
The Qlogic Everest Driver for Ethernet is the Ethernet specifc module for
579xx ethernet products by Qlogic.

This patch adds a very minimal PCI driver, one that doesn't yet register
a network device, but one that does interact with qed and does a basic
initialization of the HW.

Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/Kconfig  |   5 +
 drivers/net/ethernet/qlogic/Makefile |   1 +
 drivers/net/ethernet/qlogic/qede/Makefile|   3 +
 drivers/net/ethernet/qlogic/qede/qede.h  |  73 ++
 drivers/net/ethernet/qlogic/qede/qede_main.c | 354 +++
 5 files changed, 436 insertions(+)
 create mode 100644 drivers/net/ethernet/qlogic/qede/Makefile
 create mode 100644 drivers/net/ethernet/qlogic/qede/qede.h
 create mode 100644 drivers/net/ethernet/qlogic/qede/qede_main.c

diff --git a/drivers/net/ethernet/qlogic/Kconfig 
b/drivers/net/ethernet/qlogic/Kconfig
index 58c3fb3..30a6f24 100644
--- a/drivers/net/ethernet/qlogic/Kconfig
+++ b/drivers/net/ethernet/qlogic/Kconfig
@@ -97,4 +97,9 @@ config QED
---help---
  This enables the support for ...
 
+config QEDE
+   tristate "QLogic QED 25/40/100Gb Ethernet NIC"
+   depends on QED
+   ---help---
+ This enables the support for ...
 endif # NET_VENDOR_QLOGIC
diff --git a/drivers/net/ethernet/qlogic/Makefile 
b/drivers/net/ethernet/qlogic/Makefile
index 7600138..cee90e0 100644
--- a/drivers/net/ethernet/qlogic/Makefile
+++ b/drivers/net/ethernet/qlogic/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_QLCNIC) += qlcnic/
 obj-$(CONFIG_QLGE) += qlge/
 obj-$(CONFIG_NETXEN_NIC) += netxen/
 obj-$(CONFIG_QED) += qed/
+obj-$(CONFIG_QEDE)+= qede/
diff --git a/drivers/net/ethernet/qlogic/qede/Makefile 
b/drivers/net/ethernet/qlogic/qede/Makefile
new file mode 100644
index 000..bedfe9f
--- /dev/null
+++ b/drivers/net/ethernet/qlogic/qede/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_QEDE) := qede.o
+
+qede-y := qede_main.o
diff --git a/drivers/net/ethernet/qlogic/qede/qede.h 
b/drivers/net/ethernet/qlogic/qede/qede.h
new file mode 100644
index 000..7e2bcfa
--- /dev/null
+++ b/drivers/net/ethernet/qlogic/qede/qede.h
@@ -0,0 +1,73 @@
+/* QLogic qede NIC Driver
+* Copyright (c) 2015 QLogic Corporation
+*
+* This software is available under the terms of the GNU General Public License
+* (GPL) Version 2, available from the file COPYING in the main directory of
+* this source tree.
+*/
+
+#ifndef _QEDE_H_
+#define _QEDE_H_
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define QEDE_MAJOR_VERSION 8
+#define QEDE_MINOR_VERSION 4
+#define QEDE_REVISION_VERSION  0
+#define QEDE_ENGINEERING_VERSION   0
+#define DRV_MODULE_VERSION __stringify(QEDE_MAJOR_VERSION) "." \
+   __stringify(QEDE_MINOR_VERSION) "." \
+   __stringify(QEDE_REVISION_VERSION) "."  \
+   __stringify(QEDE_ENGINEERING_VERSION)
+
+#define QEDE_ETH_INTERFACE_VERSION 300
+
+#define DRV_MODULE_SYM qede
+
+struct qede_dev {
+   struct qed_dev  *cdev;
+   struct net_device   *ndev;
+   struct pci_dev  *pdev;
+
+   u32 dp_module;
+   u8  dp_level;
+
+   const struct qed_eth_ops*ops;
+
+   struct qed_dev_eth_info dev_info;
+#define QEDE_MAX_RSS_CNT(edev) ((edev)->dev_info.num_queues)
+#define QEDE_MAX_TSS_CNT(edev) ((edev)->dev_info.num_queues * \
+(edev)->dev_info.num_tc)
+
+   u16 num_rss;
+   u8  num_tc;
+#define QEDE_RSS_CNT(edev) ((edev)->num_rss)
+#define QEDE_TSS_CNT(edev) ((edev)->num_rss *  \
+(edev)->num_tc)
+#define QEDE_TSS_IDX(edev, txqidx) ((txqidx) % (edev)->num_rss)
+#define QEDE_TC_IDX(edev, txqidx)  ((txqidx) / (edev)->num_rss)
+
+   struct qed_int_info int_info;
+   unsigned char   primary_mac[ETH_ALEN];
+
+   /* Smaller private varaiant of the RTNL lock */
+   struct mutexqede_lock;
+   u32 state; /* Protected by qede_lock */
+};
+
+/* Debug print definitions */
+#define DP_NAME(edev) ((edev)->ndev->name)
+
+#endif /* _QEDE_H_ */
diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c 
b/drivers/net/ethernet/qlogic/qede/qede_main.c
new file mode 100644
index 000..35065dc
--- /dev/null
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -0,0 +1,354 @@
+/* QLogic qede NIC Driver
+* Copyright (c) 2015 QLogic Corporation
+*
+* This software is available under the terms of the GNU General Public License
+* (GPL) Version 2, available from the file COPYING in the main directory of
+* this so

[PATCH net-next v6 08/10] qede: Add support for link

2015-10-13 Thread Yuval Mintz
From: Sudarsana Kalluru 

This adds basic link functionality to qede - driver still doesn't provide
users with an API to change any link property, but it does request qed to
initialize the link using default configuration, and registers a callback
that allows it to get link notifications.

This patch adds the ability of the driver to set the carrier as active and
to enable traffic as a result of async. link notifications.
Following this patch, driver should be capable of running traffic.

Signed-off-by: Sudarsana Kalluru 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qede/qede_main.c | 47 
 1 file changed, 47 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c 
b/drivers/net/ethernet/qlogic/qede/qede_main.c
index 7720571..f38a9d1 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -87,6 +87,7 @@ static int qede_probe(struct pci_dev *pdev, const struct 
pci_device_id *id);
 static void qede_remove(struct pci_dev *pdev);
 static int qede_alloc_rx_buffer(struct qede_dev *edev,
struct qede_rx_queue *rxq);
+static void qede_link_update(void *dev, struct qed_link_output *link);
 
 static struct pci_driver qede_pci_driver = {
.name = "qede",
@@ -95,6 +96,12 @@ static struct pci_driver qede_pci_driver = {
.remove = qede_remove,
 };
 
+static struct qed_eth_cb_ops qede_ll_ops = {
+   {
+   .link_update = qede_link_update,
+   },
+};
+
 static int qede_netdev_event(struct notifier_block *this, unsigned long event,
 void *ptr)
 {
@@ -1304,6 +1311,8 @@ static int __qede_probe(struct pci_dev *pdev, u32 
dp_module, u8 dp_level,
 
edev->ops->common->set_id(cdev, edev->ndev->name, DRV_MODULE_VERSION);
 
+   edev->ops->register_ops(cdev, &qede_ll_ops, edev);
+
INIT_DELAYED_WORK(&edev->sp_task, qede_sp_task);
mutex_init(&edev->qede_lock);
 
@@ -2088,6 +2097,7 @@ enum qede_unload_mode {
 
 static void qede_unload(struct qede_dev *edev, enum qede_unload_mode mode)
 {
+   struct qed_link_params link_params;
int rc;
 
DP_INFO(edev, "Starting qede unload\n");
@@ -2099,6 +2109,10 @@ static void qede_unload(struct qede_dev *edev, enum 
qede_unload_mode mode)
netif_tx_disable(edev->ndev);
netif_carrier_off(edev->ndev);
 
+   /* Reset the link */
+   memset(&link_params, 0, sizeof(link_params));
+   link_params.link_up = false;
+   edev->ops->common->set_link(edev->cdev, &link_params);
rc = qede_stop_queues(edev);
if (rc) {
qede_sync_free_irqs(edev);
@@ -2129,6 +2143,8 @@ enum qede_load_mode {
 
 static int qede_load(struct qede_dev *edev, enum qede_load_mode mode)
 {
+   struct qed_link_params link_params;
+   struct qed_link_output link_output;
int rc;
 
DP_INFO(edev, "Starting qede load\n");
@@ -2172,6 +2188,17 @@ static int qede_load(struct qede_dev *edev, enum 
qede_load_mode mode)
mutex_lock(&edev->qede_lock);
edev->state = QEDE_STATE_OPEN;
mutex_unlock(&edev->qede_lock);
+
+   /* Ask for link-up using current configuration */
+   memset(&link_params, 0, sizeof(link_params));
+   link_params.link_up = true;
+   edev->ops->common->set_link(edev->cdev, &link_params);
+
+   /* Query whether link is already-up */
+   memset(&link_output, 0, sizeof(link_output));
+   edev->ops->common->get_link(edev->cdev, &link_output);
+   qede_link_update(edev, &link_output);
+
DP_INFO(edev, "Ending successfully qede load\n");
 
return 0;
@@ -2212,6 +2239,26 @@ static int qede_close(struct net_device *ndev)
return 0;
 }
 
+static void qede_link_update(void *dev, struct qed_link_output *link)
+{
+   struct qede_dev *edev = dev;
+
+   if (!netif_running(edev->ndev)) {
+   DP_VERBOSE(edev, NETIF_MSG_LINK, "Interface is not running\n");
+   return;
+   }
+
+   if (link->link_up) {
+   DP_NOTICE(edev, "Link is up\n");
+   netif_tx_start_all_queues(edev->ndev);
+   netif_carrier_on(edev->ndev);
+   } else {
+   DP_NOTICE(edev, "Link is down\n");
+   netif_tx_disable(edev->ndev);
+   netif_carrier_off(edev->ndev);
+   }
+}
+
 static int qede_set_mac_addr(struct net_device *ndev, void *p)
 {
struct qede_dev *edev = netdev_priv(ndev);
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v6 05/10] qede: Add basic network device support

2015-10-13 Thread Yuval Mintz
From: Sudarsana Kalluru 

This patch includes the basic Rx/Tx support for the driver [although
carrier will still never be turned on].
Following this patch the driver registers a network device, initializes
it and prepares it for traffic.

Signed-off-by: Sudarsana Kalluru 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qede/qede.h  |  128 ++
 drivers/net/ethernet/qlogic/qede/qede_main.c | 1796 ++
 2 files changed, 1924 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qede/qede.h 
b/drivers/net/ethernet/qlogic/qede/qede.h
index 7e2bcfa..424ef4a 100644
--- a/drivers/net/ethernet/qlogic/qede/qede.h
+++ b/drivers/net/ethernet/qlogic/qede/qede.h
@@ -51,6 +51,7 @@ struct qede_dev {
 #define QEDE_MAX_TSS_CNT(edev) ((edev)->dev_info.num_queues * \
 (edev)->dev_info.num_tc)
 
+   struct qede_fastpath*fp_array;
u16 num_rss;
u8  num_tc;
 #define QEDE_RSS_CNT(edev) ((edev)->num_rss)
@@ -58,6 +59,9 @@ struct qede_dev {
 (edev)->num_tc)
 #define QEDE_TSS_IDX(edev, txqidx) ((txqidx) % (edev)->num_rss)
 #define QEDE_TC_IDX(edev, txqidx)  ((txqidx) / (edev)->num_rss)
+#define QEDE_TX_QUEUE(edev, txqidx)\
+   (&(edev)->fp_array[QEDE_TSS_IDX((edev), (txqidx))].txqs[QEDE_TC_IDX( \
+   (edev), (txqidx))])
 
struct qed_int_info int_info;
unsigned char   primary_mac[ETH_ALEN];
@@ -65,9 +69,133 @@ struct qede_dev {
/* Smaller private varaiant of the RTNL lock */
struct mutexqede_lock;
u32 state; /* Protected by qede_lock */
+   u16 rx_buf_size;
+   /* L2 header size + 2*VLANs (8 bytes) + LLC SNAP (8 bytes) */
+#define ETH_OVERHEAD   (ETH_HLEN + 8 + 8)
+   /* Max supported alignment is 256 (8 shift)
+* minimal alignment shift 6 is optimal for 57xxx HW performance
+*/
+#define QEDE_RX_ALIGN_SHIFTmax(6, min(8, L1_CACHE_SHIFT))
+   /* We assume skb_build() uses sizeof(struct skb_shared_info) bytes
+* at the end of skb->data, to avoid wasting a full cache line.
+* This reduces memory use (skb->truesize).
+*/
+#define QEDE_FW_RX_ALIGN_END   \
+   max_t(u64, 1UL << QEDE_RX_ALIGN_SHIFT,  \
+ SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
+
+   struct qed_update_vport_rss_params  rss_params;
+   u16 q_num_rx_buffers; /* Must be a power of two */
+   u16 q_num_tx_buffers; /* Must be a power of two */
+};
+
+enum QEDE_STATE {
+   QEDE_STATE_CLOSED,
+   QEDE_STATE_OPEN,
+};
+
+#define HILO_U64(hi, lo)   u64)(hi)) << 32) + (lo))
+
+#defineMAX_NUM_TC  8
+#defineMAX_NUM_PRI 8
+
+/* The driver supports the new build_skb() API:
+ * RX ring buffer contains pointer to kmalloc() data only,
+ * skb are built only after the frame was DMA-ed.
+ */
+struct sw_rx_data {
+   u8 *data;
+
+   DEFINE_DMA_UNMAP_ADDR(mapping);
+};
+
+struct qede_rx_queue {
+   __le16  *hw_cons_ptr;
+   struct sw_rx_data   *sw_rx_ring;
+   u16 sw_rx_cons;
+   u16 sw_rx_prod;
+   struct qed_chainrx_bd_ring;
+   struct qed_chainrx_comp_ring;
+   void __iomem*hw_rxq_prod_addr;
+
+   int rx_buf_size;
+
+   u16 num_rx_buffers;
+   u16 rxq_id;
+
+   u64 rx_hw_errors;
+   u64 rx_alloc_errors;
+};
+
+union db_prod {
+   struct eth_db_data data;
+   u32 raw;
+};
+
+struct sw_tx_bd {
+   struct sk_buff *skb;
+   u8 flags;
+/* Set on the first BD descriptor when there is a split BD */
+#define QEDE_TSO_SPLIT_BD  BIT(0)
+};
+
+struct qede_tx_queue {
+   int index; /* Queue index */
+   __le16  *hw_cons_ptr;
+   struct sw_tx_bd *sw_tx_ring;
+   u16 sw_tx_cons;
+   u16 sw_tx_prod;
+   struct qed_chaintx_pbl;
+   void __iomem*doorbell_addr;
+   union db_prod   tx_db;
+
+   u16 num_tx_buffers;
+};
+
+#define BD_UNMAP_ADDR(bd)  HILO_U64(le32_to_cpu((bd)->addr.hi), \
+le32_to_cpu((bd)->addr.lo))
+#define BD_SET_UNMAP_ADDR_LEN(bd, maddr, len)  \
+   do {\
+   (bd)->addr.hi = cpu_to_le32(upper_32_

[PATCH net-next v6 09/10] qed: Add statistics support

2015-10-13 Thread Yuval Mintz
From: Manish Chopra 

Device statistics can be gathered on-demand. This adds the qed support for
reading the statistics [both function and port] from the device, and adds
to the public API a method for requesting the current statistics.

Signed-off-by: Manish Chopra 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed.h |  14 ++
 drivers/net/ethernet/qlogic/qed/qed_dev.c | 244 +-
 drivers/net/ethernet/qlogic/qed/qed_dev_api.h |   3 +
 drivers/net/ethernet/qlogic/qed/qed_hsi.h |  30 
 drivers/net/ethernet/qlogic/qed/qed_l2.c  |   3 +
 include/linux/qed/qed_eth_if.h|   3 +
 6 files changed, 296 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed.h 
b/drivers/net/ethernet/qlogic/qed/qed.h
index b046f55..d574d58 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -211,7 +211,20 @@ struct qed_qm_info {
u32 pf_rl;
 };
 
+struct storm_stats {
+   u32 address;
+   u32 len;
+};
+
+struct qed_storm_stats {
+   struct storm_stats mstats;
+   struct storm_stats pstats;
+   struct storm_stats tstats;
+   struct storm_stats ustats;
+};
+
 struct qed_fw_data {
+   struct fw_ver_info  *fw_ver_info;
const u8*modes_tree_buf;
union init_op   *init_ops;
const u32   *arr_data;
@@ -295,6 +308,7 @@ struct qed_hwfn {
 
/* QM init */
struct qed_qm_info  qm_info;
+   struct qed_storm_stats  storm_stats;
 
/* Buffer for unzipping firmware data */
void*unzip_buf;
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 079cbfa..696e45d 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -644,8 +644,10 @@ int qed_hw_init(struct qed_dev *cdev,
bool allow_npar_tx_switch,
const u8 *bin_fw_data)
 {
-   u32 load_code, param;
+   struct qed_storm_stats *p_stat;
+   u32 load_code, param, *p_address;
int rc, mfw_rc, i;
+   u8 fw_vport = 0;
 
rc = qed_init_fw_data(cdev, bin_fw_data);
if (rc != 0)
@@ -654,6 +656,10 @@ int qed_hw_init(struct qed_dev *cdev,
for_each_hwfn(cdev, i) {
struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
 
+   rc = qed_fw_vport(p_hwfn, 0, &fw_vport);
+   if (rc != 0)
+   return rc;
+
/* Enable DMAE in PXP */
rc = qed_change_pci_hwfn(p_hwfn, p_hwfn->p_main_ptt, true);
 
@@ -717,6 +723,25 @@ int qed_hw_init(struct qed_dev *cdev,
}
 
p_hwfn->hw_init_done = true;
+
+   /* init PF stats */
+   p_stat = &p_hwfn->storm_stats;
+   p_stat->mstats.address = BAR0_MAP_REG_MSDM_RAM +
+MSTORM_QUEUE_STAT_OFFSET(fw_vport);
+   p_stat->mstats.len = sizeof(struct eth_mstorm_per_queue_stat);
+
+   p_stat->ustats.address = BAR0_MAP_REG_USDM_RAM +
+USTORM_QUEUE_STAT_OFFSET(fw_vport);
+   p_stat->ustats.len = sizeof(struct eth_ustorm_per_queue_stat);
+
+   p_stat->pstats.address = BAR0_MAP_REG_PSDM_RAM +
+PSTORM_QUEUE_STAT_OFFSET(fw_vport);
+   p_stat->pstats.len = sizeof(struct eth_pstorm_per_queue_stat);
+
+   p_address = &p_stat->tstats.address;
+   *p_address = BAR0_MAP_REG_TSDM_RAM +
+TSTORM_PORT_STAT_OFFSET(MFW_PORT(p_hwfn));
+   p_stat->tstats.len = sizeof(struct tstorm_per_port_stat);
}
 
return 0;
@@ -1500,6 +1525,223 @@ void qed_chain_free(struct qed_dev *cdev,
  p_chain->p_phys_addr);
 }
 
+static void __qed_get_vport_stats(struct qed_dev   *cdev,
+ struct qed_eth_stats  *stats)
+{
+   int i, j;
+
+   memset(stats, 0, sizeof(*stats));
+
+   for_each_hwfn(cdev, i) {
+   struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
+   struct eth_mstorm_per_queue_stat mstats;
+   struct eth_ustorm_per_queue_stat ustats;
+   struct eth_pstorm_per_queue_stat pstats;
+   struct tstorm_per_port_stat tstats;
+   struct port_stats port_stats;
+   struct qed_ptt *p_ptt = qed_ptt_acquire(p_hwfn);
+
+   if (!p_ptt) {
+   DP_ERR(p_hwfn, "Failed to acquire ptt\n");
+   continue;
+   }
+
+   memset(&mstats, 0, sizeof(mstats));
+   qed_memcpy_from(p_hwfn, p_ptt, &mstats,
+   p_hwfn->storm_stats.mstats.address,
+   

[PATCH net-next v6 02/10] qed: Add basic L2 interface

2015-10-13 Thread Yuval Mintz
From: Manish Chopra 

This patch adds a public API for a network driver to work on top of QED.
The interface itself is very minimal - it's mostly infrastructure, as the
only content it has after this patch is a query for HW-based information
required for the creation of a network interface [I.e., no actual
protocol-specific configurations are supported].

Signed-off-by: Manish Chopra 
Signed-off-by: Yuval Mintz 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/Makefile  |   2 +-
 drivers/net/ethernet/qlogic/qed/qed.h |  14 ++
 drivers/net/ethernet/qlogic/qed/qed_dev.c |  62 +++
 drivers/net/ethernet/qlogic/qed/qed_hsi.h |   1 +
 drivers/net/ethernet/qlogic/qed/qed_l2.c  |  87 ++
 include/linux/qed/eth_common.h| 278 ++
 include/linux/qed/qed_eth_if.h|  38 
 7 files changed, 481 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/qlogic/qed/qed_l2.c
 create mode 100644 include/linux/qed/eth_common.h
 create mode 100644 include/linux/qed/qed_eth_if.h

diff --git a/drivers/net/ethernet/qlogic/qed/Makefile 
b/drivers/net/ethernet/qlogic/qed/Makefile
index 5bbe0c7..dbe6938 100644
--- a/drivers/net/ethernet/qlogic/qed/Makefile
+++ b/drivers/net/ethernet/qlogic/qed/Makefile
@@ -1,3 +1,3 @@
 obj-$(CONFIG_QED) := qed.o
 
-qed-y := qed_cxt.o qed_dev.o qed_hw.o qed_init_fw_funcs.o qed_init_ops.o 
qed_int.o qed_main.o qed_mcp.o qed_sp_commands.o qed_spq.o
+qed-y := qed_cxt.o qed_dev.o qed_hw.o qed_init_fw_funcs.o qed_init_ops.o 
qed_int.o qed_l2.o qed_main.o qed_mcp.o qed_sp_commands.o qed_spq.o
diff --git a/drivers/net/ethernet/qlogic/qed/qed.h 
b/drivers/net/ethernet/qlogic/qed/qed.h
index 727f76a..e82fef1 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -24,6 +24,7 @@
 #include 
 #include "qed_hsi.h"
 
+extern const struct qed_common_ops qed_common_ops_pass;
 #define DRV_MODULE_VERSION "8.4.0.0"
 
 #define MAX_HWFNS_PER_DEVICE(4)
@@ -90,13 +91,22 @@ struct qed_qm_iids {
 
 enum QED_RESOURCES {
QED_SB,
+   QED_L2_QUEUE,
QED_VPORT,
+   QED_RSS_ENG,
QED_PQ,
QED_RL,
+   QED_MAC,
+   QED_VLAN,
QED_ILT,
QED_MAX_RESC,
 };
 
+enum QED_FEATURE {
+   QED_PF_L2_QUE,
+   QED_MAX_FEATURES,
+};
+
 struct qed_hw_info {
/* PCI personality */
enum qed_pci_personalitypersonality;
@@ -104,6 +114,7 @@ struct qed_hw_info {
/* Resource Allocation scheme results */
u32 resc_start[QED_MAX_RESC];
u32 resc_num[QED_MAX_RESC];
+   u32 feat_num[QED_MAX_FEATURES];
 
 #define RESC_START(_p_hwfn, resc) ((_p_hwfn)->hw_info.resc_start[resc])
 #define RESC_NUM(_p_hwfn, resc) ((_p_hwfn)->hw_info.resc_num[resc])
@@ -265,6 +276,9 @@ struct qed_hwfn {
 
struct qed_mcp_info *mcp_info;
 
+   struct qed_hw_cid_data  *p_tx_cids;
+   struct qed_hw_cid_data  *p_rx_cids;
+
struct qed_dmae_infodmae_info;
 
/* QM init */
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index a088e1a..e00bf6b 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -92,6 +92,15 @@ void qed_resc_free(struct qed_dev *cdev)
for_each_hwfn(cdev, i) {
struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
 
+   kfree(p_hwfn->p_tx_cids);
+   p_hwfn->p_tx_cids = NULL;
+   kfree(p_hwfn->p_rx_cids);
+   p_hwfn->p_rx_cids = NULL;
+   }
+
+   for_each_hwfn(cdev, i) {
+   struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
+
qed_cxt_mngr_free(p_hwfn);
qed_qm_info_free(p_hwfn);
qed_spq_free(p_hwfn);
@@ -202,6 +211,29 @@ int qed_resc_alloc(struct qed_dev *cdev)
if (!cdev->fw_data)
return -ENOMEM;
 
+   /* Allocate Memory for the Queue->CID mapping */
+   for_each_hwfn(cdev, i) {
+   struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
+   int tx_size = sizeof(struct qed_hw_cid_data) *
+ RESC_NUM(p_hwfn, QED_L2_QUEUE);
+   int rx_size = sizeof(struct qed_hw_cid_data) *
+ RESC_NUM(p_hwfn, QED_L2_QUEUE);
+
+   p_hwfn->p_tx_cids = kzalloc(tx_size, GFP_KERNEL);
+   if (!p_hwfn->p_tx_cids) {
+   DP_NOTICE(p_hwfn,
+ "Failed to allocate memory for Tx Cids\n");
+   goto alloc_err;
+   }
+
+   p_hwfn->p_rx_cids = kzalloc(rx_size, GFP_KERNEL);
+   if (!p_hwfn->p_rx_cids) {
+   DP_NOTICE(p_hwfn,
+ "Failed to allocate memory for Rx Cids\n");
+

[PATCH net-next v6 00/10] Add new drivers: qed & qede

2015-10-13 Thread Yuval Mintz
From: Ariel Elior 

This series implements the driver set for Qlogic's new 579xx series.
These are 10/20/25/40/50/100 Gig capable converged nics, supporting
ethernet (obviously), iscsi, fcoe, roce and iwarp protocols.

The overall driver design includes a common module ('qed') and protocol
specific dependent modules for ethernet ('qede'), fcoe ('qedf'),
iscsi ('qedi') and roce ('qedr').
The common module contains all of the common logic, e.g. initialization,
cleanup, infrastructure for interrupt handling, link management, slowpath
etc. as well as protocol agnostic features, and supplying an abstraction
layer for other modules.
The protocol specific modules can be compiled and operated independently
of each other, with the exception of the rdma modules which are dependent
on the ethernet module, in accordance with the kernel rdma stack design.

This series only adds the core and ethernet modules, with basic L2
capabilities. Future series will add the rest of the modules and enhance
the L2 functionality.

Ths patch series is constructed of the following patches:
qed:  Add module with basic common support
qed:  Add basic L2 interface
qede: Add basic Network driver
qed:  Add slowpath L2 support
qede: Add basic network device support
qede: Add classification configuration
qed:  Add link support
qede: Add support for link
qed:  Add statistics support
qede: Add basic ethtool support

This project is a team effort, thanks go to Yuval Mintz, Dmitry Kravkov,
Michal Kalderon, Tomer Tayar, Manish Chopra, Sudarsana Kalluru,
Rajesh Borundia, Sony Chacko, Artum Zolotushko, Harish Patil, Rasesh Mody,
Sergey Ukhterov and Elad Manela, as well as former team members,
Eilon Greenstein and Shmulik Ravid.

Changes from previos version:
-

>From Version 5:
  - Style change and fixes [mostly in patches 1, 4 and 7].
Thanks go to Francois Romieu, a mere mortal. ;-)

>From Version 4:
  - Drop dependency for x86_64.

>From Version 3:
  - Limit support of initial submission to x86_64.
  - Fix endian problems appearing via sparse [although no BE support yet].
  - Fix small issues suggested by the kbuild test robot.

>From Version 2:
  - Removed U64_{HI,LO}; Using {upper,lower}_32_bits instead.
  - Use regular napi weight definition.
  - [We still use the __le variants for variables, since we didn't get
 a reply regarding the change into non-user API types].

>From Version 1:
  - Removed private license file; Instead revised comments at source headers.

Thanks,
Ariel Elior
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next] switchdev: enforce no pvid flag in vlan ranges

2015-10-13 Thread Ido Schimmel
Tue, Oct 13, 2015 at 05:32:26PM IDT, vivien.dide...@savoirfairelinux.com wrote:
>On Oct. Tuesday 13 (42) 11:31 AM, Ido Schimmel wrote:
>> Mon, Oct 12, 2015 at 08:36:25PM IDT, vivien.dide...@savoirfairelinux.com 
>> wrote:
>> >Hi guys,
>> >
>> >On Oct. Monday 12 (42) 02:01 PM, Nikolay Aleksandrov wrote:
>> >> From: Nikolay Aleksandrov 
>> >> 
>> >> We shouldn't allow BRIDGE_VLAN_INFO_PVID flag in VLAN ranges.
>> >> 
>> >> Signed-off-by: Nikolay Aleksandrov 
>> >> ---
>> >>  net/switchdev/switchdev.c | 3 +++
>> >>  1 file changed, 3 insertions(+)
>> >> 
>> >> diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
>> >> index 6e4a4f9ad927..256c596de896 100644
>> >> --- a/net/switchdev/switchdev.c
>> >> +++ b/net/switchdev/switchdev.c
>> >> @@ -720,6 +720,9 @@ static int switchdev_port_br_afspec(struct net_device 
>> >> *dev,
>> >>   if (vlan.vid_begin)
>> >>   return -EINVAL;
>> >>   vlan.vid_begin = vinfo->vid;
>> >> + /* don't allow range of pvids */
>> >> + if (vlan.flags & BRIDGE_VLAN_INFO_PVID)
>> >> + return -EINVAL;
>> >>   } else if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_END) {
>> >>   if (!vlan.vid_begin)
>> >>   return -EINVAL;
>> >> -- 
>> >> 2.4.3
>> >> 
>> >
>> >Yes the patch looks good, but it is a minor check though. I hope the
>> >subject of this thread is making sense.
>> >
>> >VLAN ranges seem to have been included for an UX purpose (so commands
>> >look like Cisco IOS). We don't want to change any existing interface, so
>> >we pushed that down to drivers, with the only valid reason that, maybe
>> >one day, an hardware can be capable of programming a range on a per-port
>> >basis.
>> Hi,
>> 
>> That's actually what we are doing in mlxsw. We can do up to 256 entries in
>> one go. We've yet to submit this part.
>
>Perfect Ido, thanks for pointing this out! I'm OK with the range then. 
>
>So there is now a very last question in my head for this, which is more
>a matter of kernel design. Should the user be aware of such underlying
>support? In other words, would it make sense to do this in a driver:
>
>foo_port_vlan_add(struct net_device *dev,
>  struct switchdev_obj_port_vlan *vlan)
>{
>if (vlan->vid_begin != vlan->vid_end)
>return -ENOTSUPP; /* or something more relevant for user */
>
>return foo_port_single_vlan_add(dev, vlan->vid_begin);
>}
>
>So drivers keep being simple, and we can easily propagate the fact that
>one-or-all VLAN is not supportable, vs. the VLAN feature itself is not
>implemented and must be done in software.
I think that if you want to keep it simple, then Scott's advice from the
previous thread is the most appropriate one. I believe the hardware you
are using is simply not meant to support multiple 802.1Q bridges.

Trying to go around this will simply result in weird behavior (such as
not supporting VLAN ranges), which is only sacrificed to support
something a user doesn't even require (given the fact he's aware the
hardware is meant to support only one 802.1Q bridge).

What do you think?
>
>I'm not sure how transparent the hardware must be to the user.
>
>(the problem of one VLAN unsupported in a range is still something we
>need to address).
>
>> 
>> >
>> >So what happens is that we'll add some code to fix and check non-sense
>> >(e.g. range + PVID) in switchdev, bridge, and I'm sure we are missing
>> >other spots.
>> >
>> >Sorry for being insistent, but this still doesn't look right to me.
>> >
>> >It seems like we are bloating bridge, switchdev and drivers for the only
>> >reason to maintain a kernel support for something like:
>> >
>> ># for i in $(seq 100 4000); do bridge vlan add vid $i dev swp0; done
>
>Thanks,
>-v
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: NULL pointer dereference in rt6_get_cookie()

2015-10-13 Thread Martin KaFai Lau
On Tue, Oct 13, 2015 at 09:26:41PM +0200, Phil Sutter wrote:
> I have backed up the rt pointer at top of the function and restored it
> before pr_err, this is the output:
>
> | rt6i_dst:2001:4dd0:ff3b:13::/64 rt6i_gateway::: rt6i_flags:4001 
> dst.flags:
Hi Phil, Can you try the following patch and report the pr_err?

Thanks,
Martin

--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -262,7 +262,7 @@ static struct dst_ops ip6_dst_blackhole_ops = {
.default_advmss =   ip6_default_advmss,
.update_pmtu=   ip6_rt_blackhole_update_pmtu,
.redirect   =   ip6_rt_blackhole_redirect,
-   .cow_metrics=   ip6_rt_blackhole_cow_metrics,
+   .cow_metrics=   dst_cow_metrics_generic,
.neigh_lookup   =   ip6_neigh_lookup,
 };

@@ -1201,21 +1201,20 @@ struct dst_entry *ip6_blackhole_route(struct net *net, 
struct dst_entry *dst_ori
new = &rt->dst;

memset(new + 1, 0, sizeof(*rt) - sizeof(*new));
+   INIT_LIST_HEAD(&rt->rt6i_siblings);
+   INIT_LIST_HEAD(&rt->rt6i_uncached);

new->__use = 1;
new->input = dst_discard;
new->output = dst_discard_out;

-   if (dst_metrics_read_only(&ort->dst))
-   new->_metrics = ort->dst._metrics;
-   else
-   dst_copy_metrics(new, &ort->dst);
+   dst_copy_metrics(new, &ort->dst);
rt->rt6i_idev = ort->rt6i_idev;
if (rt->rt6i_idev)
in6_dev_hold(rt->rt6i_idev);

rt->rt6i_gateway = ort->rt6i_gateway;
-   rt->rt6i_flags = ort->rt6i_flags;
+   rt->rt6i_flags = ort->rt6i_flags & (~RTF_PCPU);
rt->rt6i_metric = 0;

memcpy(&rt->rt6i_dst, &ort->rt6i_dst, sizeof(struct rt6key));
@@ -1223,6 +1222,19 @@ struct dst_entry *ip6_blackhole_route(struct net *net, 
struct dst_entry *dst_ori
memcpy(&rt->rt6i_src, &ort->rt6i_src, sizeof(struct rt6key));
 #endif

+   pr_err("ort:%p rt6i_dst:[%pI6c]/%d rt6i_gateway:[%pI6c] "
+  "rt6i_flags:%08X dst.flags:%08X\n",
+  ort,
+  &ort->rt6i_dst.addr, ort->rt6i_dst.plen,
+  &ort->rt6i_gateway, ort->rt6i_flags,
+  ort->dst.flags);
+   pr_err(" rt:%p rt6i_dst:[%pI6c]/%d rt6i_gateway:[%pI6c] "
+  "rt6i_flags:%08X dst.flags:%08X\n",
+  rt,
+  &rt->rt6i_dst.addr, rt->rt6i_dst.plen,
+  &rt->rt6i_gateway, rt->rt6i_flags,
+  rt->dst.flags);
+
dst_free(new);
}
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 4/4] bridge: Remove br_get_link_af_size

2015-10-13 Thread Ronen Arad
Unset get_link_af_size in br_af_ops. br_get_link_af_size() becomes
unused and thus removed.

Signed-off-by: Ronen Arad 
---
 net/bridge/br_netlink.c | 20 
 1 file changed, 20 deletions(-)

diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index d900881..204222d 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -1214,29 +1214,9 @@ static int br_fill_info(struct sk_buff *skb, const 
struct net_device *brdev)
return 0;
 }
 
-static size_t br_get_link_af_size(const struct net_device *dev)
-{
-   struct net_bridge_port *p;
-   struct net_bridge *br;
-   int num_vlans = 0;
-
-   if (br_port_exists(dev)) {
-   p = br_port_get_rtnl(dev);
-   num_vlans = br_get_num_vlan_infos(nbp_vlan_group(p),
- RTEXT_FILTER_BRVLAN);
-   } else if (dev->priv_flags & IFF_EBRIDGE) {
-   br = netdev_priv(dev);
-   num_vlans = br_get_num_vlan_infos(br_vlan_group(br),
- RTEXT_FILTER_BRVLAN);
-   }
-
-   /* Each VLAN is returned in bridge_vlan_info along with flags */
-   return num_vlans * nla_total_size(sizeof(struct bridge_vlan_info));
-}
 
 static struct rtnl_af_ops br_af_ops __read_mostly = {
.family = AF_BRIDGE,
-   .get_link_af_size   = br_get_link_af_size,
.get_link_af_size_filtered  = br_get_link_af_size_filtered,
 };
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 2/4] bridge: br_af_ops add br_get_link_af_size_filtered

2015-10-13 Thread Ronen Arad
Provide get_af_size_filtered (set to br_get_link_af_size_filtered)
in br_af_ops for proper filtering mask aware sizing of AF_BRIDGE
attributes. This is an optimization of netlink message size when
-c[compressvlans] option is entered for iproute2's bridge command.
Optimization will get into effect with rtnetlink change in the next
patch of this set.

Signed-off-by: Ronen Arad 
---
 net/bridge/br_netlink.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 94b4de8..d900881 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -1235,8 +1235,9 @@ static size_t br_get_link_af_size(const struct net_device 
*dev)
 }
 
 static struct rtnl_af_ops br_af_ops __read_mostly = {
-   .family = AF_BRIDGE,
-   .get_link_af_size   = br_get_link_af_size,
+   .family = AF_BRIDGE,
+   .get_link_af_size   = br_get_link_af_size,
+   .get_link_af_size_filtered  = br_get_link_af_size_filtered,
 };
 
 struct rtnl_link_ops br_link_ops __read_mostly = {
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 1/4] rtnetlink: Add get_link_af_size_filtered to rtnl_af_ops

2015-10-13 Thread Ronen Arad
get_link_af_size_filtered() - a filtering-mask aware alternative
function is added to struct rtnl_af_ops in order to allow for
"rightsizing" the IFLA_AF_SPEC calculation in if_nlmsg_size().
This significantly reduces the message size when at least one netdev has
large number of VLANs.

Signed-off-by: Ronen Arad 
---
 include/net/rtnetlink.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index aff6ceb..96df9bb 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -130,6 +130,8 @@ struct rtnl_af_ops {
const struct nlattr *attr);
int (*set_link_af)(struct net_device *dev,
   const struct nlattr *attr);
+   size_t  (*get_link_af_size_filtered)(const struct 
net_device *dev,
+u32 
ext_filter_mask);
 };
 
 void __rtnl_af_unregister(struct rtnl_af_ops *ops);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 3/4] rtnetlink: Prefer filtering-aware af sizing

2015-10-13 Thread Ronen Arad
Add ext_filter_mask arg to rtnl_link_get_af_size().
rtnl_link_get_af_size() will prefer filtering-aware af sizing when
provided by an address family. It falls back to get_link_af_size for
other families.

Signed-off-by: Ronen Arad 
---
 net/core/rtnetlink.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 2477595..dd7cda7 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -497,7 +497,8 @@ void rtnl_af_unregister(struct rtnl_af_ops *ops)
 }
 EXPORT_SYMBOL_GPL(rtnl_af_unregister);
 
-static size_t rtnl_link_get_af_size(const struct net_device *dev)
+static size_t rtnl_link_get_af_size(const struct net_device *dev,
+   u32 ext_filter_mask)
 {
struct rtnl_af_ops *af_ops;
size_t size;
@@ -506,7 +507,12 @@ static size_t rtnl_link_get_af_size(const struct 
net_device *dev)
size = nla_total_size(sizeof(struct nlattr));
 
list_for_each_entry(af_ops, &rtnl_af_ops, list) {
-   if (af_ops->get_link_af_size) {
+   /* Prefer filtering-aware af sizing when available */
+   if (af_ops->get_link_af_size_filtered) {
+   /* AF_* + nested data */
+   size += nla_total_size(sizeof(struct nlattr)) +
+   af_ops->get_link_af_size_filtered(dev, 
ext_filter_mask);
+   } else if (af_ops->get_link_af_size) {
/* AF_* + nested data */
size += nla_total_size(sizeof(struct nlattr)) +
af_ops->get_link_af_size(dev);
@@ -900,7 +906,7 @@ static noinline size_t if_nlmsg_size(const struct 
net_device *dev,
   + rtnl_vfinfo_size(dev, ext_filter_mask) /* IFLA_VFINFO_LIST */
   + rtnl_port_size(dev, ext_filter_mask) /* IFLA_VF_PORTS + 
IFLA_PORT_SELF */
   + rtnl_link_get_size(dev) /* IFLA_LINKINFO */
-  + rtnl_link_get_af_size(dev) /* IFLA_AF_SPEC */
+  + rtnl_link_get_af_size(dev, ext_filter_mask) /* IFLA_AF_SPEC */
   + nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_PORT_ID */
   + nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_SWITCH_ID */
   + nla_total_size(1); /* IFLA_PROTO_DOWN */
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 0/4] Rightsize IFLA_AF_SPEC size calculation

2015-10-13 Thread Ronen Arad
if_nlmsg_size() overestimates the minimum allocation size of netlink dump
request (when called from rtnl_calcit()) or the size of the message (when called
from rtnl_getlink()). This is because ext_filter_mask is not supported by
rtnl_link_get_af_size() and rtnl_link_get_size().

The over-estimation is significant when at least one netdev has many VLANs
configured (8 bytes for each configured VLAN).

This patch-set "rightsizes" the protocol specific attribute size calculation by
propagating ext_filter_mask to rtnl_link_get_af_size() and adding optional
filtering aware get_af_size_filtered op in struct rtnl_af_ops. Bridge module,
which already used filtering aware sizing for notification, is enhanced to do
the same for netlink dump requests.

Ronen Arad (4):
  rtnetlink: Add get_link_af_size_filtered to rtnl_af_ops
  bridge: br_af_ops add br_get_link_af_size_filtered
  rtnetlink: Prefer filtering-aware af sizing
  bridge: Remove br_get_link_af_size

 include/net/rtnetlink.h |  2 ++
 net/bridge/br_netlink.c | 23 ++-
 net/core/rtnetlink.c| 12 +---
 3 files changed, 13 insertions(+), 24 deletions(-)

--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/6] e1000 driver remove checkpatch errors, warnings and checks.

2015-10-13 Thread Jeff Kirsher
On Tue, 2015-10-13 at 15:23 -0700, Alexander Duyck wrote:
> On 10/13/2015 02:39 PM, Janusz Wolak wrote:
> > From: Janusz Wolak 
> >
> > Signed-off-by: Janusz Wolak 
> > ---
> >   drivers/net/ethernet/intel/e1000/e1000_param.c | 114
> ++---
> >   1 file changed, 82 insertions(+), 32 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/intel/e1000/e1000_param.c
> b/drivers/net/ethernet/intel/e1000/e1000_param.c
> > index c9cde35..9ec730e 100644
> > --- a/drivers/net/ethernet/intel/e1000/e1000_param.c
> > +++ b/drivers/net/ethernet/intel/e1000/e1000_param.c
> > @@ -1,5 +1,5 @@
> >  
> /
> ***
> > -
> > +*
> > Intel PRO/1000 Linux driver
> > Copyright(c) 1999 - 2006 Intel Corporation.
> >   
> > @@ -45,10 +45,10 @@
> >   
> >   #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
> >   #define E1000_PARAM(X, desc) \
> > - static int X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
> > + static int X[E1000_MAX_NIC + 1] = E1000_PARAM_INIT; \
> >   static unsigned int num_##X; \
> >   module_param_array_named(X, X, int, &num_##X, 0); \
> > - MODULE_PARM_DESC(X, desc);
> > + MODULE_PARM_DESC(X, desc)
> >   
> >   /* Transmit Descriptor Count
> >*
> > @@ -200,6 +200,7 @@ struct e1000_option {
> >   } r;
> >   struct { /* list_option info */
> >   int nr;
> > +
> >   const struct e1000_opt_list { int i; char
> *str; } *p;
> >   } l;
> >   } arg;
> 
> How is adding a space here adding any value?  Please don't just
> blindly 
> follow checkpatch as it can give out erroneous information.
> 
> Looking over most of this patch series it seems like it is taking 
> readability in the wrong direction and reducing the ability to
> maintain 
> the driver since this code has been "maintenance only" for some time 
> now.  If somebody comes up with a legitimate fix for an issue at some
> point in the future they will need to work around these patches in
> order 
> to back-port it into a stable release and that just hurts
> maintainability.
> 
> I'd say this whole series should be rejected on the grounds that this
> driver is mostly stable and should only really be modified for bug
> fixes 
> at this point.  If we really need to go through and do a checkpatch 
> sweep we should probably just focus on serious errors only instead of
> going astray and chasing down things that are false hits or minor
> issues 
> that are mostly a matter of preference.

In addition to all what Alex has said, I am not pleased about a 6 patch
series, with every patch in the series with the exact same frickin
title.

Consider this patch series rejected and dropped.

signature.asc
Description: This is a digitally signed message part


Re: simplify configfs attributes V2

2015-10-13 Thread Nicholas A. Bellinger
Hi Christoph & Co,

On Sat, 2015-10-03 at 15:32 +0200, Christoph Hellwig wrote:
> This series consolidates the code to implement configfs attributes
> by providing the ->show and ->store method in common code and using
> container_of in the methods to access the containing structure.
> 
> This reduces source and binary size of configfs consumers a lot.
> 
> Changes since V1:
>  - a couple fixes for unintended changes in the uvc driver
>  - moved a few CONFIG_ATTR() statements around
>  - fixed up the documentation and samples in the last patch
>  - added a little rather pointless blurb to the patch description for
>various patches
> 

Apologies for the delayed follow-up on -v2.

Applied to target-pending/for-next, with Felipe's ACK for usb, and
Pratyush's ACK for spear13xx.

Thank you,

--nab

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 2/2] bpf: Implement bpf_perf_event_sample_enable/disable() helpers

2015-10-13 Thread Alexei Starovoitov

On 10/13/15 3:54 AM, He Kuang wrote:

If we want perf to reflect as soon as our sample event be generated,
--no-buffering should be used, but this option has a greater
impact on performance.


no_buffering doesn't have to be applied to all events obviously.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [MM PATCH V4 6/6] slub: optimize bulk slowpath free by detached freelist

2015-10-13 Thread Joonsoo Kim
On Tue, Sep 29, 2015 at 05:48:26PM +0200, Jesper Dangaard Brouer wrote:
> This change focus on improving the speed of object freeing in the
> "slowpath" of kmem_cache_free_bulk.
> 
> The calls slab_free (fastpath) and __slab_free (slowpath) have been
> extended with support for bulk free, which amortize the overhead of
> the (locked) cmpxchg_double.
> 
> To use the new bulking feature, we build what I call a detached
> freelist.  The detached freelist takes advantage of three properties:
> 
>  1) the free function call owns the object that is about to be freed,
> thus writing into this memory is synchronization-free.
> 
>  2) many freelist's can co-exist side-by-side in the same slab-page
> each with a separate head pointer.
> 
>  3) it is the visibility of the head pointer that needs synchronization.
> 
> Given these properties, the brilliant part is that the detached
> freelist can be constructed without any need for synchronization.  The
> freelist is constructed directly in the page objects, without any
> synchronization needed.  The detached freelist is allocated on the
> stack of the function call kmem_cache_free_bulk.  Thus, the freelist
> head pointer is not visible to other CPUs.
> 
> All objects in a SLUB freelist must belong to the same slab-page.
> Thus, constructing the detached freelist is about matching objects
> that belong to the same slab-page.  The bulk free array is scanned is
> a progressive manor with a limited look-ahead facility.
> 
> Kmem debug support is handled in call of slab_free().
> 
> Notice kmem_cache_free_bulk no longer need to disable IRQs. This
> only slowed down single free bulk with approx 3 cycles.
> 
> 
> Performance data:
>  Benchmarked[1] obj size 256 bytes on CPU i7-4790K @ 4.00GHz
> 
> SLUB fastpath single object quick reuse: 47 cycles(tsc) 11.931 ns
> 
> To get stable and comparable numbers, the kernel have been booted with
> "slab_merge" (this also improve performance for larger bulk sizes).
> 
> Performance data, compared against fallback bulking:
> 
> bulk -  fallback bulk- improvement with this patch
>1 -  62 cycles(tsc) 15.662 ns - 49 cycles(tsc) 12.407 ns- improved 21.0%
>2 -  55 cycles(tsc) 13.935 ns - 30 cycles(tsc) 7.506 ns - improved 45.5%
>3 -  53 cycles(tsc) 13.341 ns - 23 cycles(tsc) 5.865 ns - improved 56.6%
>4 -  52 cycles(tsc) 13.081 ns - 20 cycles(tsc) 5.048 ns - improved 61.5%
>8 -  50 cycles(tsc) 12.627 ns - 18 cycles(tsc) 4.659 ns - improved 64.0%
>   16 -  49 cycles(tsc) 12.412 ns - 17 cycles(tsc) 4.495 ns - improved 65.3%
>   30 -  49 cycles(tsc) 12.484 ns - 18 cycles(tsc) 4.533 ns - improved 63.3%
>   32 -  50 cycles(tsc) 12.627 ns - 18 cycles(tsc) 4.707 ns - improved 64.0%
>   34 -  96 cycles(tsc) 24.243 ns - 23 cycles(tsc) 5.976 ns - improved 76.0%
>   48 -  83 cycles(tsc) 20.818 ns - 21 cycles(tsc) 5.329 ns - improved 74.7%
>   64 -  74 cycles(tsc) 18.700 ns - 20 cycles(tsc) 5.127 ns - improved 73.0%
>  128 -  90 cycles(tsc) 22.734 ns - 27 cycles(tsc) 6.833 ns - improved 70.0%
>  158 -  99 cycles(tsc) 24.776 ns - 30 cycles(tsc) 7.583 ns - improved 69.7%
>  250 - 104 cycles(tsc) 26.089 ns - 37 cycles(tsc) 9.280 ns - improved 64.4%
> 
> Performance data, compared current in-kernel bulking:
> 
> bulk - curr in-kernel  - improvement with this patch
>1 -  46 cycles(tsc) - 49 cycles(tsc) - improved (cycles:-3) -6.5%
>2 -  27 cycles(tsc) - 30 cycles(tsc) - improved (cycles:-3) -11.1%
>3 -  21 cycles(tsc) - 23 cycles(tsc) - improved (cycles:-2) -9.5%
>4 -  18 cycles(tsc) - 20 cycles(tsc) - improved (cycles:-2) -11.1%
>8 -  17 cycles(tsc) - 18 cycles(tsc) - improved (cycles:-1) -5.9%
>   16 -  18 cycles(tsc) - 17 cycles(tsc) - improved (cycles: 1)  5.6%
>   30 -  18 cycles(tsc) - 18 cycles(tsc) - improved (cycles: 0)  0.0%
>   32 -  18 cycles(tsc) - 18 cycles(tsc) - improved (cycles: 0)  0.0%
>   34 -  78 cycles(tsc) - 23 cycles(tsc) - improved (cycles:55) 70.5%
>   48 -  60 cycles(tsc) - 21 cycles(tsc) - improved (cycles:39) 65.0%
>   64 -  49 cycles(tsc) - 20 cycles(tsc) - improved (cycles:29) 59.2%
>  128 -  69 cycles(tsc) - 27 cycles(tsc) - improved (cycles:42) 60.9%
>  158 -  79 cycles(tsc) - 30 cycles(tsc) - improved (cycles:49) 62.0%
>  250 -  86 cycles(tsc) - 37 cycles(tsc) - improved (cycles:49) 57.0%
> 
> Performance with normal SLUB merging is significantly slower for
> larger bulking.  This is believed to (primarily) be an effect of not
> having to share the per-CPU data-structures, as tuning per-CPU size
> can achieve similar performance.
> 
> bulk - slab_nomerge   -  normal SLUB merge
>1 -  49 cycles(tsc) - 49 cycles(tsc) - merge slower with cycles:0
>2 -  30 cycles(tsc) - 30 cycles(tsc) - merge slower with cycles:0
>3 -  23 cycles(tsc) - 23 cycles(tsc) - merge slower with cycles:0
>4 -  20 cycles(tsc) - 20 cycles(tsc) - merge slower with cycles:0
>8 -  18 cycles(tsc) - 18 cycles(tsc) - merge slower with cycles:0
>   16 -  17 cycles(tsc) - 17 cycles(tsc

RE: [PATCH net-next v5 01/10] qed: Add module with basic common support

2015-10-13 Thread Yuval Mintz
> Yuval Mintz  :
> [...]
> > > > +struct qed_simd_fp_handler {
> > > > + void*token;
> > > > + void(*func)(void *);
> > > > +};
> > > Use union * ?
> > The token is a cookie to be used by a func, so union isn't appropriate.
> 
> Lets' reformulate: replace 'void * token' by 'union foobar *token'.
> 
> void * silents compiler. union * doesn't.

Not sure I get you here - this hander is used for registering interrupt handlers
in case INTa is used, and multiple modules [both QED and the appropriate
protocol driver] need to use it.
Turning this into an explicit union would require QED to be familiar with the
ISR cookies of all the various protocol drivers. While possible, it'll create
additional .h dependencies between those in a direction that currently doesn't
exist [I.e., QED would have to include protocol driver .h for it].

> 
> [...]
> > > > + rc = -ENOMEM;
> > > > + goto ilt_shadow_fail;
> > > > + } else {
> > > > + DP_VERBOSE(p_hwfn, QED_MSG_ILT,
> > > > +"Allocated 0x%x bytes for ilt shadow\n",
> > > > +(u32)(size * sizeof(struct qed_dma_mem)));
> > > > + }
> > > The "else" branch after the "goto" isn't idiomatic.
> > Not that I mind, but is such a prefernce described in any style-guide?
> 
> Documentation/CodingStyle gives some hints in its "goto" section but it 
> doesn't
> specifically go that far. Is there a reward if I can exhumate some message on
> netdev where it would had already been outlined ?

Depends. Do you consider wasted time to be a reward? ;-)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next 2/4] net/mlx5_core: Add pci error handlers to mlx5_core driver

2015-10-13 Thread Or Gerlitz



On 10/13/2015 8:04 PM, kbuild test robot wrote:

Hi Majd,

[auto build test WARNING on net-next/master -- if it's inappropriate base, 
please suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/Or-Gerlitz/net-mlx5_core-Fix-internal-error-detection-conditions/20151013-234855
reproduce:
 # apt-get install sparse
 make ARCH=x86_64 allmodconfig
 make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)


Hi Majd,

Please address and push fix to Gerrit, IM me when this is ready.

Or.





drivers/net/ethernet/mellanox/mlx5/core/cmd.c:1383:36: sparse: incorrect type 
in assignment (different base types)

drivers/net/ethernet/mellanox/mlx5/core/cmd.c:1383:36:expected restricted 
__be32 [usertype] 
drivers/net/ethernet/mellanox/mlx5/core/cmd.c:1383:36:got unsigned int 
[unsigned] [addressable] [usertype] drv_synd

vim +1383 drivers/net/ethernet/mellanox/mlx5/core/cmd.c

   1367 }
   1368 
   1369 static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, 
void *out,
   1370 int out_size, mlx5_cmd_cbk_t callback, void 
*context)
   1371 {
   1372 struct mlx5_cmd_msg *inb;
   1373 struct mlx5_cmd_msg *outb;
   1374 int pages_queue;
   1375 gfp_t gfp;
   1376 int err;
   1377 u8 status = 0;
   1378 u32 drv_synd;
   1379 
   1380 if (pci_channel_offline(dev->pdev) ||
   1381 dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
   1382 err = mlx5_internal_err_ret_value(dev, opcode_from_in(in), 
&drv_synd, &status);

1383*get_synd_ptr(out) = drv_synd;

   1384 *get_status_ptr(out) = status;
   1385 return err;
   1386 }
   1387 



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] net: phy: smsc: disable energy detect mode

2015-10-13 Thread Heiko Schocher

Hello Florian,

Am 13.10.2015 um 21:26 schrieb Florian Fainelli:

On 12/10/15 22:13, Heiko Schocher wrote:

On some boards the energy enable detect mode leads in
trouble with some switches, so make the enabling of
this mode configurable through DT.

Signed-off-by: Heiko Schocher 
---

  .../devicetree/bindings/net/smsc-lan87xx.txt   | 19 +
  drivers/net/phy/smsc.c | 24 +-
  2 files changed, 38 insertions(+), 5 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/net/smsc-lan87xx.txt

diff --git a/Documentation/devicetree/bindings/net/smsc-lan87xx.txt 
b/Documentation/devicetree/bindings/net/smsc-lan87xx.txt
new file mode 100644
index 000..39aa1dc
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/smsc-lan87xx.txt
@@ -0,0 +1,19 @@
+SMSC LAN87xx Ethernet PHY
+
+Some boards require special tuning values. Configure them
+through an Ethernet OF device node.
+
+Optional properties:
+
+- disable-energy-detect:
+  If set, do not enable energy detect mode for the SMSC phy.
+  default: enable energy detect mode


Although energy detection is something that is implemented by many PHYs,
I am not sure a generic property is suitable here, I would prefix that
with the SMSC vendor prefix here to make it clear this only applies to
this PHY.


Hmm... but all PHYs should be able to enable, disable it in some way, or?


Would not you want to make it a reverse property here though, something
like this:

smsc,energy-detect: boolean, when present indicates the PHY reliably
supports energy detection


Yes, that was also my first thought, but currently, on this PHYs
energy detect mode is on ... and if I introduce such a property,
it will disable it for all existing boards, because property is
missing ... so, maybe I break boards ...


+
+Examples:
+
+   /* Attach to an Ethernet device with autodetected PHY */
+   &cpsw_emac0 {
+   phy_id = <&davinci_mdio>, <0>;
+   phy-mode = "mii";
+   disable-energy-detect;
+   };
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index 70b0895..f90fbf3 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -43,16 +43,30 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)

  static int smsc_phy_config_init(struct phy_device *phydev)
  {
+#ifdef CONFIG_OF
+   int len;
+   struct device *dev = &phydev->dev;
+   struct device_node *of_node = dev->of_node;


That does not need to be ifdefd out, at best annontate with __maybe_unused?


Yes, I try it.


+#endif
int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
+   int enable_energy = 1;

if (rc < 0)
return rc;

-   /* Enable energy detect mode for this SMSC Transceivers */
-   rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
-  rc | MII_LAN83C185_EDPWRDOWN);
-   if (rc < 0)
-   return rc;
+#ifdef CONFIG_OF
+   if (!of_node && dev->parent->of_node)
+   of_node = dev->parent->of_node;


That looks strange, why would the property be placed at the parent level
when this is a PHY device tree node property?


Hmm.. I recheck this.


+   if (of_find_property(of_node, "disable-energy-detect", &len))
+   enable_energy = 0;
+#endif
+   if (enable_energy) {
+   /* Enable energy detect mode for this SMSC Transceivers */
+   rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
+  rc | MII_LAN83C185_EDPWRDOWN);
+   if (rc < 0)
+   return rc;
+   }

return smsc_phy_ack_interrupt(phydev);
  }



Thanks for your review.

bye,
Heiko

--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next v2] bnxt_en: New Broadcom ethernet driver.

2015-10-13 Thread kbuild test robot
Hi Michael,

[auto build test WARNING on net-next/master -- if it's inappropriate base, 
please suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/Michael-Chan/bnxt_en-New-Broadcom-ethernet-driver/20151014-112018
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c:204:20: sparse: incorrect 
>> type in assignment (different base types)
   drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c:204:20:expected 
restricted __le32 [addressable] [assigned] [usertype] max_bw
   drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c:204:20:got int [signed] 
max_tx_rate
>> drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c:206:20: sparse: incorrect 
>> type in assignment (different base types)
   drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c:206:20:expected 
restricted __le32 [addressable] [assigned] [usertype] min_bw
   drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c:206:20:got int [signed] 
min_tx_rate

vim +204 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c

   198  if (min_tx_rate == vf->min_tx_rate && max_tx_rate == 
vf->max_tx_rate)
   199  return 0;
   200  bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1);
   201  req.vf_id = cpu_to_le16(vf->fw_fid);
   202  req.flags = cpu_to_le32(vf->func_flags);
   203  req.enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_MAX_BW);
 > 204  req.max_bw = max_tx_rate;
   205  req.enables |= cpu_to_le32(FUNC_CFG_REQ_ENABLES_MIN_BW);
 > 206  req.min_bw = min_tx_rate;
   207  rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
   208  if (!rc) {
   209  vf->min_tx_rate = min_tx_rate;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] sunrpc: fix waitqueue_active without memory barrier in sunrpc

2015-10-13 Thread Kosuke Tatsukawa
J. Bruce Fields wrote:
> On Mon, Oct 12, 2015 at 10:41:06AM +, Kosuke Tatsukawa wrote:
>> J. Bruce Fields wrote:
>> > On Fri, Oct 09, 2015 at 06:29:44AM +, Kosuke Tatsukawa wrote:
>> >> Neil Brown wrote:
>> >> > Kosuke Tatsukawa  writes:
>> >> > 
>> >> >> There are several places in net/sunrpc/svcsock.c which calls
>> >> >> waitqueue_active() without calling a memory barrier.  Add a memory
>> >> >> barrier just as in wq_has_sleeper().
>> >> >>
>> >> >> I found this issue when I was looking through the linux source code
>> >> >> for places calling waitqueue_active() before wake_up*(), but without
>> >> >> preceding memory barriers, after sending a patch to fix a similar
>> >> >> issue in drivers/tty/n_tty.c  (Details about the original issue can be
>> >> >> found here: https://lkml.org/lkml/2015/9/28/849).
>> >> > 
>> >> > hi,
>> >> > this feels like the wrong approach to the problem.  It requires extra
>> >> > 'smb_mb's to be spread around which are hard to understand as easy to
>> >> > forget.
>> >> > 
>> >> > A quick look seems to suggest that (nearly) every waitqueue_active()
>> >> > will need an smb_mb.  Could we just put the smb_mb() inside
>> >> > waitqueue_active()??
>> >> 
>> >> 
>> >> There are around 200 occurrences of waitqueue_active() in the kernel
>> >> source, and most of the places which use it before wake_up are either
>> >> protected by some spin lock, or already has a memory barrier or some
>> >> kind of atomic operation before it.
>> >> 
>> >> Simply adding smp_mb() to waitqueue_active() would incur extra cost in
>> >> many cases and won't be a good idea.
>> >> 
>> >> Another way to solve this problem is to remove the waitqueue_active(),
>> >> making the code look like this;
>> >>   if (wq)
>> >>   wake_up_interruptible(wq);
>> >> This also fixes the problem because the spinlock in the wake_up*() acts
>> >> as a memory barrier and prevents the code from being reordered by the
>> >> CPU (and it also makes the resulting code is much simpler).
>> > 
>> > I might not care which we did, except I don't have the means to test
>> > this quickly, and I guess this is some of our most frequently called
>> > code.
>> > 
>> > I suppose your patch is the most conservative approach, as the
>> > alternative is a spinlock/unlock in wake_up_interruptible, which I
>> > assume is necessarily more expensive than an smp_mb().
>> > 
>> > As far as I can tell it's been this way since forever.  (Well, since a
>> > 2002 patch "NFSD: TCP: rationalise locking in RPC server routines" which
>> > removed some spinlocks from the data_ready routines.)
>> > 
>> > I don't understand what the actual race is yet (which code exactly is
>> > missing the wakeup in this case?  nfsd threads seem to instead get
>> > woken up by the wake_up_process() in svc_xprt_do_enqueue().)
>> 
>> Thank you for the reply.  I tried looking into this.
>> 
>> The callbacks in net/sunrpc/svcsock.c are set up in svc_tcp_init() and
>> svc_udp_init(), which are both called from svc_setup_socket().
>> svc_setup_socket() is called (indirectly) from lockd, nfsd, and nfsv4
>> callback port related code.
>> 
>> Maybe I'm wrong, but there might not be any kernel code that is using
>> the socket's wait queue in this case.
> 
> As Trond points out there are probably waiters internal to the
> networking code.

Trond and Bruce, thank you for the comment.  I was able to find the call
to the wait function that was called from nfsd.

sk_stream_wait_connect() and sk_stream_wait_memory() were called from
either do_tcp_sendpages() or tcp_sendmsg() called from within
svc_send().  sk_stream_wait_connect() shouldn't be called at this point,
because the socket has already been used to receive the rpc request.

On the wake_up side, sk_write_space() is called from the following
locations.  The relevant ones seems to be preceded by atomic_sub or a
memory barrier.
+ ksocknal_write_space 
[drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c:633]
+ atm_pop_raw [net/atm/raw.c:40]
+ sock_setsockopt [net/core/sock.c:740]
+ sock_wfree [net/core/sock.c:1630]
  Preceded by atomic_sub in sock_wfree()
+ ccid3_hc_tx_packet_recv [net/dccp/ccids/ccid3.c:442]
+ do_tcp_sendpages [net/ipv4/tcp.c:1008]
+ tcp_sendmsg [net/ipv4/tcp.c:1300]
+ do_tcp_setsockopt [net/ipv4/tcp.c:2597]
+ tcp_new_space [net/ipv4/tcp_input.c:4885]
  Preceded by smp_mb__after_atomic in tcp_check_space()
+ llc_conn_state_process [net/llc/llc_conn.c:148]
+ pipe_rcv_status [net/phonet/pep.c:312]
+ pipe_do_rcv [net/phonet/pep.c:440]
+ pipe_start_flow_control [net/phonet/pep.c:554]
+ svc_sock_setbufsize [net/sunrpc/svcsock.c:45]

sk_state_change() calls related to TCP/IP were called from the following
places.
+ inet_shutdown [net/ipv4/af_inet.c:825]
  This shouldn't be called when waiting
+ tcp_done [net/ipv4/tcp.c:3078]
  spin_lock*/spin_unlock* is called in lock_timer_base
+ tcp_fin [net/ipv4/tcp_input.c:4031]
  atomic_long_sub is called from sk_memory_allocated_sub called within
  sk_mem_reclaim
+ t

Re: [PATCH v2 1/3] unix: fix use-after-free in unix_dgram_poll()

2015-10-13 Thread Jason Baron
On 10/12/2015 04:41 PM, Rainer Weikusat wrote:
> Jason Baron  writes:
>> On 10/05/2015 12:31 PM, Rainer Weikusat wrote:
> 
> [...]
> 
>>> Here's a more simple idea which _might_ work. The underlying problem
>>> seems to be that the second sock_poll_wait introduces a covert reference
>>> to the peer socket which isn't accounted for. The basic idea behind this
>>> is to execute an additional sock_hold for the peer whenever the
>>> sock_poll_wait is called for it and store it (the struct sock *) in a
>>> new struct unix_sock member.
> 
> [...]
> 
>> Interesting - will this work for the test case you supplied where we are in
>> epoll_wait() and another thread does a connect() to a new target? In that
>> case, even if we issue a wakeup to the epoll thread, its not going to have
>> a non-NULL poll_table, so it wouldn't be added to the new target. IE
>> the first test case here:
>>
>> https://lkml.org/lkml/2015/10/4/154
> 
> "Indeed it would not." I've also meanwhile found the time to check what
> is and isn't locked here and found that Eric's "this looks racy" was
> also justified. In theory, a clean solution could be based on modifying
> the various polling implementations to keep a piece of data for a polled
> something and provided that again on each subsequent poll call. This
> could then be used to keep the peer socket alive for as long as
> necessary were it possible to change the set of wait queues with every
> poll call. Since this also isn't the case, the idea to increment the
> reference count of the peer socket won't fly.
> 
> OTOH, something I seriously dislike about your relaying implementation
> is the unconditional add_wait_queue upon connect as this builds up a
> possibly large wait queue of entities entirely uninterested in the
> event which will need to be traversed even if peer_wait wakeups will
> only happen if at least someone actually wants to be notified. This
> could be changed such that the struct unix_sock member is only put onto
> the peer's wait queue in poll and only if it hasn't already been put
> onto it. The connection could then be severed if some kind of
> 'disconnect' occurs.
> 
> The code below (again based on 3.2.54) is what I'm currently running and
> it has survived testing during the day (without trying the exercise in
> hexadecimal as that doesn't cause failure for me, anyway). The wakeup
> relaying function checks that a socket wait queue actually still exists
> because I used to get null pointers oopses without every now and then
> (I've also tested this with an additional printk printing 'no q' in case
> the pointer was actually null to verify that this really occurs here).
> 

Hi,

What about the following race?

1) thread A does poll() on f, finds the wakeup condition low, and adds
itself to the remote peer_wait queue.

2) thread B sets the wake up condition in dgram_recvmsg(), but does not
execute the wakeup of threads yet.

3) thread C also does a poll() on f, finds now that the wakeup condition
is set, and hence removes f from the remote peer_wait queue.

Then, thread A misses the POLLOUT, and hangs.

I understand your concern about POLLIN only waiters-I think we
could add the 'relay callback' in dgram_poll() only for those who are
looking for POLLOUT, and simply avoid the de-registration, as in practice
I think its unlikely we are going to have a socket switching from
POLLOUT to *only* POLLIN. I suspect that will cover most of the cases
that concern you?

Thanks,

-Jason

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next 1/4] net/mlx5_core: Fix internal error detection conditions

2015-10-13 Thread David Miller
From: Or Gerlitz 
Date: Tue, 13 Oct 2015 18:44:06 +0300

> + if (in_fatal(dev) && !health->sick) {
> + health->sick = 1;
> + print_health_info(dev);
> + queue_work(health->wq, &health->work);
>   }
>  }
>  
> diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
> index 41a3287..cd469b9 100644
> --- a/include/linux/mlx5/driver.h
> +++ b/include/linux/mlx5/driver.h
> @@ -393,6 +393,7 @@ struct mlx5_core_health {
>   struct timer_list   timer;
>   u32 prev;
>   int miss_counter;
> + int sick;
>   struct workqueue_struct*wq;
>   struct work_struct  work;
>  };
> -- 
> 2.3.7
> 

Please use "bool" and true/false for boolean states.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next] net: hisilicon net: fix a bug about led

2015-10-13 Thread yankejian
From: lipeng 

this patch fixes a bug in hns driver. the link led is on at the beginning,
but at this time the ethernet port is on down status. it needs to reset
the led status on init sequence.

Signed-off-by: lipeng 
Signed-off-by: yankejian 
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 95bf42a..f8f7347 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -744,9 +744,11 @@ int hns_mac_get_cfg(struct dsaf_device *dsaf_dev, int 
mac_idx)
mac_cb->serdes_vaddr = dsaf_dev->sds_base;
 
if (dsaf_dev->cpld_base &&
-   mac_idx < DSAF_SERVICE_PORT_NUM_PER_DSAF)
+   mac_idx < DSAF_SERVICE_PORT_NUM_PER_DSAF) {
mac_cb->cpld_vaddr = dsaf_dev->cpld_base +
mac_cb->mac_id * CPLD_ADDR_PORT_OFFSET;
+   cpld_led_reset(mac_cb);
+   }
mac_cb->sfp_prsnt = 0;
mac_cb->txpkt_for_led = 0;
mac_cb->rxpkt_for_led = 0;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH nf-next 1/2] ipvs: Remove possibly unused variable from ip_vs_out

2015-10-13 Thread Simon Horman
On Mon, Oct 12, 2015 at 05:43:49PM +0200, Pablo Neira Ayuso wrote:
> On Wed, Oct 07, 2015 at 04:58:47PM +0300, Sergei Shtylyov wrote:
> > Hello.
> > 
> > On 10/7/2015 8:23 AM, Simon Horman wrote:
> > 
> > >From: David Ahern 
> > >
> > >Eric's net namespace changes in 1b75097dd7a26 leaves net unreferenced if
> > >CONFIG_IP_VS_IPV6 is not enabled:
> > >
> > >../net/netfilter/ipvs/ip_vs_core.c: In function ‘ip_vs_out’:
> > >../net/netfilter/ipvs/ip_vs_core.c:1177:14: warning: unused variable ‘net’ 
> > >[-Wunused-variable]
> > >
> > >After the net refactoring there is only 1 user; push the reference to the
> > >1 user. While the line length slightly exceeds 80 it seems to be the
> > >best change.
> > >
> > >Fixes: 1b75097dd7a26("ipvs: Pass ipvs into ip_vs_out")
> > 
> >Minor nit: missing space before (. Could be probbably fixed while 
> > applying...
> 
> I have pulled this anyway, I don't want to keep this back for this
> minor style problem.
> 
> But please Simon, run checkpatch.pl before submitting next time.

Sorry about that, I will try to be more careful.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next] net: vrf: Documentation update, ip commands

2015-10-13 Thread David Miller
From: David Ahern 
Date: Mon, 12 Oct 2015 13:54:38 -0700

> Add ip commands with examples for creating VRF devics, enslaving interfaces
> and dumping VRF-focused data (address, neighbors, routes).
> 
> Signed-off-by: David Ahern 

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Patch net-next 1/4] net_sched: introduce qdisc_replace() helper

2015-10-13 Thread David Miller
From: Cong Wang 
Date: Mon, 12 Oct 2015 11:38:00 -0700

> Remove nearly duplicated code and prepare for the following patch.
> 
> Cc: Jamal Hadi Salim 
> Signed-off-by: Cong Wang 

This isn't an equivalent transformation:

> +static inline struct Qdisc *qdisc_replace(struct Qdisc *sch, struct Qdisc 
> *new,
> +   struct Qdisc **pold)
> +{
> + struct Qdisc *old;
> +
> + sch_tree_lock(sch);
> + old = *pold;
> + *pold = new;
> + if (old != NULL) {
> + qdisc_tree_decrease_qlen(old, old->q.qlen);
> + qdisc_reset(old);
> + }
> + sch_tree_unlock(sch);
> +
> + return old;
> +}
> +

Is not the same as:

> diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c
> index f26bdea..c76cdd4 100644
> --- a/net/sched/sch_drr.c
> +++ b/net/sched/sch_drr.c
> @@ -226,11 +226,7 @@ static int drr_graft_class(struct Qdisc *sch, unsigned 
> long arg,
>   new = &noop_qdisc;
>   }
>  
> - sch_tree_lock(sch);
> - drr_purge_queue(cl);
> - *old = cl->qdisc;
> - cl->qdisc = new;
> - sch_tree_unlock(sch);
> + *old = qdisc_replace(sch, new, &cl->qdisc);
>   return 0;
>  }
>  

This.

If you want to change semantics, you must do it explicitly in a separate
commit with a detailed commit message explaining how and why.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next v5] net: ipv6: Make address flushing on ifdown optional

2015-10-13 Thread David Miller
From: David Ahern 
Date: Mon, 12 Oct 2015 09:33:07 -0700

> Currently, all ipv6 addresses are flushed when the interface is configured
> down, including global, static addresses:
 ...
> Add a new sysctl to make this behavior optional. The new setting defaults to
> flush all addresses to maintain backwards compatibility. When the setting is
> reset global addresses with no expire times are not flushed:
 ...
> Signed-off-by: David Ahern 

Here is what I really don't like about these changes: the failure
semantics are terrible.

If I add an address or a route, and some memory allocation fails, I get
a notification and see that my operation did not succeed.

But here, my routes can fail to be added during an ifup and all I will
get, at best, is a kernel log message.

This places a serious disconnect between what the user asked for and
making sure he finds out directly that his operation did not really
fully succeed.

In fact, this failure handling here during ifup leaves the interface in
a partially configured state.

There are really two ways to deal with this properly:

1) Propagate the failure back through the notifiers and fail the ifup
   completely when the addrconf_dst_alloc() fails.

2) On ifdown, stash the objects away somewhere so that memory allocation
   is not necessary on ifup.

Neither are really smooth approaches, but they have the attribute that
they give the user clean behavior and semantics.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/6] e1000 driver remove checkpatch errors, warnings and checks.

2015-10-13 Thread Joe Perches
On Tue, 2015-10-13 at 15:23 -0700, Alexander Duyck wrote:
> Please don't just blindly 
> follow checkpatch as it can give out erroneous information.
> 
> Looking over most of this patch series it seems like it is taking 
> readability in the wrong direction and reducing the ability to maintain 
> the driver since this code has been "maintenance only" for some time 
> now.  If somebody comes up with a legitimate fix for an issue at some 
> point in the future they will need to work around these patches in order 
> to back-port it into a stable release and that just hurts maintainability.
> 
> I'd say this whole series should be rejected on the grounds that this 
> driver is mostly stable and should only really be modified for bug fixes 
> at this point.  If we really need to go through and do a checkpatch 
> sweep we should probably just focus on serious errors only instead of 
> going astray and chasing down things that are false hits or minor issues 
> that are mostly a matter of preference.

Excellent advice.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] mISDN: use kstrdup() in dsp_pipeline_build

2015-10-13 Thread David Miller
From: Geliang Tang 
Date: Mon, 12 Oct 2015 01:19:07 -0700

> Use kstrdup instead of strlen-kmalloc-strcpy. Remove unneeded NULL
> test, it will be tested inside kstrdup. Remove 0 length string test,
> it has been tested in the caller of dsp_pipeline_build.
> 
> Signed-off-by: Geliang Tang 
> ---
> Changes in v2:
>   - Remove unneeded NULL test.

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next] tcp/dccp: fix behavior of stale SYN_RECV request sockets

2015-10-13 Thread David Miller
From: Eric Dumazet 
Date: Tue, 13 Oct 2015 17:12:54 -0700

> From: Eric Dumazet 
> 
> When a TCP/DCCP listener is closed, its pending SYN_RECV request sockets
> become stale, meaning 3WHS can not complete.
> 
> But current behavior is wrong :
> incoming packets finding such stale sockets are dropped.
> 
> We need instead to cleanup the request socket and perform another
> lookup :
> - Incoming ACK will give a RST answer,
> - SYN rtx might find another listener if available.
> - We expedite cleanup of request sockets and old listener socket.
> 
> Fixes: 079096f103fa ("tcp/dccp: install syn_recv requests into ehash table")
> Signed-off-by: Eric Dumazet 

Applied, thanks Eric.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


dringende reactie

2015-10-13 Thread Aspire Money Loan®


groeten,
  Ik ben mevrouw Annie Ethan uit een particuliere kredietverlening 
bedrijf dat bekend staat als Aspire Money Loan®. Wij bieden alle soorten lening 
tegen 3% rente. Als u behoefte van de lening zo vriendelijk contact met ons op 
met de onderstaande informatie.
Volledige naam:
Geslacht:
land:
adres:
Leenbedrag:
duur:
tel:
Wij wachten uw reactie als je geïnteresseerd bent
Dankjewel,
Annie Ethan

-- 
Esta mensagem foi verificada pelo sistema de antivirus e
 acredita-se estar livre de perigo.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next] cxgb4i: Increased the value of MAX_IMM_TX_PKT_LEN from 128 to 256 bytes

2015-10-13 Thread Karen Xie
This helps improving the latency of small packets.

Signed-off-by: Rakesh Ranjan 
Signed-off-by: Karen Xie 

---
 drivers/scsi/cxgbi/cxgb4i/cxgb4i.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c 
b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
index de6feb8..804806e 100644
--- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
+++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
@@ -160,7 +160,7 @@ static struct scsi_transport_template *cxgb4i_stt;
 
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
 #define RCV_BUFSIZ_MASK0x3FFU
-#define MAX_IMM_TX_PKT_LEN 128
+#define MAX_IMM_TX_PKT_LEN 256
 
 static int push_tx_frames(struct cxgbi_sock *, int);
 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next] tcp/dccp: fix behavior of stale SYN_RECV request sockets

2015-10-13 Thread Eric Dumazet
From: Eric Dumazet 

When a TCP/DCCP listener is closed, its pending SYN_RECV request sockets
become stale, meaning 3WHS can not complete.

But current behavior is wrong :
incoming packets finding such stale sockets are dropped.

We need instead to cleanup the request socket and perform another
lookup :
- Incoming ACK will give a RST answer,
- SYN rtx might find another listener if available.
- We expedite cleanup of request sockets and old listener socket.

Fixes: 079096f103fa ("tcp/dccp: install syn_recv requests into ehash table")
Signed-off-by: Eric Dumazet 
---
 net/dccp/ipv4.c |   15 +++
 net/dccp/ipv6.c |   15 +++
 net/ipv4/tcp_ipv4.c |7 ++-
 net/ipv6/tcp_ipv6.c |7 ++-
 4 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 
8e99681c8189d82e3e5f6a3c6089b103c0df2ca3..0dcf1963b323db7c7501dd58292795ee62fc0736
 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -799,15 +799,10 @@ static int dccp_v4_rcv(struct sk_buff *skb)
  DCCP_SKB_CB(skb)->dccpd_ack_seq);
}
 
-   /* Step 2:
-*  Look up flow ID in table and get corresponding socket */
+lookup:
sk = __inet_lookup_skb(&dccp_hashinfo, skb,
   dh->dccph_sport, dh->dccph_dport);
-   /*
-* Step 2:
-*  If no socket ...
-*/
-   if (sk == NULL) {
+   if (!sk) {
dccp_pr_debug("failed to look up flow ID in table and "
  "get corresponding socket\n");
goto no_dccp_socket;
@@ -830,8 +825,12 @@ static int dccp_v4_rcv(struct sk_buff *skb)
struct sock *nsk = NULL;
 
sk = req->rsk_listener;
-   if (sk->sk_state == DCCP_LISTEN)
+   if (likely(sk->sk_state == DCCP_LISTEN)) {
nsk = dccp_check_req(sk, skb, req);
+   } else {
+   inet_csk_reqsk_queue_drop(sk, req);
+   goto lookup;
+   }
if (!nsk) {
reqsk_put(req);
goto discard_it;
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 
aed314f8c7c60b00191aabc42c733f02304b18b0..68831931b1fe63a46031fe3324f8a0546f330236
 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -656,16 +656,11 @@ static int dccp_v6_rcv(struct sk_buff *skb)
else
DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb);
 
-   /* Step 2:
-*  Look up flow ID in table and get corresponding socket */
+lookup:
sk = __inet6_lookup_skb(&dccp_hashinfo, skb,
dh->dccph_sport, dh->dccph_dport,
inet6_iif(skb));
-   /*
-* Step 2:
-*  If no socket ...
-*/
-   if (sk == NULL) {
+   if (!sk) {
dccp_pr_debug("failed to look up flow ID in table and "
  "get corresponding socket\n");
goto no_dccp_socket;
@@ -688,8 +683,12 @@ static int dccp_v6_rcv(struct sk_buff *skb)
struct sock *nsk = NULL;
 
sk = req->rsk_listener;
-   if (sk->sk_state == DCCP_LISTEN)
+   if (likely(sk->sk_state == DCCP_LISTEN)) {
nsk = dccp_check_req(sk, skb, req);
+   } else {
+   inet_csk_reqsk_queue_drop(sk, req);
+   goto lookup;
+   }
if (!nsk) {
reqsk_put(req);
goto discard_it;
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 
ddb198392c7fd9be24d62a5d87da051b86cc8c55..1ff0923df7153d37f153fb0fa100a88cdeef0509
 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1572,6 +1572,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
TCP_SKB_CB(skb)->ip_dsfield = ipv4_get_dsfield(iph);
TCP_SKB_CB(skb)->sacked  = 0;
 
+lookup:
sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
if (!sk)
goto no_tcp_socket;
@@ -1587,8 +1588,12 @@ process:
sk = req->rsk_listener;
if (tcp_v4_inbound_md5_hash(sk, skb))
goto discard_and_relse;
-   if (sk->sk_state == TCP_LISTEN)
+   if (likely(sk->sk_state == TCP_LISTEN)) {
nsk = tcp_check_req(sk, skb, req, false);
+   } else {
+   inet_csk_reqsk_queue_drop(sk, req);
+   goto lookup;
+   }
if (!nsk) {
reqsk_put(req);
goto discard_it;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 
2887c8474b650468a76919fe9d25aff43361e1ba..7ce1c57199d13ac4b5d20ab47a32471493322edd
 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1363,6 +1363,7 @@ static int tcp_

Re: [PATCH 5/6] e1000 driver remove checkpatch errors, warnings and checks.

2015-10-13 Thread Alexander Duyck

On 10/13/2015 02:39 PM, Janusz Wolak wrote:

From: Janusz Wolak 

Signed-off-by: Janusz Wolak 
---
  drivers/net/ethernet/intel/e1000/e1000_param.c | 114 ++---
  1 file changed, 82 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_param.c 
b/drivers/net/ethernet/intel/e1000/e1000_param.c
index c9cde35..9ec730e 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_param.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_param.c
@@ -1,5 +1,5 @@
  
/***
-
+*
Intel PRO/1000 Linux driver
Copyright(c) 1999 - 2006 Intel Corporation.
  
@@ -45,10 +45,10 @@
  
  #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }

  #define E1000_PARAM(X, desc) \
-   static int X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
+   static int X[E1000_MAX_NIC + 1] = E1000_PARAM_INIT; \
static unsigned int num_##X; \
module_param_array_named(X, X, int, &num_##X, 0); \
-   MODULE_PARM_DESC(X, desc);
+   MODULE_PARM_DESC(X, desc)
  
  /* Transmit Descriptor Count

   *
@@ -200,6 +200,7 @@ struct e1000_option {
} r;
struct { /* list_option info */
int nr;
+
const struct e1000_opt_list { int i; char *str; } *p;
} l;
} arg;


How is adding a space here adding any value?  Please don't just blindly 
follow checkpatch as it can give out erroneous information.


Looking over most of this patch series it seems like it is taking 
readability in the wrong direction and reducing the ability to maintain 
the driver since this code has been "maintenance only" for some time 
now.  If somebody comes up with a legitimate fix for an issue at some 
point in the future they will need to work around these patches in order 
to back-port it into a stable release and that just hurts maintainability.


I'd say this whole series should be rejected on the grounds that this 
driver is mostly stable and should only really be modified for bug fixes 
at this point.  If we really need to go through and do a checkpatch 
sweep we should probably just focus on serious errors only instead of 
going astray and chasing down things that are false hits or minor issues 
that are mostly a matter of preference.


- Alex
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next v5 01/10] qed: Add module with basic common support

2015-10-13 Thread Francois Romieu
Yuval Mintz  :
[...]
> > > +struct qed_simd_fp_handler {
> > > + void*token;
> > > + void(*func)(void *);
> > > +};
> > Use union * ?
> The token is a cookie to be used by a func, so union isn't appropriate.

Lets' reformulate: replace 'void * token' by 'union foobar *token'.

void * silents compiler. union * doesn't.

[...]
> > > + rc = -ENOMEM;
> > > + goto ilt_shadow_fail;
> > > + } else {
> > > + DP_VERBOSE(p_hwfn, QED_MSG_ILT,
> > > +"Allocated 0x%x bytes for ilt shadow\n",
> > > +(u32)(size * sizeof(struct qed_dma_mem)));
> > > + }
> > The "else" branch after the "goto" isn't idiomatic.
> Not that I mind, but is such a prefernce described in any style-guide?

Documentation/CodingStyle gives some hints in its "goto" section but it
doesn't specifically go that far. Is there a reward if I can exhumate
some message on netdev where it would had already been outlined ?

-- 
Ueimor
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] e1000 driver remove checkpatch errors, warnings and checks.

2015-10-13 Thread Janusz Wolak
From: Janusz Wolak 

Signed-off-by: Janusz Wolak 
---
 drivers/net/ethernet/intel/e1000/e1000_osdep.h | 49 +-
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_osdep.h 
b/drivers/net/ethernet/intel/e1000/e1000_osdep.h
index 33e7c45a..aeb3b95 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_osdep.h
+++ b/drivers/net/ethernet/intel/e1000/e1000_osdep.h
@@ -1,5 +1,5 @@
 
/***
-
+*
   Intel PRO/1000 Linux driver
   Copyright(c) 1999 - 2006 Intel Corporation.
 
@@ -26,7 +26,6 @@
 
 
***/
 
-
 /* glue for the OS independent part of e1000
  * includes register access macros
  */
@@ -34,7 +33,7 @@
 #ifndef _E1000_OSDEP_H_
 #define _E1000_OSDEP_H_
 
-#include 
+#include 
 
 #define CONFIG_RAM_BASE 0x6
 #define GBE_CONFIG_OFFSET   0x0
@@ -60,50 +59,50 @@
 ? E1000_##reg : E1000_82542_##reg
 
 #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
-writel((value), ((a)->hw_addr + \
-(((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
-((offset) << 2
+ writel((value), ((a)->hw_addr + \
+   (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
+   ((offset) << 2
 
 #define E1000_READ_REG_ARRAY(a, reg, offset) ( \
-readl((a)->hw_addr + \
-(((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
-((offset) << 2)))
+readl((a)->hw_addr + \
+   (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
+   ((offset) << 2)))
 
 #define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
 #define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
 
 #define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
-writew((value), ((a)->hw_addr + \
-(((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
-((offset) << 1
+  writew((value), ((a)->hw_addr + \
+   (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
+   ((offset) << 1
 
 #define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
-readw((a)->hw_addr + \
-(((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
-((offset) << 1)))
+ readw((a)->hw_addr + \
+   (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
+   ((offset) << 1)))
 
 #define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
-writeb((value), ((a)->hw_addr + \
-(((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
-(offset
+  writeb((value), ((a)->hw_addr + \
+   (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
+   (offset
 
 #define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
-readb((a)->hw_addr + \
-(((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
-(offset)))
+ readb((a)->hw_addr + \
+   (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
+   (offset)))
 
 #define E1000_WRITE_FLUSH() er32(STATUS)
 
 #define E1000_WRITE_ICH_FLASH_REG(a, reg, value) ( \
-writel((value), ((a)->flash_address + reg)))
+ writel((value), ((a)->flash_address + reg)))
 
 #define E1000_READ_ICH_FLASH_REG(a, reg) ( \
-readl((a)->flash_address + reg))
+readl((a)->flash_address + reg))
 
 #define E1000_WRITE_ICH_FLASH_REG16(a, reg, value) ( \
-writew((value), ((a)->flash_address + reg)))
+   writew((value), ((a)->flash_address + reg)))
 
 #define E1000_READ_ICH_FLASH_REG16(a, reg) ( \
-readw((a)->flash_address + reg))
+  readw((a)->flash_address + reg))
 
 #endif /* _E1000_OSDEP_H_ */
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] e1000 driver remove checkpatch errors, warnings and checks.

2015-10-13 Thread Janusz Wolak
From: Janusz Wolak 

Signed-off-by: Janusz Wolak 
---
 drivers/net/ethernet/intel/e1000/e1000_hw.h | 154 +++-
 1 file changed, 80 insertions(+), 74 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_hw.h 
b/drivers/net/ethernet/intel/e1000/e1000_hw.h
index 5cf7268c..65a9640 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_hw.h
+++ b/drivers/net/ethernet/intel/e1000/e1000_hw.h
@@ -1,5 +1,5 @@
 
/***
-
+*
   Intel PRO/1000 Linux driver
   Copyright(c) 1999 - 2006 Intel Corporation.
 
@@ -285,7 +285,7 @@ typedef enum {
 #define E1000_BLK_PHY_RESET   12
 
 #define E1000_BYTE_SWAP_WORD(_value) _value) & 0x00ff) << 8) | \
- (((_value) & 0xff00) >> 8))
+(((_value) & 0xff00) >> 8))
 
 /* Function prototypes */
 /* Initialization */
@@ -299,11 +299,11 @@ s32 e1000_setup_link(struct e1000_hw *hw);
 s32 e1000_phy_setup_autoneg(struct e1000_hw *hw);
 void e1000_config_collision_dist(struct e1000_hw *hw);
 s32 e1000_check_for_link(struct e1000_hw *hw);
-s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 * speed, u16 * duplex);
+s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex);
 s32 e1000_force_mac_fc(struct e1000_hw *hw);
 
 /* PHY */
-s32 e1000_read_phy_reg(struct e1000_hw *hw, u32 reg_addr, u16 * phy_data);
+s32 e1000_read_phy_reg(struct e1000_hw *hw, u32 reg_addr, u16 *phy_data);
 s32 e1000_write_phy_reg(struct e1000_hw *hw, u32 reg_addr, u16 data);
 s32 e1000_phy_hw_reset(struct e1000_hw *hw);
 s32 e1000_phy_reset(struct e1000_hw *hw);
@@ -344,6 +344,7 @@ struct e1000_host_mng_command_info {
struct e1000_host_mng_command_header command_header;/* Command 
Head/Command Result Head has 4 bytes */
u8 command_data[E1000_HI_MAX_MNG_DATA_LENGTH];  /* Command data can 
length 0..0x658 */
 };
+
 #ifdef __BIG_ENDIAN
 struct e1000_host_mng_dhcp_cookie {
u32 signature;
@@ -369,16 +370,16 @@ struct e1000_host_mng_dhcp_cookie {
 #endif
 
 bool e1000_check_mng_mode(struct e1000_hw *hw);
-s32 e1000_read_eeprom(struct e1000_hw *hw, u16 reg, u16 words, u16 * data);
+s32 e1000_read_eeprom(struct e1000_hw *hw, u16 reg, u16 words, u16 *data);
 s32 e1000_validate_eeprom_checksum(struct e1000_hw *hw);
 s32 e1000_update_eeprom_checksum(struct e1000_hw *hw);
-s32 e1000_write_eeprom(struct e1000_hw *hw, u16 reg, u16 words, u16 * data);
+s32 e1000_write_eeprom(struct e1000_hw *hw, u16 reg, u16 words, u16 *data);
 s32 e1000_read_mac_addr(struct e1000_hw *hw);
 
 /* Filters (multicast, vlan, receive) */
-u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 * mc_addr);
+u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr);
 void e1000_mta_set(struct e1000_hw *hw, u32 hash_value);
-void e1000_rar_set(struct e1000_hw *hw, u8 * mc_addr, u32 rar_index);
+void e1000_rar_set(struct e1000_hw *hw, u8 *mc_addr, u32 rar_index);
 void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value);
 
 /* LED functions */
@@ -401,10 +402,8 @@ int e1000_pcix_get_mmrbc(struct e1000_hw *hw);
 /* Port I/O is only supported on 82544 and newer */
 void e1000_io_write(struct e1000_hw *hw, unsigned long port, u32 value);
 
-#define E1000_READ_REG_IO(a, reg) \
-e1000_read_reg_io((a), E1000_##reg)
-#define E1000_WRITE_REG_IO(a, reg, val) \
-e1000_write_reg_io((a), E1000_##reg, val)
+#define E1000_READ_REG_IO(a, reg) e1000_read_reg_io((a), E1000_##reg)
+#define E1000_WRITE_REG_IO(a, reg, val) e1000_write_reg_io((a), E1000_##reg, 
val)
 
 /* PCI Device IDs */
 #define E1000_DEV_ID_82542   0x1000
@@ -467,8 +466,7 @@ void e1000_io_write(struct e1000_hw *hw, unsigned long 
port, u32 value);
 #define ENET_HEADER_SIZE 14
 #define MINIMUM_ETHERNET_FRAME_SIZE  64/* With FCS */
 #define ETHERNET_FCS_SIZE4
-#define MINIMUM_ETHERNET_PACKET_SIZE \
-(MINIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE)
+#define MINIMUM_ETHERNET_PACKET_SIZE (MINIMUM_ETHERNET_FRAME_SIZE - 
ETHERNET_FCS_SIZE)
 #define CRC_LENGTH   ETHERNET_FCS_SIZE
 #define MAX_JUMBO_FRAME_SIZE 0x3F00
 
@@ -489,9 +487,7 @@ void e1000_io_write(struct e1000_hw *hw, unsigned long 
port, u32 value);
  *   o RXDMT0 = Receive Descriptor Minimum Threshold hit (ring 0)
  *   o RXSEQ  = Receive Sequence Error
  */
-#define POLL_IMS_ENABLE_MASK ( \
-E1000_IMS_RXDMT0 | \
-E1000_IMS_RXSEQ)
+#define POLL_IMS_ENABLE_MASK (E1000_IMS_RXDMT0 | E1000_IMS_RXSEQ)
 
 /* This defines the bits that are set in the Interrupt Mask
  * Set/Read Register.  Each bit is documented below:
@@ -501,12 +497,8 @@ void e1000_io_write(struct e1000_hw *hw, unsigned long 
port, u32 value);
  *   o RXSEQ  = Receive Sequence Error
  *   o LSC= Link Status Change
  */
-#define IMS_ENABLE_MASK ( \
-E1000_IMS_RXT0   |\
-E1000_IMS_TXDW   |\
-E1000_IMS_RXDMT0 |\
-E1000_IMS_RXSEQ  |\
-E1

[PATCH 3/6] e1000 driver remove checkpatch errors, warnings and checks.

2015-10-13 Thread Janusz Wolak
From: Janusz Wolak 

Signed-off-by: Janusz Wolak 
---
 drivers/net/ethernet/intel/e1000/e1000.h | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000.h 
b/drivers/net/ethernet/intel/e1000/e1000.h
index 6970710..ec82b2d 100644
--- a/drivers/net/ethernet/intel/e1000/e1000.h
+++ b/drivers/net/ethernet/intel/e1000/e1000.h
@@ -1,5 +1,5 @@
 
/***
-
+*
   Intel PRO/1000 Linux driver
   Copyright(c) 1999 - 2006 Intel Corporation.
 
@@ -26,7 +26,6 @@
 
 
***/
 
-
 /* Linux PRO/1000 Ethernet Driver main header file */
 
 #ifndef _E1000_H_
@@ -53,7 +52,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -82,8 +81,7 @@ struct e1000_adapter;
 
 #define E1000_MAX_INTR 10
 
-/*
- * Count for polling __E1000_RESET condition every 10-20msec.
+/* Count for polling __E1000_RESET condition every 10-20msec.
  */
 #define E1000_CHECK_RESET_COUNT50
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6] e1000 driver remove checkpatch errors, warnings and checks.

2015-10-13 Thread Janusz Wolak
From: Janusz Wolak 

Signed-off-by: Janusz Wolak 
---
 drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 31 ++--
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c 
b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
index 4270ad2..c4ffab4 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
@@ -36,12 +36,12 @@ struct e1000_stats {
int stat_offset;
 };
 
-#define E1000_STAT(m)  E1000_STATS, \
+#define E1000_STAT(m)  (E1000_STATS, \
sizeof(((struct e1000_adapter *)0)->m), \
-   offsetof(struct e1000_adapter, m)
-#define E1000_NETDEV_STAT(m)   NETDEV_STATS, \
+   offsetof(struct e1000_adapter, m))
+#define E1000_NETDEV_STAT(m)   (NETDEV_STATS, \
sizeof(((struct net_device *)0)->m), \
-   offsetof(struct net_device, m)
+   offsetof(struct net_device, m))
 
 static const struct e1000_stats e1000_gstrings_stats[] = {
{ "rx_packets", E1000_STAT(stats.gprc) },
@@ -114,7 +114,7 @@ static int e1000_get_settings(struct net_device *netdev,
   SUPPORTED_10baseT_Full |
   SUPPORTED_100baseT_Half |
   SUPPORTED_100baseT_Full |
-  SUPPORTED_1000baseT_Full|
+  SUPPORTED_1000baseT_Full |
   SUPPORTED_Autoneg |
   SUPPORTED_TP);
ecmd->advertising = ADVERTISED_TP;
@@ -708,8 +708,7 @@ static bool reg_set_and_check(struct e1000_adapter 
*adapter, u64 *data, int reg,
writel(write & mask, address);
read = readl(address);
if ((read & mask) != (write & mask)) {
-   e_err(drv, "set/check reg %04X test failed: "
- "got 0x%08X expected 0x%08X\n",
+   e_err(drv, "set/check reg %04X test failed: got 0x%08X expected 
0x%08X\n",
  reg, (read & mask), (write & mask));
*data = reg;
return true;
@@ -1021,7 +1020,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter 
*adapter)
ret_val = 2;
goto err_nomem;
}
-   txdr->next_to_use = txdr->next_to_clean = 0;
+   txdr->next_to_use = 0;
+   txdr->next_to_clean = 0;
 
ew32(TDBAL, ((u64)txdr->dma & 0x));
ew32(TDBAH, ((u64)txdr->dma >> 32));
@@ -1079,7 +1079,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter 
*adapter)
ret_val = 6;
goto err_nomem;
}
-   rxdr->next_to_use = rxdr->next_to_clean = 0;
+   rxdr->next_to_use = 0;
+   rxdr->next_to_clean = 0;
 
rctl = er32(RCTL);
ew32(RCTL, rctl & ~E1000_RCTL_EN);
@@ -1251,7 +1252,7 @@ static int e1000_integrated_phy_loopback(struct 
e1000_adapter *adapter)
ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
-   E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
+   E1000_CTRL_SPD_1000 | /* Force Speed to 1000 */
E1000_CTRL_FD); /* Force Duplex to FULL */
 
if (hw->media_type == e1000_media_type_copper &&
@@ -1293,7 +1294,8 @@ static int e1000_set_phy_loopback(struct e1000_adapter 
*adapter)
 * attempt this 10 times.
 */
while (e1000_nonintegrated_phy_loopback(adapter) &&
-  count++ < 10);
+  count++ < 10)
+   ;
if (count < 11)
return 0;
}
@@ -1420,7 +1422,9 @@ static int e1000_run_loopback_test(struct e1000_adapter 
*adapter)
else
lc = ((rxdr->count / 64) * 2) + 1;
 
-   k = l = 0;
+   k = 0;
+   l = 0;
+
for (j = 0; j <= lc; j++) { /* loop count loop */
for (i = 0; i < 64; i++) { /* send the packets */
e1000_create_lbtest_frame(txdr->buffer_info[i].skb,
@@ -1796,7 +1800,8 @@ static int e1000_set_coalesce(struct net_device *netdev,
return -EINVAL;
 
if (ec->rx_coalesce_usecs == 4) {
-   adapter->itr = adapter->itr_setting = 4;
+   adapter->itr = 4;
+   adapter->itr_setting = 4;
} else if (ec->rx_coalesce_usecs <= 3) {
adapter->itr = 2;
adapter->itr_setting = ec->rx_coalesce_usecs;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe n

[PATCH 1/6] e1000 driver remove checkpatch errors, warnings and checks.

2015-10-13 Thread Janusz Wolak
From: Janusz Wolak 

Signed-off-by: Janusz Wolak 
---
 drivers/net/ethernet/intel/e1000/e1000_main.c | 145 ++
 1 file changed, 76 insertions(+), 69 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c 
b/drivers/net/ethernet/intel/e1000/e1000_main.c
index e0c3c14..583a094 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -1,5 +1,5 @@
 
/***
-
+*
   Intel PRO/1000 Linux driver
   Copyright(c) 1999 - 2006 Intel Corporation.
 
@@ -34,7 +34,7 @@
 #include 
 
 char e1000_driver_name[] = "e1000";
-static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
+static const char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
 #define DRV_VERSION "7.3.21-k8-NAPI"
 const char e1000_driver_version[] = DRV_VERSION;
 static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel 
Corporation.";
@@ -149,6 +149,7 @@ static void e1000_alloc_dummy_rx_buffers(struct 
e1000_adapter *adapter,
 int cleaned_count)
 {
 }
+
 static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
   struct e1000_rx_ring *rx_ring,
   int cleaned_count);
@@ -185,14 +186,14 @@ static void e1000_shutdown(struct pci_dev *pdev);
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
 /* for netdump / net console */
-static void e1000_netpoll (struct net_device *netdev);
+static void e1000_netpoll(struct net_device *netdev);
 #endif
 
 #define COPYBREAK_DEFAULT 256
 static unsigned int copybreak __read_mostly = COPYBREAK_DEFAULT;
 module_param(copybreak, uint, 0644);
 MODULE_PARM_DESC(copybreak,
-   "Maximum size of packet that is copied to a new buffer on receive");
+"Maximum size of packet that is copied to a new buffer on 
receive");
 
 static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
pci_channel_state_t state);
@@ -224,7 +225,7 @@ MODULE_DESCRIPTION("Intel(R) PRO/1000 Network Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
 
-#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV|NETIF_MSG_PROBE|NETIF_MSG_LINK)
+#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
 static int debug = -1;
 module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
@@ -237,6 +238,7 @@ MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
 struct net_device *e1000_get_hw_dev(struct e1000_hw *hw)
 {
struct e1000_adapter *adapter = hw->back;
+
return adapter->netdev;
 }
 
@@ -249,6 +251,7 @@ struct net_device *e1000_get_hw_dev(struct e1000_hw *hw)
 static int __init e1000_init_module(void)
 {
int ret;
+
pr_info("%s - version %s\n", e1000_driver_string, e1000_driver_version);
 
pr_info("%s\n", e1000_copyright);
@@ -258,8 +261,7 @@ static int __init e1000_init_module(void)
if (copybreak == 0)
pr_info("copybreak disabled\n");
else
-   pr_info("copybreak enabled for "
-  "packets <= %u bytes\n", copybreak);
+   pr_info("copybreak enabled for packets <= %u bytes\n", 
copybreak);
}
return ret;
 }
@@ -288,9 +290,8 @@ static int e1000_request_irq(struct e1000_adapter *adapter)
 
err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name,
  netdev);
-   if (err) {
+   if (err)
e_err(probe, "Unable to allocate interrupt Error: %d\n", err);
-   }
 
return err;
 }
@@ -406,6 +407,7 @@ static void e1000_configure(struct e1000_adapter *adapter)
 */
for (i = 0; i < adapter->num_rx_queues; i++) {
struct e1000_rx_ring *ring = &adapter->rx_ring[i];
+
adapter->alloc_rx_buf(adapter, ring,
  E1000_DESC_UNUSED(ring));
}
@@ -466,7 +468,7 @@ static void e1000_power_down_phy(struct e1000_adapter 
*adapter)
 * (c) SoL/IDER session is active
 */
if (!adapter->wol && hw->mac_type >= e1000_82540 &&
-  hw->media_type == e1000_media_type_copper) {
+   hw->media_type == e1000_media_type_copper) {
u16 mii_reg = 0;
 
switch (hw->mac_type) {
@@ -501,8 +503,7 @@ static void e1000_down_and_stop(struct e1000_adapter 
*adapter)
 
cancel_delayed_work_sync(&adapter->watchdog_task);
 
-   /*
-* Since the watchdog task can reschedule other tasks, we should cancel
+   /* Since the watchdog task can reschedule other tasks, we should cancel
 * it first, otherwise we can run into the situation when a work is
 * still running after the adapter has been turned down.
 */
@@ -806,7 +807,7 @@ static in

[PATCH 5/6] e1000 driver remove checkpatch errors, warnings and checks.

2015-10-13 Thread Janusz Wolak
From: Janusz Wolak 

Signed-off-by: Janusz Wolak 
---
 drivers/net/ethernet/intel/e1000/e1000_param.c | 114 ++---
 1 file changed, 82 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_param.c 
b/drivers/net/ethernet/intel/e1000/e1000_param.c
index c9cde35..9ec730e 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_param.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_param.c
@@ -1,5 +1,5 @@
 
/***
-
+*
   Intel PRO/1000 Linux driver
   Copyright(c) 1999 - 2006 Intel Corporation.
 
@@ -45,10 +45,10 @@
 
 #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
 #define E1000_PARAM(X, desc) \
-   static int X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
+   static int X[E1000_MAX_NIC + 1] = E1000_PARAM_INIT; \
static unsigned int num_##X; \
module_param_array_named(X, X, int, &num_##X, 0); \
-   MODULE_PARM_DESC(X, desc);
+   MODULE_PARM_DESC(X, desc)
 
 /* Transmit Descriptor Count
  *
@@ -200,6 +200,7 @@ struct e1000_option {
} r;
struct { /* list_option info */
int nr;
+
const struct e1000_opt_list { int i; char *str; } *p;
} l;
} arg;
@@ -250,7 +251,7 @@ static int e1000_validate_option(unsigned int *value,
}
 
e_dev_info("Invalid %s value specified (%i) %s\n",
-  opt->name, *value, opt->err);
+  opt->name, *value, opt->err);
*value = opt->def;
return -1;
 }
@@ -291,7 +292,8 @@ void e1000_check_options(struct e1000_adapter *adapter)
.arg  = { .r = {
.min = E1000_MIN_TXD,
.max = mac_type < e1000_82544 ? E1000_MAX_TXD : 
E1000_MAX_82544_TXD
-   }}
+  }
+   }
};
 
if (num_TxDescriptors > bd) {
@@ -320,7 +322,8 @@ void e1000_check_options(struct e1000_adapter *adapter)
.min = E1000_MIN_RXD,
.max = mac_type < e1000_82544 ? E1000_MAX_RXD :
   E1000_MAX_82544_RXD
-   }}
+  }
+   }
};
 
if (num_RxDescriptors > bd) {
@@ -344,6 +347,7 @@ void e1000_check_options(struct e1000_adapter *adapter)
 
if (num_XsumRX > bd) {
unsigned int rx_csum = XsumRX[bd];
+
e1000_validate_option(&rx_csum, &opt, adapter);
adapter->rx_csum = rx_csum;
} else {
@@ -366,15 +370,20 @@ void e1000_check_options(struct e1000_adapter *adapter)
.err  = "reading default settings from EEPROM",
.def  = E1000_FC_DEFAULT,
.arg  = { .l = { .nr = ARRAY_SIZE(fc_list),
-.p = fc_list }}
+.p = fc_list
+  }
+   }
};
 
if (num_FlowControl > bd) {
unsigned int fc = FlowControl[bd];
+
e1000_validate_option(&fc, &opt, adapter);
-   adapter->hw.fc = adapter->hw.original_fc = fc;
+   adapter->hw.fc = fc;
+   adapter->hw.original_fc = fc;
} else {
-   adapter->hw.fc = adapter->hw.original_fc = opt.def;
+   adapter->hw.fc = opt.def;
+   adapter->hw.original_fc = opt.def;
}
}
{ /* Transmit Interrupt Delay */
@@ -384,13 +393,15 @@ void e1000_check_options(struct e1000_adapter *adapter)
.err  = "using default of " 
__MODULE_STRING(DEFAULT_TIDV),
.def  = DEFAULT_TIDV,
.arg  = { .r = { .min = MIN_TXDELAY,
-.max = MAX_TXDELAY }}
+.max = MAX_TXDELAY
+  }
+   }
};
 
if (num_TxIntDelay > bd) {
adapter->tx_int_delay = TxIntDelay[bd];
e1000_validate_option(&adapter->tx_int_delay, &opt,
- adapter);
+ adapter);
} else {
adapter->tx_int_delay = opt.def;
}
@@ -402,7 +413,9 @@ void e1000_check_options(struct e1000_adapter *adapter)
.err  = "using default of " 
__MODULE_STRING(DEFAULT_TADV),
.def  = DEFA

Re: e1000_driver_checkpatch_remove_errors_warnings_checks

2015-10-13 Thread Janusz Wolak
I had used checkpatch.pl as You suggested. I decided to leave gmail( 
janusz...@gmail.com ) because I had had problems with git send-email (I 
guess that e-mail client caused the last problem). I've switched to 
januszwo...@awokados.com.pl



W dniu 13.10.2015 o 08:37, Jeff Kirsher pisze:

On Sun, 2015-10-11 at 21:11 +0200, Janusz Wolak wrote:

  From daf0a1f5100c21f10b9e08829433258267748c44 Mon Sep 17 00:00:00
2001
From: Janusz Wolak 
Date: Tue, 6 Oct 2015 21:03:19 +0200
Subject: [PATCH 1/6] Remove checkpatch warnings and checks.

Signed-off-by: Janusz Wolak 
---
   drivers/net/ethernet/intel/e1000/e1000_main.c | 145
++
   1 file changed, 76 insertions(+), 69 deletions(-)


Your patch is not applicable, because you sent a corrupt patch.  Please
use checkpatch.pl on your patches before sending them out for review.


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 1/4] Produce system time from correlated clocksource

2015-10-13 Thread Richard Cochran
On Tue, Oct 13, 2015 at 09:15:51PM +0200, Thomas Gleixner wrote:
> That's not working. The firmware is not going to change, no matter
> what.

Can we at least have a explanation of how the firmware operates?  How
are (ART,sys) pairs are generated, and how they are supposed to get
into the DSP?

Thanks,
Richard



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/1] Fix for module license in Broadcom Phy Library

2015-10-13 Thread Arun Parameswaran
Hi
This patchset adds the module description, license & author to the
Broadcom Phy Library (drivers/net/phy/bcm-phy-lib.c) introduced by
the commit: a1cba5613edf5 ("net: phy: Add Broadcom phy library for
common interfaces")

Arun Parameswaran (1):
  net: phy: bcm-phy-lib: Fix module license issue

 drivers/net/phy/bcm-phy-lib.c | 4 
 1 file changed, 4 insertions(+)

-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] net: phy: bcm-phy-lib: Fix module license issue

2015-10-13 Thread Arun Parameswaran
The 'bcm-phy-lib.c', added as a part of the commit
"net: phy: Add Broadcom phy library for common interfaces"
was missing the module license. This was causing an issue
when the library is built as a module; "module license
'unspecified' taints kernel".

This patch fixes the issue by adding the module license,
author and description to the bcm-phy-lib.c file.

Fixes: a1cba5613edf5 ("net: phy: Add Broadcom phy library for common
interfaces")
Signed-off-by: Arun Parameswaran 
---
 drivers/net/phy/bcm-phy-lib.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c
index 13e161e..ddb377e 100644
--- a/drivers/net/phy/bcm-phy-lib.c
+++ b/drivers/net/phy/bcm-phy-lib.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define MII_BCM_CHANNEL_WIDTH 0x2000
@@ -207,3 +208,6 @@ int bcm_phy_enable_eee(struct phy_device *phydev)
 }
 EXPORT_SYMBOL_GPL(bcm_phy_enable_eee);
 
+MODULE_DESCRIPTION("Broadcom PHY Library");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Broadcom Corporation");
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i40evf: fix 32 bit build warnings

2015-10-13 Thread Arnd Bergmann
On Tuesday 13 October 2015 12:25:10 Jesse Brandeburg wrote:
> On Tue, 13 Oct 2015 13:37:04 +0200
> Arnd Bergmann  wrote:
> 
> > On Monday 12 October 2015 23:18:21 you wrote:
> > > On Wed, 2015-10-07 at 22:13 +0200, Arnd Bergmann wrote:
> > > > Jesse Brandeburg fixed a bug for 32-bit systems in the i40e driver
> > > > in commit 9c70d7cebfec5 ("i40e: fix 32 bit build warnings"), but the
> > > > same code still exists in the i40evf driver and causes compilation
> > > > warnings in ARM and x86 allmodconfig:
> > > > 
> > > > drivers/net/ethernet/intel/i40evf/i40e_common.c:445:68: warning: cast
> > > > from pointer to integer of different size [-Wpointer-to-int-cast]
> > > > drivers/net/ethernet/intel/i40evf/i40e_common.c:446:71: warning: cast
> > > > from pointer to integer of different size [-Wpointer-to-int-cast]
> > > > 
> > > > This applies the same fix by removing the broken code.
> > > > 
> > > > Signed-off-by: Arnd Bergmann 
> > > 
> > > Does not apply at all to my next-queue tree (dev-queue branch), my
> > > guess is that this is already fixed in one of the patches already in my
> > > queue.
> > > 
> > 
> > I still get these warnings on your branch:
> 
> Make sure you're pulling from the dev-queue branch, not the master
> branch of Jeff's next-queue repo.

Indeed, I was only looking at the branch that last got pulled into
net-next, assuming that was the one that was where the fixes for 4.3
are in. Sorry about that.

> I've made that mistake many times, and I do see that the code in
> question is not present in:
> https://git.kernel.org/cgit/linux/kernel/git/jkirsher/next-queue.git/tree/drivers/net/ethernet/intel/i40evf/i40e_common.c?h=dev-queue

Ok, I see your commit 7890f6979a8 ("i40evf: fix overlong BIT defines")
there now. Any chance to get that into mainline? The branch appears
to have a mix of new features and bug fixes, so it looks like it's
at least not destined for 4.3.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 1/4] Produce system time from correlated clocksource

2015-10-13 Thread Thomas Gleixner
On Mon, 12 Oct 2015, Christopher S. Hall wrote:
> Another representative use case of time sync and the correlated
> clocksource (in addition to PTP noted above) is PTP synchronized
> audio.

This wants to be a seperate patch, really.
 
> +/* This needs to be 3 or greater for backtracking to be useful */

Why?

> +#define SHADOW_HISTORY_DEPTH 7

And that number is 7 because?

>  static DEFINE_RAW_SPINLOCK(timekeeper_lock);
> -static struct timekeeper shadow_timekeeper;
> +static struct timekeeper shadow_timekeeper[SHADOW_HISTORY_DEPTH];
> +static int shadow_index = -1; /* incremented to zero in timekeeping_init() */

What's the point of this? Aside of that, please do not use tail comments.

> +static bool shadow_timekeeper_full;

That's silly. Make DEPTH a power of 2 and do:

   idx = (idx + 1) & (DEPTH - 1);

> +/*
> + * Modifies shadow index argument to point to the next array element
> + * Returns bool indicating shadow array fullness after the update
> + */
> +static bool get_next_shadow_index(int *shadow_index_out)
> +{
> + *shadow_index_out = (shadow_index + 1) % SHADOW_HISTORY_DEPTH;
> + /*
> +  * If shadow timekeeper is full it stays full, otherwise compute
> +  * the next value based on whether the index rolls over
> +  */
> + return shadow_timekeeper_full ?
> + true : *shadow_index_out < shadow_index;

All this can go away.

> + if (action & TK_MIRROR) {
> + int next_shadow_index;
> + bool next_shadow_full =
> + get_next_shadow_index(&next_shadow_index);
> + memcpy(shadow_timekeeper+next_shadow_index,
> +&tk_core.timekeeper, sizeof(tk_core.timekeeper));
> + shadow_index = next_shadow_index;
> + shadow_timekeeper_full = next_shadow_full;

Ditto.

> + }
>  }
>  
>  /**
> @@ -884,6 +923,142 @@ EXPORT_SYMBOL(getnstime_raw_and_real);
>  
>  #endif /* CONFIG_NTP_PPS */
>  
> +/*
> + * Iterator-like function which can be called multiple times to return the
> + * previous shadow_index
> + * Returns false when finding previous is not possible because:
> + * - The array is not full
> + * - The previous shadow_index refers to an entry that may be in-flight
> + */
> +static bool get_prev_shadow_index(int *shadow_index_io)
> +{
> + int guard_index;
> + int ret = (*shadow_index_io - 1) % SHADOW_HISTORY_DEPTH;
> +
> + ret += ret < 0 ? SHADOW_HISTORY_DEPTH : 0;
> + /*
> +  * guard_index references the next shadow entry, assume that this
> +  * isn't valid since its not protected by sequence lock
> +  */
> + get_next_shadow_index(&guard_index);
> + /* if the array isn't full and index references top (invalid) entry */
> + if (!shadow_timekeeper_full && ret > *shadow_index_io)
> + return false;
> + /* the next entry may be in-flight and may be invalid  */
> + if (ret == guard_index)
> + return false;
> + /* Also make sure that entry is valid based on current shadow_index */
> + *shadow_index_io = ret;
> + return true;

You surely try hard to do stuff in the most unreadable way. 

> +/**
> + * get_correlated_timestamp - Get a correlated timestamp
> + * @crs: conversion between correlated clock and system clock
> + * @crt: callback to get simultaneous device and correlated clock value *or*
> + *   contains a valid correlated clock value and NULL callback
> + *
> + * Reads a timestamp from a device and correlates it to system time.  This
> + * function can be used in two ways.  If a non-NULL get_ts function pointer 
> is
> + * supplied in @crt, this function is called within the retry loop to
> + * read the current correlated clock value and associated device time.
> + * Otherwise (get_ts is NULL) a correlated clock value is supplied and
> + * the history in shadow_timekeeper is consulted if necessary.
> + */
> +int get_correlated_timestamp(struct correlated_ts *crt,
> +  struct correlated_cs *crs)
> +{
> + struct timekeeper *tk = &tk_core.timekeeper;
> + unsigned long seq;
> + cycles_t cycles, cycles_now, cycles_last;
> + ktime_t base;
> + s64 nsecs;
> + int ret;
> +
> + do {
> + seq = read_seqcount_begin(&tk_core.seq);
> + /*
> +  * Verify that the correlated clocksoure is related to
> +  * the currently installed timekeeper clocksoure
> +  */
> + if (tk->tkr_mono.clock != crs->related_cs)
> + return -ENODEV;
> +
> + /*
> +  * Get a timestamp from the device if get_ts is non-NULL
> +  */
> + if( crt->get_ts ) {
> + ret = crt->get_ts(crt);
> + if (ret)
> + return ret;
> + }

What's the point of this? Why are you not making the few lines which
you can actually reuse a helper function and leave the PTP code alone?

> -- 
> 2

Re: [PATCH] i40evf: fix 32 bit build warnings

2015-10-13 Thread Jesse Brandeburg
On Tue, 13 Oct 2015 12:05:32 -0700
Jeff Kirsher  wrote:

> On Tue, 2015-10-13 at 13:37 +0200, Arnd Bergmann wrote:
> > This is the majority of all build warnings we get on allmodconfig
> > (both i386 and arm),
> > so it would be really nice to have it fixed before 4.3. For all I can
> > tell, the
> > patch still applies on your branch too, but see below for the rebased
> > version.
> > 
> > I also note that your branch is not part of linux-next, is that
> > intentional?
> > 
> > Arnd
> 
> Huh are you sure you used by dev-queue branch?  I ask because this is
> what I am getting when I try to apply your patch:
> 
> git am .apply/i40evf-fix-32-bit-build-warnings.patch
> Applying: Jesse Brandeburg fixed a bug for 32-bit systems in the i40e
> driver
> error: patch failed:
> drivers/net/ethernet/intel/i40evf/i40e_common.c:443
> error: drivers/net/ethernet/intel/i40evf/i40e_common.c: patch does not
> apply
> Patch failed at 0001 Jesse Brandeburg fixed a bug for 32-bit systems in
> the i40e driver
> The copy of the patch that failed is found in:
>/home/jtkirshe/Public/next-queue/.git/rebase-apply/patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".
> [12:02:27 @jtkirshe-linux:next-queue]$ patch -p1 <.apply/i40evf-fix-32
> -bit-build-warnings.patch 
> patching file drivers/net/ethernet/intel/i40evf/i40e_common.c
> Reversed (or previously applied) patch detected!  Assume -R? [n] 
> Apply anyway? [n] 
> Skipping patch.
> 2 out of 2 hunks ignored -- saving rejects to file
> drivers/net/ethernet/intel/i40evf/i40e_common.c.rej
> [12:02:52 @jtkirshe-linux:next-queue]$
> 
> Even looking at the code, the code your changing does not exist in my
> dev-queue branch of my next-queue tree. 

it was already fixed via

commit 7890f6979a8eab436487396d6e2e0def8633fa16
Author: Jesse Brandeburg 
Date:   Tue Oct 13 11:15:46 2015 -0700

i40evf: fix overlong BIT defines
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: NULL pointer dereference in rt6_get_cookie()

2015-10-13 Thread Martin KaFai Lau
On Tue, Oct 13, 2015 at 09:10:39PM +0200, Phil Sutter wrote:
> Hi Martin,
>
> On Tue, Oct 13, 2015 at 11:14:43AM -0700, Martin KaFai Lau wrote:
> > On Sat, Oct 10, 2015 at 03:24:37PM +0200, Phil Sutter wrote:
> > > The conditional at the start of the function evaluates true, since
> > > 'rt->rt6i_flags & RTF_PCPU' is non-zero.
> > Hi Phil, can you try the following patch and capture the dmesg output
> > to confirm the value of rt->rt6i_flags and the rt->dst.flags.
> >
> > Thanks,
> > Martin
> >
> > --- a/include/net/ip6_fib.h
> > +++ b/include/net/ip6_fib.h
> > @@ -167,8 +167,15 @@ static inline void rt6_update_expires(struct rt6_info 
> > *rt0, int timeout)
> >
> >  static inline u32 rt6_get_cookie(const struct rt6_info *rt)
> >  {
> > -   if (rt->rt6i_flags & RTF_PCPU || unlikely(rt->dst.flags & DST_NOCACHE))
> > +   if (rt->rt6i_flags & RTF_PCPU || unlikely(rt->dst.flags & DST_NOCACHE)) 
> > {
> > rt = (struct rt6_info *)(rt->dst.from);
> > +   if (!rt)
> > +   pr_err("rt6i_dst:%pI6c/%d rt6i_gateway:%pI6c "
> > +  "rt6i_flags:%08X dst.flags:%08X\n",
> > +  &rt->rt6i_dst.addr, rt->rt6i_dst.plen,
> > +  &rt->rt6i_gateway, rt->rt6i_flags,
> > +  rt->dst.flags);
> > +   }
> >
> > return rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
> >  }
>
> This code is not sane. Your pr_err() statement tries to dereference the
> NULL pointer in question. Are you interested in the originally passed
> rt6_info?
Good catch. sorry about that.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] net: phy: smsc: disable energy detect mode

2015-10-13 Thread Florian Fainelli
On 12/10/15 22:13, Heiko Schocher wrote:
> On some boards the energy enable detect mode leads in
> trouble with some switches, so make the enabling of
> this mode configurable through DT.
> 
> Signed-off-by: Heiko Schocher 
> ---
> 
>  .../devicetree/bindings/net/smsc-lan87xx.txt   | 19 +
>  drivers/net/phy/smsc.c | 24 
> +-
>  2 files changed, 38 insertions(+), 5 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/net/smsc-lan87xx.txt
> 
> diff --git a/Documentation/devicetree/bindings/net/smsc-lan87xx.txt 
> b/Documentation/devicetree/bindings/net/smsc-lan87xx.txt
> new file mode 100644
> index 000..39aa1dc
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/smsc-lan87xx.txt
> @@ -0,0 +1,19 @@
> +SMSC LAN87xx Ethernet PHY
> +
> +Some boards require special tuning values. Configure them
> +through an Ethernet OF device node.
> +
> +Optional properties:
> +
> +- disable-energy-detect:
> +  If set, do not enable energy detect mode for the SMSC phy.
> +  default: enable energy detect mode

Although energy detection is something that is implemented by many PHYs,
I am not sure a generic property is suitable here, I would prefix that
with the SMSC vendor prefix here to make it clear this only applies to
this PHY.

Would not you want to make it a reverse property here though, something
like this:

smsc,energy-detect: boolean, when present indicates the PHY reliably
supports energy detection


> +
> +Examples:
> +
> + /* Attach to an Ethernet device with autodetected PHY */
> + &cpsw_emac0 {
> + phy_id = <&davinci_mdio>, <0>;
> + phy-mode = "mii";
> + disable-energy-detect;
> + };
> diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
> index 70b0895..f90fbf3 100644
> --- a/drivers/net/phy/smsc.c
> +++ b/drivers/net/phy/smsc.c
> @@ -43,16 +43,30 @@ static int smsc_phy_ack_interrupt(struct phy_device 
> *phydev)
>  
>  static int smsc_phy_config_init(struct phy_device *phydev)
>  {
> +#ifdef CONFIG_OF
> + int len;
> + struct device *dev = &phydev->dev;
> + struct device_node *of_node = dev->of_node;

That does not need to be ifdefd out, at best annontate with __maybe_unused?

> +#endif
>   int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
> + int enable_energy = 1;
>  
>   if (rc < 0)
>   return rc;
>  
> - /* Enable energy detect mode for this SMSC Transceivers */
> - rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
> -rc | MII_LAN83C185_EDPWRDOWN);
> - if (rc < 0)
> - return rc;
> +#ifdef CONFIG_OF
> + if (!of_node && dev->parent->of_node)
> + of_node = dev->parent->of_node;

That looks strange, why would the property be placed at the parent level
when this is a PHY device tree node property?

> + if (of_find_property(of_node, "disable-energy-detect", &len))
> + enable_energy = 0;
> +#endif
> + if (enable_energy) {
> + /* Enable energy detect mode for this SMSC Transceivers */
> + rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
> +rc | MII_LAN83C185_EDPWRDOWN);
> + if (rc < 0)
> + return rc;
> + }
>  
>   return smsc_phy_ack_interrupt(phydev);
>  }
> 


-- 
Florian
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: NULL pointer dereference in rt6_get_cookie()

2015-10-13 Thread Phil Sutter
On Tue, Oct 13, 2015 at 09:10:39PM +0200, Phil Sutter wrote:
> Hi Martin,
> 
> On Tue, Oct 13, 2015 at 11:14:43AM -0700, Martin KaFai Lau wrote:
> > On Sat, Oct 10, 2015 at 03:24:37PM +0200, Phil Sutter wrote:
> > > The conditional at the start of the function evaluates true, since
> > > 'rt->rt6i_flags & RTF_PCPU' is non-zero.
> > Hi Phil, can you try the following patch and capture the dmesg output
> > to confirm the value of rt->rt6i_flags and the rt->dst.flags.
> > 
> > Thanks,
> > Martin
> > 
> > --- a/include/net/ip6_fib.h
> > +++ b/include/net/ip6_fib.h
> > @@ -167,8 +167,15 @@ static inline void rt6_update_expires(struct rt6_info 
> > *rt0, int timeout)
> > 
> >  static inline u32 rt6_get_cookie(const struct rt6_info *rt)
> >  {
> > -   if (rt->rt6i_flags & RTF_PCPU || unlikely(rt->dst.flags & DST_NOCACHE))
> > +   if (rt->rt6i_flags & RTF_PCPU || unlikely(rt->dst.flags & DST_NOCACHE)) 
> > {
> > rt = (struct rt6_info *)(rt->dst.from);
> > +   if (!rt)
> > +   pr_err("rt6i_dst:%pI6c/%d rt6i_gateway:%pI6c "
> > +  "rt6i_flags:%08X dst.flags:%08X\n",
> > +  &rt->rt6i_dst.addr, rt->rt6i_dst.plen,
> > +  &rt->rt6i_gateway, rt->rt6i_flags,
> > +  rt->dst.flags);
> > +   }
> > 
> > return rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
> >  }
> 
> This code is not sane. Your pr_err() statement tries to dereference the
> NULL pointer in question. Are you interested in the originally passed
> rt6_info?

I have backed up the rt pointer at top of the function and restored it
before pr_err, this is the output:

| rt6i_dst:2001:4dd0:ff3b:13::/64 rt6i_gateway::: rt6i_flags:4001 
dst.flags:

HTH, Phil
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i40evf: fix 32 bit build warnings

2015-10-13 Thread Jesse Brandeburg
On Tue, 13 Oct 2015 13:37:04 +0200
Arnd Bergmann  wrote:

> On Monday 12 October 2015 23:18:21 you wrote:
> > On Wed, 2015-10-07 at 22:13 +0200, Arnd Bergmann wrote:
> > > Jesse Brandeburg fixed a bug for 32-bit systems in the i40e driver
> > > in commit 9c70d7cebfec5 ("i40e: fix 32 bit build warnings"), but the
> > > same code still exists in the i40evf driver and causes compilation
> > > warnings in ARM and x86 allmodconfig:
> > > 
> > > drivers/net/ethernet/intel/i40evf/i40e_common.c:445:68: warning: cast
> > > from pointer to integer of different size [-Wpointer-to-int-cast]
> > > drivers/net/ethernet/intel/i40evf/i40e_common.c:446:71: warning: cast
> > > from pointer to integer of different size [-Wpointer-to-int-cast]
> > > 
> > > This applies the same fix by removing the broken code.
> > > 
> > > Signed-off-by: Arnd Bergmann 
> > 
> > Does not apply at all to my next-queue tree (dev-queue branch), my
> > guess is that this is already fixed in one of the patches already in my
> > queue.
> > 
> 
> I still get these warnings on your branch:

Make sure you're pulling from the dev-queue branch, not the master
branch of Jeff's next-queue repo.

I've made that mistake many times, and I do see that the code in
question is not present in:
https://git.kernel.org/cgit/linux/kernel/git/jkirsher/next-queue.git/tree/drivers/net/ethernet/intel/i40evf/i40e_common.c?h=dev-queue


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next] route: fib_validate_source remove the <= RT_SCOPE_HOST test

2015-10-13 Thread Julian Anastasov

Hello,

On Wed, 14 Oct 2015, Xin Long wrote:

> commit fe3edf45792a ("ipv4: Remove all RTCF_DIRECTSRC handliing.").
> 
> Before this commit, we had a tristate:
> < 0: error
> 0: ok
> 1: ok and set RTCF_DIRECTSRC
> 
> But now we only care about 0 or < 0.

Not true, __mkroute_input() uses the 'err' result
to set IPSKB_DOREDIRECT.

Regards

--
Julian Anastasov 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 1/4] Produce system time from correlated clocksource

2015-10-13 Thread Thomas Gleixner
On Tue, 13 Oct 2015, Richard Cochran wrote:

> On Tue, Oct 13, 2015 at 09:51:02AM +0200, Thomas Gleixner wrote:
> > 
> > You are restricting the problem space to this particular use
> > case. There are other use cases where PTP is not available or not the
> > relevant reference, but you still want to correlate time domains to
> > ART.
> 
> They may well be other use cases, but they have not been identified
> here.  The PTP to media clock problem has a very simple solution.  You
> do not need a history of system time stamps to solve it.

Well, these use cases are not in the focus of Christopher, but I have
a few in my head. Think industrial fieldbusses.
 
> Even if you wanted to correlate the system time's UTC with the media
> clock, still you don't need any shadow history for that.  Just feed
> (ART, UTC) pairs into the DSP at a regular rate, and let the DSP do
> the math.  This does not need to be part of the central time keeping
> code at all.

That's not working. The firmware is not going to change, no matter
what.

Thanks,

tglx
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: NULL pointer dereference in rt6_get_cookie()

2015-10-13 Thread Phil Sutter
Hi Martin,

On Tue, Oct 13, 2015 at 11:14:43AM -0700, Martin KaFai Lau wrote:
> On Sat, Oct 10, 2015 at 03:24:37PM +0200, Phil Sutter wrote:
> > The conditional at the start of the function evaluates true, since
> > 'rt->rt6i_flags & RTF_PCPU' is non-zero.
> Hi Phil, can you try the following patch and capture the dmesg output
> to confirm the value of rt->rt6i_flags and the rt->dst.flags.
> 
> Thanks,
> Martin
> 
> --- a/include/net/ip6_fib.h
> +++ b/include/net/ip6_fib.h
> @@ -167,8 +167,15 @@ static inline void rt6_update_expires(struct rt6_info 
> *rt0, int timeout)
> 
>  static inline u32 rt6_get_cookie(const struct rt6_info *rt)
>  {
> - if (rt->rt6i_flags & RTF_PCPU || unlikely(rt->dst.flags & DST_NOCACHE))
> + if (rt->rt6i_flags & RTF_PCPU || unlikely(rt->dst.flags & DST_NOCACHE)) 
> {
>   rt = (struct rt6_info *)(rt->dst.from);
> + if (!rt)
> + pr_err("rt6i_dst:%pI6c/%d rt6i_gateway:%pI6c "
> +"rt6i_flags:%08X dst.flags:%08X\n",
> +&rt->rt6i_dst.addr, rt->rt6i_dst.plen,
> +&rt->rt6i_gateway, rt->rt6i_flags,
> +rt->dst.flags);
> + }
> 
>   return rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
>  }

This code is not sane. Your pr_err() statement tries to dereference the
NULL pointer in question. Are you interested in the originally passed
rt6_info?

Cheers, Phil
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i40evf: fix 32 bit build warnings

2015-10-13 Thread Jeff Kirsher
On Tue, 2015-10-13 at 13:37 +0200, Arnd Bergmann wrote:
> This is the majority of all build warnings we get on allmodconfig
> (both i386 and arm),
> so it would be really nice to have it fixed before 4.3. For all I can
> tell, the
> patch still applies on your branch too, but see below for the rebased
> version.
> 
> I also note that your branch is not part of linux-next, is that
> intentional?
> 
> Arnd

Huh are you sure you used by dev-queue branch?  I ask because this is
what I am getting when I try to apply your patch:

git am .apply/i40evf-fix-32-bit-build-warnings.patch
Applying: Jesse Brandeburg fixed a bug for 32-bit systems in the i40e
driver
error: patch failed:
drivers/net/ethernet/intel/i40evf/i40e_common.c:443
error: drivers/net/ethernet/intel/i40evf/i40e_common.c: patch does not
apply
Patch failed at 0001 Jesse Brandeburg fixed a bug for 32-bit systems in
the i40e driver
The copy of the patch that failed is found in:
   /home/jtkirshe/Public/next-queue/.git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
[12:02:27 @jtkirshe-linux:next-queue]$ patch -p1 <.apply/i40evf-fix-32
-bit-build-warnings.patch 
patching file drivers/net/ethernet/intel/i40evf/i40e_common.c
Reversed (or previously applied) patch detected!  Assume -R? [n] 
Apply anyway? [n] 
Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file
drivers/net/ethernet/intel/i40evf/i40e_common.c.rej
[12:02:52 @jtkirshe-linux:next-queue]$

Even looking at the code, the code your changing does not exist in my
dev-queue branch of my next-queue tree. 

signature.asc
Description: This is a digitally signed message part


Re: [PATCH] i40evf: fix 32 bit build warnings

2015-10-13 Thread Jeff Kirsher
On Tue, 2015-10-13 at 13:37 +0200, Arnd Bergmann wrote:
> This is the majority of all build warnings we get on allmodconfig
> (both i386 and arm),
> so it would be really nice to have it fixed before 4.3. For all I can
> tell, the
> patch still applies on your branch too, but see below for the rebased
> version.
> 
> I also note that your branch is not part of linux-next, is that 
> intentional?

No, I assume it is because the linux-next maintainer has not picked up
my tree.

signature.asc
Description: This is a digitally signed message part


Re: [PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code

2015-10-13 Thread Vivien Didelot
On Oct. Tuesday 13 (42) 12:46 PM, Vivien Didelot wrote:
> There is no need to write the MAC address before every Get Next
> operation, since ATU MAC registers are not cleared between calls.
> 
> Move the _mv88e6xxx_atu_mac_write call outside of _mv88e6xxx_atu_getnext
> so future code could call ATU Get Next multiple times and save a few
> register access.

Signed-off-by: Vivien Didelot 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code

2015-10-13 Thread Florian Fainelli
On 13/10/15 11:11, Vivien Didelot wrote:
> On Oct. Tuesday 13 (42) 10:35 AM, Florian Fainelli wrote:
>> On 13/10/15 09:46, Vivien Didelot wrote:
>>> There is no need to write the MAC address before every Get Next
>>> operation, since ATU MAC registers are not cleared between calls.
>>>
>>> Move the _mv88e6xxx_atu_mac_write call outside of _mv88e6xxx_atu_getnext
>>> so future code could call ATU Get Next multiple times and save a few
>>> register access.
>>
>> Missing SoB tag here.
> 
> Damn, good catch. Can I add it in reply to the patch, or should I send a
> v3?

I am fairly positive patchwork should be able to pick it up, so replying
to your patch might just do it fine.
-- 
Florian
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [4.1.3-rt8] [report][cpuhotplug] BUG: spinlock bad magic on CPU#0, sh/137

2015-10-13 Thread Grygorii Strashko
On 10/12/2015 11:16 AM, Thomas Gleixner wrote:
> On Fri, 9 Oct 2015, Grygorii Strashko wrote:
>> I can constantly see below error report with 4.1 RT-kernel on TI ARM dra7-evm
>> if I'm trying to unplug cpu1:
>>
>> [   57.737589] CPU1: shutdown
>> [   57.767537] BUG: spinlock bad magic on CPU#0, sh/137
>> [   57.767546]  lock: 0xee994730, .magic: , .owner: /-1, 
>> .owner_cpu: 0
> 
>> It looks like this backtrace was introduces by
>>
>> commit 91df05da13a6c6c358e71182e80f19f3c48d1615
>> net: Use skbufhead with raw lock
>>
>> I see the potential fix for this issue as below:
>>
>> index 4969c0d..f8c23de 100644
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -7217,7 +7217,7 @@ static int dev_cpu_callback(struct notifier_block *nfb,
>>  netif_rx_ni(skb);
>>  input_queue_head_incr(oldsd);
>>  }
>> -   while ((skb = skb_dequeue(&oldsd->input_pkt_queue))) {
>> +   while ((skb = __skb_dequeue(&oldsd->input_pkt_queue))) {
> 
> Your patch is white space damaged 
> 
>>  netif_rx_ni(skb);
>>  input_queue_head_incr(oldsd);
>>  }
>>
>> input_pkt_queue is per-cpu queue and at this moment cpu is dead already,
>> so no one should touch it. But I'm not sure if my assumption is correct.
> 
> It is. Picking it up for the next release
> 

Thanks & Sorry. I've not expected this diff/hack to be applied as patch :(

-- 
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: NULL pointer dereference in rt6_get_cookie()

2015-10-13 Thread Martin KaFai Lau
On Sat, Oct 10, 2015 at 03:24:37PM +0200, Phil Sutter wrote:
> The conditional at the start of the function evaluates true, since
> 'rt->rt6i_flags & RTF_PCPU' is non-zero.
Hi Phil, can you try the following patch and capture the dmesg output
to confirm the value of rt->rt6i_flags and the rt->dst.flags.

Thanks,
Martin

--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -167,8 +167,15 @@ static inline void rt6_update_expires(struct rt6_info 
*rt0, int timeout)

 static inline u32 rt6_get_cookie(const struct rt6_info *rt)
 {
-   if (rt->rt6i_flags & RTF_PCPU || unlikely(rt->dst.flags & DST_NOCACHE))
+   if (rt->rt6i_flags & RTF_PCPU || unlikely(rt->dst.flags & DST_NOCACHE)) 
{
rt = (struct rt6_info *)(rt->dst.from);
+   if (!rt)
+   pr_err("rt6i_dst:%pI6c/%d rt6i_gateway:%pI6c "
+  "rt6i_flags:%08X dst.flags:%08X\n",
+  &rt->rt6i_dst.addr, rt->rt6i_dst.plen,
+  &rt->rt6i_gateway, rt->rt6i_flags,
+  rt->dst.flags);
+   }

return rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
 }
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next V15 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-13 Thread Pravin Shelar
On Tue, Oct 13, 2015 at 10:39 AM, Thomas F Herbert
 wrote:
> Pravin,
>
> Thanks for the review.
>
>
> On 10/13/15 7:47 AM, Pravin Shelar wrote:
>>
>> On Sat, Oct 10, 2015 at 4:40 PM, Thomas F Herbert
>>  wrote:
>>>
>>> Add support for 802.1ad including the ability to push and pop double
>>> tagged vlans. Add support for 802.1ad to netlink parsing and flow
>>> conversion. Uses double nested encap attributes to represent double
>>> tagged vlan. Inner TPID encoded along with ctci in nested attributes.
>>>
>>> Signed-off-by: Thomas F Herbert 
>>> ---
>>>   net/openvswitch/actions.c  |   6 +-
>>>   net/openvswitch/flow.c |  92 +++
>>>   net/openvswitch/flow.h |  11 ++-
>>>   net/openvswitch/flow_netlink.c | 166
>>> +
>>>   net/openvswitch/vport-netdev.c |   4 +-
>>>   5 files changed, 245 insertions(+), 34 deletions(-)
>>>
>> ...
>>
...

>>
>> I see lot of duplicate code here. How about code below:
>>
>> struct qtag_prefix {
>>  __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
>>  __be16 tci;
>> };
>>
>> /* Return  < 0 on memory error
>>   * Return   == 0 on non vlan or incomplete packet packet
>>   * Return > 0 on successfully parsing vlan tag.
>>   */
>> static int parse_vlan_tag(__be16 vlan_proto, struct sk_buff *skb,
>>struct vlan_tag *cvlan)
>> {
>>  if (likely(!eth_type_vlan(skb->vlan_proto)))
>>  return 0;
>>
>>  if (unlikely(skb->len < sizeof(struct qtag_prefix) +
>> sizeof(__be16))) {
>>  vlan->tci = 0;
>>  return 0;
>>  }
>>
>>  if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
>> sizeof(__be16
>>  return -ENOMEM;
>>
>>  qp = (struct qtag_prefix *)skb->data;
>>  key->eth.cvlan.tci = qp->tci | htons(VLAN_TAG_PRESENT);
>>  key->eth.cvlan.tpid = qp->eth_type;
>>
>>  __skb_pull(skb, sizeof(struct qtag_prefix));
>>  return 1;
>> }
>
> This makes for cleaner code and certainly better for maintainability so I
> have just implemented it for this next revision. However, note that with
> this change, we incur the overhead of an additional function call for single
> tagged vlan packets.
>
If there is any performance issue we can fix the code later.

>>
>> static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
>> {
>>  struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;
...

>>> +   u64 mask_v_attrs = 0;
>>> +
>>> +   err = parse_flow_mask_nlattrs(*nla, a, &mask_v_attrs,
>>> log);
>>> +   if (err)
>>> +   return err;
>>> +
>>> +   if (mask_v_attrs & 1 << OVS_KEY_ATTR_ENCAP) {
>>> +   if (!*ie_valid) {
>>> +   OVS_NLERR(log, "Encap mask attribute is
>>> set for non-CVLAN frame.");
>>> +   err = -EINVAL;
>>> +   return err;
>>> +   }
>>> +   encap = a[OVS_KEY_ATTR_ENCAP];
>>> +
>>> +   err = cust_vlan_from_nlattrs(match, a, is_mask,
>>> log);
>>> +   if (err)
>>> +   return err;
>>> +   *nla = encap;
>>> +
>>
>> There is no checking for ATTR_VLAN or ATTR_ETHERTYPE. This can result
>> in null pointer deference in cust_vlan_from_nlattrs().
>
> The original vlan code does not check for these attribs in the masked case.
> It does check for them in the non-masked case and then sets a boolean and
> checks it in the masked case. I do the same thing for the inner vlan. I
> check for the attributes in the non-masked case and set a boolean and check
> the boolean in the masked case. Why is this not sufficient?

Original code is checking for attributes before referencing them. For
example  in function ovs_nla_get_match() before extracting eth_type,
it does check a[OVS_KEY_ATTR_ETHERTYPE]. But If you spot bug in
current code please send fix for net tree.
Regarding the Boolean, it is for presence of inner vlan for key
attribute, mask attribute still could be missing vlan attribute.
For vlan mask, we can keep check sanity check as outer vlan. It means
eth_type must be specified and should be 0x, and tci mask is
optional and by default initialized to 0x.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code

2015-10-13 Thread Vivien Didelot
On Oct. Tuesday 13 (42) 10:35 AM, Florian Fainelli wrote:
> On 13/10/15 09:46, Vivien Didelot wrote:
> > There is no need to write the MAC address before every Get Next
> > operation, since ATU MAC registers are not cleared between calls.
> > 
> > Move the _mv88e6xxx_atu_mac_write call outside of _mv88e6xxx_atu_getnext
> > so future code could call ATU Get Next multiple times and save a few
> > register access.
> 
> Missing SoB tag here.

Damn, good catch. Can I add it in reply to the patch, or should I send a
v3?

Thanks,
-v
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] netlink: trim skb to exact size to avoid MSG_TRUNC

2015-10-13 Thread Arad, Ronen


>-Original Message-
>From: Thomas Graf [mailto:tg...@suug.ch]
>Sent: Tuesday, October 13, 2015 1:56 AM
>To: Arad, Ronen
>Cc: netdev@vger.kernel.org
>Subject: Re: [PATCH] netlink: trim skb to exact size to avoid MSG_TRUNC
>
>On 10/12/15 at 06:15pm, Ronen Arad wrote:
>> The available room in the skb allocated in netlink_dump for iproute2
>> show requests (e.g. "ip link [show]", "bridge [-c] vlan show") should
>> be trimmed to the exact size requested in order to avoid MSG_TRUNC flag
>> set in netlink_recvmg.
>> This was handled properly for small skb allocated when no interface has
>> many VLANs configured. This patch applies the same logic to larger skbs
>> which are allocated using the calculated min_dump_alloc size.
>>
>> Signed-off-by: Ronen Arad 
>
>Wouldn't this imply a bug in which rtnl_calcit() does not account for
>some data that is later dumped?
[@Ronen] rtnl_calcit() is not bug-free. It is not, however, the direct
cause of the problem this patch intends to solve.
rtnl_calcit() overestimates the min_alloc_size. The space for VLAN_INFO for
the maximum number ov VLANs on any interface is always added to
min_alloc_size even when the dump request does not specify VLAN or
compressed VLANs. The overestimation is because if_nlmsg_size() does not
pass ext_filter_mask to  rtnl_link_get_af_size() or rtnl_link_get_size().
(ext_filter_mask is passed to rtnl_vfinfo_size() and rtnl_port_size())
 
>How else could the skb end up being
>larger than what alloc_size accounts for at this point unless we end
>up stuffing 2x smallish messages into the padded projection of the
>calculated maximum message size of that type.
[@Ronen] The skb size (i.e. the tailroom of a newly allocated skb) is
greater than the argument passed to netlink_skb_alloc(). I didn't fully
looked at the allocation mechanism (there could be multiple ways and
netlink skbs could be memory mapped)). My understanding is that this is
expected as indicated by the comment in the code.

Netlink dump by design attempts to pack as many smallish messages into the
same skb to minimize the number of parts of a multi-part dump response.
The min_alloc_size is intended to guarantee drivers/modules sufficient
space for the largest dump message of a single netdev. 

>Is that what you are
>seeing?

[@Ronen] My initial observation was that with many VLANs configured, the 
min_alloc_size is greater than the 16KiB buffer iproute2 uses for both
"ip link show" and "bridge [-c[ompressvlans]] vlan show" commands. This buf
is defined locally within iproute2's lib/libnetlink.c.
Each VLAN_INFO attribute takes 8 bytes. 4094 VLANs requires 32,752 bytes.
Compressed VLANs would need a lot less (at the extreme only 8 bytes for a
single range covering the entire 1-4094 or any other range).

I bumped iproute2 buffer size from 16KiB to 3*16KiB when I first noticed
"Message truncated" error from "ip" and "bridge" commands. I was surprised
when such a large buffer remained insufficient for a system with more
interfaces.

The root cause is that the skb is allocated with more space than requested
and the dump is allowed to use this extra space available. In my case I
observed skb allocated with total space of 65,216 bytes when 34,420
were requested.
 
>
>Regardless of that, alloc_size is likely larger than nlk->max_recvmsg_len
>anyway at this point so unless the reader suddenly provides a different
>message size or does peeking it will likely still be truncated.
>
[@Ronen] My reader as I described above is providing a larger message
which I'm trying to properly size. I'm aware that libnl shields
applications from the need to know and provide properly sized buffer by
peeking or/and re-allocating a buffer.
My issue is with iproute2 "ip link show" and "bridge vlan show" commands.
 
>I'm just trying to understand which exact case you are solving here.
[@Ronen] My patch applies the same logic that is used when allocation is
done by nlk->max_recvmsg_len to allocation that is done by min_alloc_size.
The code could be clearer like that:

/* NLMSG_GOODSIZE is small to avoid high order allocations being
 * required, but it makes sense to _attempt_ a 16K bytes allocation
 * to reduce number of system calls on dump operations, if user
 * ever provided a big enough buffer.
 */
cb = &nlk->cb;
alloc_min_size = max_t(int, cb->min_dump_alloc, NLMSG_GOODSIZE);

if (alloc_min_size < nlk->max_recvmsg_len) {
alloc_size = nlk->max_recvmsg_len;
skb = netlink_alloc_skb(sk, alloc_size, nlk->portid,
GFP_KERNEL |
__GFP_NOWARN |
__GFP_NORETRY);
}
if (!skb) {
alloc_size = alloc_min_size;
skb = netlink_alloc_skb(sk, alloc_size, nlk->portid,
GFP_KERNEL);
}
if (!skb)
goto errout_sk

Re: [PATCH net-next V15 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes

2015-10-13 Thread Thomas F Herbert

Pravin,

Thanks for the review.

On 10/13/15 7:47 AM, Pravin Shelar wrote:

On Sat, Oct 10, 2015 at 4:40 PM, Thomas F Herbert
 wrote:

Add support for 802.1ad including the ability to push and pop double
tagged vlans. Add support for 802.1ad to netlink parsing and flow
conversion. Uses double nested encap attributes to represent double
tagged vlan. Inner TPID encoded along with ctci in nested attributes.

Signed-off-by: Thomas F Herbert 
---
  net/openvswitch/actions.c  |   6 +-
  net/openvswitch/flow.c |  92 +++
  net/openvswitch/flow.h |  11 ++-
  net/openvswitch/flow_netlink.c | 166 +
  net/openvswitch/vport-netdev.c |   4 +-
  5 files changed, 245 insertions(+), 34 deletions(-)


...


diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8db44a..0f9479c 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -305,21 +305,83 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
  static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
  {
 struct qtag_prefix {
-   __be16 eth_type; /* ETH_P_8021Q */
+   __be16 eth_type; /* ETH_P_8021Q  or ETH_P_8021AD */
 __be16 tci;
 };
-   struct qtag_prefix *qp;
+   struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;

-   if (unlikely(skb->len < sizeof(struct qtag_prefix) + sizeof(__be16)))
+   if (likely(skb_vlan_tag_present(skb))) {
+   key->eth.vlan.tci = htons(skb->vlan_tci);
+   key->eth.vlan.tpid = skb->vlan_proto;
+
+   /* Case where upstream
+* processing has already stripped the outer vlan tag.
+*/
+   if (unlikely(skb->vlan_proto == htons(ETH_P_8021AD))) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16))) {
+   key->eth.vlan.tci = 0;
+   return 0;
+   }
+
+   if (unlikely(!pskb_may_pull(skb,
+   sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+
+   qp = (struct qtag_prefix *)skb->data;
+   key->eth.cvlan.tci =
+   qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }
 return 0;

-   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
-sizeof(__be16
-   return -ENOMEM;
+   } else if (qp->eth_type == htons(ETH_P_8021AD)) {
+
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+
+   qp = (struct qtag_prefix *)skb->data;
+   key->eth.vlan.tci = qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.vlan.tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));

-   qp = (struct qtag_prefix *) skb->data;
-   key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT);
-   __skb_pull(skb, sizeof(struct qtag_prefix));
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+

There is no check for inner protocol in the packet.
Yes, and the code should be generic to use eth_type_vlan() for both 
inner and outer TPIDs.

I think your pseudo code below fixes that.



+   key->eth.cvlan.tci = qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.cvlan.tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+
+   return 0;
+
+   } else if (qp->eth_type == htons(ETH_P_8021Q)) {
+   if (unlikely(skb->len < sizeof(struct qtag_prefix) +
+   sizeof(__be16)))
+   return 0;
+
+   if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
+   sizeof(__be16
+   return -ENOMEM;
+   key->eth.vlan.tci = qp->tci | htons(VLAN_TAG_PRESENT);
+   key->eth.vlan.tpid = qp->eth_type;
+
+   __skb_pull(skb, sizeof(struct qtag_prefix));
+   }

 return 0;
  }

I see lot of duplicate code 

Re: [PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code

2015-10-13 Thread Florian Fainelli
On 13/10/15 09:46, Vivien Didelot wrote:
> There is no need to write the MAC address before every Get Next
> operation, since ATU MAC registers are not cleared between calls.
> 
> Move the _mv88e6xxx_atu_mac_write call outside of _mv88e6xxx_atu_getnext
> so future code could call ATU Get Next multiple times and save a few
> register access.

Missing SoB tag here.
-- 
Florian
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next] route: fib_validate_source remove the <= RT_SCOPE_HOST test

2015-10-13 Thread kbuild test robot
Hi Xin,

[auto build test WARNING on net-next/master -- if it's inappropriate base, 
please suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/Xin-Long/route-fib_validate_source-remove-the-RT_SCOPE_HOST-test/20151014-004206
config: cris-etrax-100lx_v2_defconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=cris 

All warnings (new ones prefixed by >>):

   net/ipv4/fib_frontend.c: In function '__fib_validate_source':
>> net/ipv4/fib_frontend.c:328:6: warning: unused variable 'ret' 
>> [-Wunused-variable]

vim +/ret +328 net/ipv4/fib_frontend.c

a207a4b2 David S. Miller 2012-06-28  312  
a207a4b2 David S. Miller 2012-06-28  313return inet_select_addr(dev, 
ip_hdr(skb)->saddr, scope);
35ebf65e David S. Miller 2012-06-28  314  }
35ebf65e David S. Miller 2012-06-28  315  
^1da177e Linus Torvalds  2005-04-16  316  /* Given (packet source, input 
interface) and optional (dst, oif, tos):
6a31d2a9 Eric Dumazet2010-10-04  317   * - (main) check, that source is 
valid i.e. not broadcast or our local
6a31d2a9 Eric Dumazet2010-10-04  318   *   address.
6a31d2a9 Eric Dumazet2010-10-04  319   * - figure out what "logical" 
interface this packet arrived
6a31d2a9 Eric Dumazet2010-10-04  320   *   and calculate "specific 
destination" address.
6a31d2a9 Eric Dumazet2010-10-04  321   * - check, that packet arrived from 
expected physical interface.
ebc0ffae Eric Dumazet2010-10-05  322   * called with rcu_read_lock()
^1da177e Linus Torvalds  2005-04-16  323   */
7a9bc9b8 David S. Miller 2012-06-29  324  static int 
__fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
7a9bc9b8 David S. Miller 2012-06-29  325 u8 
tos, int oif, struct net_device *dev,
7a9bc9b8 David S. Miller 2012-06-29  326 int 
rpf, struct in_device *idev, u32 *itag)
^1da177e Linus Torvalds  2005-04-16  327  {
1dced6a8 Sébastien Barré 2014-08-17 @328int ret, no_addr;
^1da177e Linus Torvalds  2005-04-16  329struct fib_result res;
9e56e380 David S. Miller 2012-06-28  330struct flowi4 fl4;
5b707aaa Denis V. Lunev  2008-01-21  331struct net *net;
9e56e380 David S. Miller 2012-06-28  332bool dev_match;
^1da177e Linus Torvalds  2005-04-16  333  
9ade2286 David S. Miller 2011-03-12  334fl4.flowi4_oif = 0;
385add90 David Ahern 2015-09-29  335fl4.flowi4_iif = 
l3mdev_master_ifindex_rcu(dev);
cd2fbe1b David Ahern 2015-08-13  336if (!fl4.flowi4_iif)

:: The code at line 328 was first introduced by commit
:: 1dced6a854827eb5683f3c57ddbb4595daf145e4 ipv4: Restore accept_local 
behaviour in fib_validate_source()

:: TO: Sébastien Barré 
:: CC: David S. Miller 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH net-next 2/4] net/mlx5_core: Add pci error handlers to mlx5_core driver

2015-10-13 Thread kbuild test robot
Hi Majd,

[auto build test WARNING on net-next/master -- if it's inappropriate base, 
please suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/Or-Gerlitz/net-mlx5_core-Fix-internal-error-detection-conditions/20151013-234855
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> drivers/net/ethernet/mellanox/mlx5/core/cmd.c:1383:36: sparse: incorrect 
>> type in assignment (different base types)
   drivers/net/ethernet/mellanox/mlx5/core/cmd.c:1383:36:expected 
restricted __be32 [usertype] 
   drivers/net/ethernet/mellanox/mlx5/core/cmd.c:1383:36:got unsigned int 
[unsigned] [addressable] [usertype] drv_synd

vim +1383 drivers/net/ethernet/mellanox/mlx5/core/cmd.c

  1367  }
  1368  
  1369  static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, 
void *out,
  1370  int out_size, mlx5_cmd_cbk_t callback, void 
*context)
  1371  {
  1372  struct mlx5_cmd_msg *inb;
  1373  struct mlx5_cmd_msg *outb;
  1374  int pages_queue;
  1375  gfp_t gfp;
  1376  int err;
  1377  u8 status = 0;
  1378  u32 drv_synd;
  1379  
  1380  if (pci_channel_offline(dev->pdev) ||
  1381  dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
  1382  err = mlx5_internal_err_ret_value(dev, 
opcode_from_in(in), &drv_synd, &status);
> 1383  *get_synd_ptr(out) = drv_synd;
  1384  *get_status_ptr(out) = status;
  1385  return err;
  1386  }
  1387  
  1388  pages_queue = is_manage_pages(in);
  1389  gfp = callback ? GFP_ATOMIC : GFP_KERNEL;
  1390  
  1391  inb = alloc_msg(dev, in_size, gfp);

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net 1/1] tipc: eliminate risk of stalled link synchronization

2015-10-13 Thread Jon Maloy
In commit 6e498158a827 ("tipc: move link synch and failover to link aggregation 
level")
we introduced a new mechanism for performing link failover and
synchronization. We have now detected a bug in this mechanism.

During link synchronization we use the arrival of any packet on
the tunnel link to trig a check for whether it has reached the
synchronization point or not. This has turned out to be too
permissive, since it may cause an arriving non-last SYNCH packet to
end the synch state, just to see the next SYNCH packet initiate a
new synch state with a new, higher synch point. This is not fatal,
but should be avoided, because it may significantly extend the
synchronization period, while at the same time we are not allowed
to send NACKs if packets are lost. In the worst case, a low-traffic
user may see its traffic stall until a LINK_PROTOCOL state message
trigs the link to leave synchronization state.

At the same time, LINK_PROTOCOL packets which happen to have a (non-
valid) sequence number lower than the tunnel link's rcv_nxt value will
be consistently dropped, and will never be able to resolve the situation
described above.

We fix this by exempting LINK_PROTOCOL packets from the sequence number
check, as they should be. We also reduce (but don't completely
eliminate) the risk of entering multiple synchronization states by only
allowing the (logically) first SYNCH packet to initiate a synchronization
state. This works independently of actual packet arrival order.

Fixes: commit 6e498158a827 ("tipc: move link synch and failover to link 
aggregation level")

Signed-off-by: Jon Maloy 
Acked-by: Ying Xue 
---
 net/tipc/node.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/tipc/node.c b/net/tipc/node.c
index 703875f..2c32a83 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -1116,7 +1116,7 @@ static bool tipc_node_check_state(struct tipc_node *n, 
struct sk_buff *skb,
}
 
/* Ignore duplicate packets */
-   if (less(oseqno, rcv_nxt))
+   if ((usr != LINK_PROTOCOL) && less(oseqno, rcv_nxt))
return true;
 
/* Initiate or update failover mode if applicable */
@@ -1146,8 +1146,8 @@ static bool tipc_node_check_state(struct tipc_node *n, 
struct sk_buff *skb,
if (!pl || !tipc_link_is_up(pl))
return true;
 
-   /* Initiate or update synch mode if applicable */
-   if ((usr == TUNNEL_PROTOCOL) && (mtyp == SYNCH_MSG)) {
+   /* Initiate synch mode if applicable */
+   if ((usr == TUNNEL_PROTOCOL) && (mtyp == SYNCH_MSG) && (oseqno == 1)) {
syncpt = iseqno + exp_pkts - 1;
if (!tipc_link_is_up(l)) {
tipc_link_fsm_evt(l, LINK_ESTABLISH_EVT);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 0/6] net: dsa: implement port_fdb_dump in drivers

2015-10-13 Thread Vivien Didelot
Not all switch chips provide a Get Next kind of operation to dump FDB entries.
It is preferred to let the driver handle the dump operation the way it works
best for the chip. Thus, drop port_fdb_getnext and implement the port_fdb_dump
operation in DSA, which pushes the switchdev FDB dump callback down to the
drivers. mv88e6xxx is the only driver affected and is updated accordingly.

v1 -> v2: fix a few "return err" instead of "goto unlock" in mv88e6xxx.c

Vivien Didelot (6):
  net: dsa: add port_fdb_dump function
  net: dsa: mv88e6xxx: write VID outside of VTU Get Next code
  net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code
  net: dsa: mv88e6xxx: implement port_fdb_dump
  net: dsa: mv88e6xxx: remove port_fdb_getnext
  net: dsa: remove port_fdb_getnext

 drivers/net/dsa/mv88e6171.c |   2 +-
 drivers/net/dsa/mv88e6352.c |   2 +-
 drivers/net/dsa/mv88e6xxx.c | 138 
 drivers/net/dsa/mv88e6xxx.h |   5 +-
 include/net/dsa.h   |   8 ++-
 net/dsa/slave.c |  26 +
 6 files changed, 89 insertions(+), 92 deletions(-)

-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 1/6] net: dsa: add port_fdb_dump function

2015-10-13 Thread Vivien Didelot
Not all switch chips support a Get Next operation to iterate on its FDB.
So add a more simple port_fdb_dump function for them.

Signed-off-by: Vivien Didelot 
---
 include/net/dsa.h | 5 +
 net/dsa/slave.c   | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index e005886..c5c48c5 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -198,7 +198,9 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
 }
 
 struct switchdev_trans;
+struct switchdev_obj;
 struct switchdev_obj_port_fdb;
+typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj);
 
 struct dsa_switch_driver {
struct list_headlist;
@@ -330,6 +332,9 @@ struct dsa_switch_driver {
int (*port_fdb_getnext)(struct dsa_switch *ds, int port,
unsigned char *addr, u16 *vid,
bool *is_static);
+   int (*port_fdb_dump)(struct dsa_switch *ds, int port,
+struct switchdev_obj_port_fdb *fdb,
+switchdev_obj_dump_cb_t *cb);
 };
 
 void register_switch_driver(struct dsa_switch_driver *type);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 43d7342..a4e3416 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -382,6 +382,9 @@ static int dsa_slave_port_fdb_dump(struct net_device *dev,
u16 vid = 0;
int ret;
 
+   if (ds->drv->port_fdb_dump)
+   return ds->drv->port_fdb_dump(ds, p->port, fdb, cb);
+
if (!ds->drv->port_fdb_getnext)
return -EOPNOTSUPP;
 
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 3/6] net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code

2015-10-13 Thread Vivien Didelot
There is no need to write the MAC address before every Get Next
operation, since ATU MAC registers are not cleared between calls.

Move the _mv88e6xxx_atu_mac_write call outside of _mv88e6xxx_atu_getnext
so future code could call ATU Get Next multiple times and save a few
register access.
---
 drivers/net/dsa/mv88e6xxx.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 8c87b03..7b15b98 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1751,7 +1751,6 @@ int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int 
port,
 }
 
 static int _mv88e6xxx_atu_getnext(struct dsa_switch *ds, u16 fid,
- const unsigned char *addr,
  struct mv88e6xxx_atu_entry *entry)
 {
struct mv88e6xxx_atu_entry next = { 0 };
@@ -1763,10 +1762,6 @@ static int _mv88e6xxx_atu_getnext(struct dsa_switch *ds, 
u16 fid,
if (ret < 0)
return ret;
 
-   ret = _mv88e6xxx_atu_mac_write(ds, addr);
-   if (ret < 0)
-   return ret;
-
ret = _mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_ATU_FID, fid);
if (ret < 0)
return ret;
@@ -1827,7 +1822,11 @@ int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, 
int port,
fid = vtu.fid;
}
 
-   ret = _mv88e6xxx_atu_getnext(ds, fid, addr, &next);
+   ret = _mv88e6xxx_atu_mac_write(ds, addr);
+   if (ret < 0)
+   goto unlock;
+
+   ret = _mv88e6xxx_atu_getnext(ds, fid, &next);
if (ret < 0)
goto unlock;
 
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 4/6] net: dsa: mv88e6xxx: implement port_fdb_dump

2015-10-13 Thread Vivien Didelot
Implement the port_fdb_dump DSA operation.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/mv88e6171.c |  1 +
 drivers/net/dsa/mv88e6352.c |  1 +
 drivers/net/dsa/mv88e6xxx.c | 65 +
 drivers/net/dsa/mv88e6xxx.h |  3 +++
 4 files changed, 70 insertions(+)

diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index dfca352..489deb8 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -123,6 +123,7 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
.port_fdb_add   = mv88e6xxx_port_fdb_add,
.port_fdb_del   = mv88e6xxx_port_fdb_del,
.port_fdb_getnext   = mv88e6xxx_port_fdb_getnext,
+   .port_fdb_dump  = mv88e6xxx_port_fdb_dump,
 };
 
 MODULE_ALIAS("platform:mv88e6171");
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index 796fdcb..6b8fd24 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -350,6 +350,7 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
.port_fdb_add   = mv88e6xxx_port_fdb_add,
.port_fdb_del   = mv88e6xxx_port_fdb_del,
.port_fdb_getnext   = mv88e6xxx_port_fdb_getnext,
+   .port_fdb_dump  = mv88e6xxx_port_fdb_dump,
 };
 
 MODULE_ALIAS("platform:mv88e6172");
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 7b15b98..a1740b4 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1799,6 +1799,71 @@ static int _mv88e6xxx_atu_getnext(struct dsa_switch *ds, 
u16 fid,
return 0;
 }
 
+int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
+   struct switchdev_obj_port_fdb *fdb,
+   switchdev_obj_dump_cb_t *cb)
+{
+   struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
+   struct mv88e6xxx_vtu_stu_entry vlan = {
+   .vid = GLOBAL_VTU_VID_MASK, /* all ones */
+   };
+   int err;
+
+   mutex_lock(&ps->smi_mutex);
+
+   err = _mv88e6xxx_vtu_vid_write(ds, vlan.vid);
+   if (err)
+   goto unlock;
+
+   do {
+   struct mv88e6xxx_atu_entry addr = {
+   .mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+   };
+
+   err = _mv88e6xxx_vtu_getnext(ds, &vlan);
+   if (err)
+   goto unlock;
+
+   if (!vlan.valid)
+   break;
+
+   err = _mv88e6xxx_atu_mac_write(ds, addr.mac);
+   if (err)
+   goto unlock;
+
+   do {
+   err = _mv88e6xxx_atu_getnext(ds, vlan.fid, &addr);
+   if (err)
+   goto unlock;
+
+   if (addr.state == GLOBAL_ATU_DATA_STATE_UNUSED)
+   break;
+
+   if (!addr.trunk && addr.portv_trunkid & BIT(port)) {
+   bool is_static = addr.state ==
+   (is_multicast_ether_addr(addr.mac) ?
+GLOBAL_ATU_DATA_STATE_MC_STATIC :
+GLOBAL_ATU_DATA_STATE_UC_STATIC);
+
+   fdb->vid = vlan.vid;
+   fdb->addr = addr.mac;
+   fdb->ndm_state = is_static ? NUD_NOARP :
+   NUD_REACHABLE;
+
+   err = cb(&fdb->obj);
+   if (err)
+   goto unlock;
+   }
+   } while (!is_broadcast_ether_addr(addr.mac));
+
+   } while (vlan.vid < GLOBAL_VTU_VID_MASK);
+
+unlock:
+   mutex_unlock(&ps->smi_mutex);
+
+   return err;
+}
+
 /* get next entry for port */
 int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
   unsigned char *addr, u16 *vid, bool *is_static)
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index ba94f17..08e0fbb 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -481,6 +481,9 @@ int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
   const struct switchdev_obj_port_fdb *fdb);
 int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
   unsigned char *addr, u16 *vid, bool *is_static);
+int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
+   struct switchdev_obj_port_fdb *fdb,
+   switchdev_obj_dump_cb_t *cb);
 int mv88e6xxx_phy_page_read(struct dsa_switch *ds, int port, int page, int 
reg);
 int mv88e6xxx_phy_page_write(struct dsa_switch *ds, int port, int page,
 int reg, int val);
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body 

[PATCH net-next v2 5/6] net: dsa: mv88e6xxx: remove port_fdb_getnext

2015-10-13 Thread Vivien Didelot
Now that port_fdb_dump is implemented and even simpler, get rid of
port_fdb_getnext.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/mv88e6171.c |  1 -
 drivers/net/dsa/mv88e6352.c |  1 -
 drivers/net/dsa/mv88e6xxx.c | 73 -
 drivers/net/dsa/mv88e6xxx.h |  2 --
 4 files changed, 77 deletions(-)

diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index 489deb8..2c8eb6f 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -122,7 +122,6 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
.port_fdb_prepare   = mv88e6xxx_port_fdb_prepare,
.port_fdb_add   = mv88e6xxx_port_fdb_add,
.port_fdb_del   = mv88e6xxx_port_fdb_del,
-   .port_fdb_getnext   = mv88e6xxx_port_fdb_getnext,
.port_fdb_dump  = mv88e6xxx_port_fdb_dump,
 };
 
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index 6b8fd24..cbf4dd8 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -349,7 +349,6 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
.port_fdb_prepare   = mv88e6xxx_port_fdb_prepare,
.port_fdb_add   = mv88e6xxx_port_fdb_add,
.port_fdb_del   = mv88e6xxx_port_fdb_del,
-   .port_fdb_getnext   = mv88e6xxx_port_fdb_getnext,
.port_fdb_dump  = mv88e6xxx_port_fdb_dump,
 };
 
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index a1740b4..980460a 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1559,33 +1559,6 @@ unlock:
return err;
 }
 
-static int _mv88e6xxx_port_vtu_getnext(struct dsa_switch *ds, int port, u16 
vid,
-  struct mv88e6xxx_vtu_stu_entry *entry)
-{
-   int err;
-
-   do {
-   if (vid == 4095)
-   return -ENOENT;
-
-   err = _mv88e6xxx_vtu_vid_write(ds, vid);
-   if (err)
-   return err;
-
-   err = _mv88e6xxx_vtu_getnext(ds, entry);
-   if (err)
-   return err;
-
-   if (!entry->valid)
-   return -ENOENT;
-
-   vid = entry->vid;
-   } while (entry->data[port] != GLOBAL_VTU_DATA_MEMBER_TAG_TAGGED &&
-entry->data[port] != GLOBAL_VTU_DATA_MEMBER_TAG_UNTAGGED);
-
-   return 0;
-}
-
 int mv88e6xxx_vlan_getnext(struct dsa_switch *ds, u16 *vid,
   unsigned long *ports, unsigned long *untagged)
 {
@@ -1864,52 +1837,6 @@ unlock:
return err;
 }
 
-/* get next entry for port */
-int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
-  unsigned char *addr, u16 *vid, bool *is_static)
-{
-   struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
-   struct mv88e6xxx_atu_entry next;
-   u16 fid = *vid; /* We use one FID per VLAN */
-   int ret;
-
-   mutex_lock(&ps->smi_mutex);
-
-   do {
-   if (is_broadcast_ether_addr(addr)) {
-   struct mv88e6xxx_vtu_stu_entry vtu;
-
-   ret = _mv88e6xxx_port_vtu_getnext(ds, port, *vid, &vtu);
-   if (ret < 0)
-   goto unlock;
-
-   *vid = vtu.vid;
-   fid = vtu.fid;
-   }
-
-   ret = _mv88e6xxx_atu_mac_write(ds, addr);
-   if (ret < 0)
-   goto unlock;
-
-   ret = _mv88e6xxx_atu_getnext(ds, fid, &next);
-   if (ret < 0)
-   goto unlock;
-
-   ether_addr_copy(addr, next.mac);
-
-   if (next.state == GLOBAL_ATU_DATA_STATE_UNUSED)
-   continue;
-   } while (next.trunk || (next.portv_trunkid & BIT(port)) == 0);
-
-   *is_static = next.state == (is_multicast_ether_addr(addr) ?
-   GLOBAL_ATU_DATA_STATE_MC_STATIC :
-   GLOBAL_ATU_DATA_STATE_UC_STATIC);
-unlock:
-   mutex_unlock(&ps->smi_mutex);
-
-   return ret;
-}
-
 static void mv88e6xxx_bridge_work(struct work_struct *work)
 {
struct mv88e6xxx_priv_state *ps;
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 08e0fbb..c921427 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -479,8 +479,6 @@ int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
   struct switchdev_trans *trans);
 int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
   const struct switchdev_obj_port_fdb *fdb);
-int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
-  unsigned char *addr, u16 *vid, bool *is_static);
 int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
struct switchdev_obj_por

[PATCH net-next v2 2/6] net: dsa: mv88e6xxx: write VID outside of VTU Get Next code

2015-10-13 Thread Vivien Didelot
There is no need to write the VLAN ID before every Get Next operation,
since the VTU VID register is not cleared between calls.

Move the VID write call in a _mv88e6xxx_vtu_vid_write function outside
of _mv88e6xxx_vtu_getnext so future code could call VTU Get Next
multiple times and save a few register accesses.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/mv88e6xxx.c | 45 ++---
 1 file changed, 34 insertions(+), 11 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 63736f9..8c87b03 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1259,7 +1259,13 @@ static int _mv88e6xxx_vtu_stu_data_write(struct 
dsa_switch *ds,
return 0;
 }
 
-static int _mv88e6xxx_vtu_getnext(struct dsa_switch *ds, u16 vid,
+static int _mv88e6xxx_vtu_vid_write(struct dsa_switch *ds, u16 vid)
+{
+   return _mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_VTU_VID,
+   vid & GLOBAL_VTU_VID_MASK);
+}
+
+static int _mv88e6xxx_vtu_getnext(struct dsa_switch *ds,
  struct mv88e6xxx_vtu_stu_entry *entry)
 {
struct mv88e6xxx_vtu_stu_entry next = { 0 };
@@ -1269,11 +1275,6 @@ static int _mv88e6xxx_vtu_getnext(struct dsa_switch *ds, 
u16 vid,
if (ret < 0)
return ret;
 
-   ret = _mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_VTU_VID,
-  vid & GLOBAL_VTU_VID_MASK);
-   if (ret < 0)
-   return ret;
-
ret = _mv88e6xxx_vtu_cmd(ds, GLOBAL_VTU_OP_VTU_GET_NEXT);
if (ret < 0)
return ret;
@@ -1485,7 +1486,12 @@ int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int 
port, u16 vid,
int err;
 
mutex_lock(&ps->smi_mutex);
-   err = _mv88e6xxx_vtu_getnext(ds, vid - 1, &vlan);
+
+   err = _mv88e6xxx_vtu_vid_write(ds, vid - 1);
+   if (err)
+   goto unlock;
+
+   err = _mv88e6xxx_vtu_getnext(ds, &vlan);
if (err)
goto unlock;
 
@@ -1514,7 +1520,11 @@ int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int 
port, u16 vid)
 
mutex_lock(&ps->smi_mutex);
 
-   err = _mv88e6xxx_vtu_getnext(ds, vid - 1, &vlan);
+   err = _mv88e6xxx_vtu_vid_write(ds, vid - 1);
+   if (err)
+   goto unlock;
+
+   err = _mv88e6xxx_vtu_getnext(ds, &vlan);
if (err)
goto unlock;
 
@@ -1558,7 +1568,11 @@ static int _mv88e6xxx_port_vtu_getnext(struct dsa_switch 
*ds, int port, u16 vid,
if (vid == 4095)
return -ENOENT;
 
-   err = _mv88e6xxx_vtu_getnext(ds, vid, entry);
+   err = _mv88e6xxx_vtu_vid_write(ds, vid);
+   if (err)
+   return err;
+
+   err = _mv88e6xxx_vtu_getnext(ds, entry);
if (err)
return err;
 
@@ -1584,7 +1598,12 @@ int mv88e6xxx_vlan_getnext(struct dsa_switch *ds, u16 
*vid,
return -ENOENT;
 
mutex_lock(&ps->smi_mutex);
-   err = _mv88e6xxx_vtu_getnext(ds, *vid, &next);
+   err = _mv88e6xxx_vtu_vid_write(ds, *vid);
+   if (err)
+   goto unlock;
+
+   err = _mv88e6xxx_vtu_getnext(ds, &next);
+unlock:
mutex_unlock(&ps->smi_mutex);
 
if (err)
@@ -2274,10 +2293,14 @@ static int mv88e6xxx_vtu_show(struct seq_file *s, void 
*p)
 
mutex_lock(&ps->smi_mutex);
 
+   ret = _mv88e6xxx_vtu_vid_write(ds, vid);
+   if (ret < 0)
+   goto unlock;
+
do {
struct mv88e6xxx_vtu_stu_entry next = { 0 };
 
-   ret = _mv88e6xxx_vtu_getnext(ds, vid, &next);
+   ret = _mv88e6xxx_vtu_getnext(ds, &next);
if (ret < 0)
goto unlock;
 
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 6/6] net: dsa: remove port_fdb_getnext

2015-10-13 Thread Vivien Didelot
No driver implements port_fdb_getnext anymore, and port_fdb_dump is
preferred anyway, so remove this function from DSA.

Signed-off-by: Vivien Didelot 
---
 include/net/dsa.h |  3 ---
 net/dsa/slave.c   | 25 +
 2 files changed, 1 insertion(+), 27 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index c5c48c5..d8ab2f9 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -329,9 +329,6 @@ struct dsa_switch_driver {
struct switchdev_trans *trans);
int (*port_fdb_del)(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_fdb *fdb);
-   int (*port_fdb_getnext)(struct dsa_switch *ds, int port,
-   unsigned char *addr, u16 *vid,
-   bool *is_static);
int (*port_fdb_dump)(struct dsa_switch *ds, int port,
 struct switchdev_obj_port_fdb *fdb,
 switchdev_obj_dump_cb_t *cb);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index a4e3416..5908893 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -378,34 +378,11 @@ static int dsa_slave_port_fdb_dump(struct net_device *dev,
 {
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->parent;
-   unsigned char addr[ETH_ALEN] = { 0 };
-   u16 vid = 0;
-   int ret;
 
if (ds->drv->port_fdb_dump)
return ds->drv->port_fdb_dump(ds, p->port, fdb, cb);
 
-   if (!ds->drv->port_fdb_getnext)
-   return -EOPNOTSUPP;
-
-   for (;;) {
-   bool is_static;
-
-   ret = ds->drv->port_fdb_getnext(ds, p->port, addr, &vid,
-   &is_static);
-   if (ret < 0)
-   break;
-
-   fdb->addr = addr;
-   fdb->vid = vid;
-   fdb->ndm_state = is_static ? NUD_NOARP : NUD_REACHABLE;
-
-   ret = cb(&fdb->obj);
-   if (ret < 0)
-   break;
-   }
-
-   return ret == -ENOENT ? 0 : ret;
+   return -EOPNOTSUPP;
 }
 
 static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next] route: fib_validate_source remove the <= RT_SCOPE_HOST test

2015-10-13 Thread Xin Long
commit fe3edf45792a ("ipv4: Remove all RTCF_DIRECTSRC handliing.").

Before this commit, we had a tristate:
< 0: error
0: ok
1: ok and set RTCF_DIRECTSRC

But now we only care about 0 or < 0.

Signed-off-by: Xin Long 
---
 net/ipv4/fib_frontend.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index d7c2bb0..f5c74d8 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -376,22 +376,14 @@ static int __fib_validate_source(struct sk_buff *skb, 
__be32 src, __be32 dst,
if (FIB_RES_DEV(res) == dev)
dev_match = true;
 #endif
-   if (dev_match) {
-   ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST;
-   return ret;
-   }
+   if (dev_match)
+   return 0;
if (no_addr)
goto last_resort;
if (rpf == 1)
goto e_rpf;
-   fl4.flowi4_oif = dev->ifindex;
 
-   ret = 0;
-   if (fib_lookup(net, &fl4, &res, FIB_LOOKUP_IGNORE_LINKSTATE) == 0) {
-   if (res.type == RTN_UNICAST)
-   ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST;
-   }
-   return ret;
+   return 0;
 
 last_resort:
if (rpf)
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next 0/6] net: dsa: implement port_fdb_dump in drivers

2015-10-13 Thread Vivien Didelot
On Oct. Tuesday 13 (42) 11:42 AM, Vivien Didelot wrote:
> Not all switch chips provide a Get Next kind of operation to dump FDB entries.
> It is preferred to let the driver handle the dump operation the way it works
> best for the chip. Thus, drop port_fdb_getnext and implement the port_fdb_dump
> operation in DSA, which pushes the switchdev FDB dump callback down to the
> drivers. mv88e6xxx is the only driver affected and is updated accordingly.
> 
> Vivien Didelot (6):
>   net: dsa: mv88e6xxx: write VID outside of VTU Get Next code
>   net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code
>   net: dsa: add port_fdb_dump function
>   net: dsa: mv88e6xxx: implement port_fdb_dump
>   net: dsa: mv88e6xxx: remove port_fdb_getnext
>   net: dsa: remove port_fdb_getnext
> 
>  drivers/net/dsa/mv88e6171.c |   2 +-
>  drivers/net/dsa/mv88e6352.c |   2 +-
>  drivers/net/dsa/mv88e6xxx.c | 140 
> 
>  drivers/net/dsa/mv88e6xxx.h |   5 +-
>  include/net/dsa.h   |   8 ++-
>  net/dsa/slave.c |  26 +---
>  6 files changed, 90 insertions(+), 93 deletions(-)

I mispaste a few "return err" instead of "goto unlock" which skips a few
mutex_unlock() in mv88e6xxx.c. I'm sending a respin right away, please
ignore this v1.

Sorry,
-v
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [Intel-wired-lan] [PATCH v8 3/3] ixgbe, ixgbevf: Add new mbox API xcast mode

2015-10-13 Thread Singh, Krishneil K

-Original Message-
From: Intel-wired-lan [mailto:intel-wired-lan-boun...@lists.osuosl.org] On 
Behalf Of Hiroshi Shimamoto
Sent: Thursday, August 27, 2015 11:59 PM
To: Or Gerlitz ; Alexander Duyck 
; Skidmore, Donald C ; 
Rose, Gregory V ; Kirsher, Jeffrey T 
; intel-wired-...@lists.osuosl.org; 
nhor...@redhat.com; jogre...@redhat.com; Linux Netdev List 
; Choi, Sy Jong ; Rony Efraim 
; Edward Cree ; David Miller 
; sassm...@redhat.com
Subject: [Intel-wired-lan] [PATCH v8 3/3] ixgbe, ixgbevf: Add new mbox API 
xcast mode

From: Hiroshi Shimamoto 

The limitation of the number of multicast address for VF is not enough for the 
large scale server with SR-IOV feature. IPv6 requires the multicast MAC address 
for each IP address to handle the Neighbor Solicitation message. We couldn't 
assign over 30 IPv6 addresses to a single VF.

This patch introduces the new mailbox API, IXGBE_VF_UPDATE_XCAST_MODE, to 
update multicast mode of VF. This adds 3 modes;
  - NONE only L2 exact match addresses or Flow Director enabled
  - MULTIBAM and ROMPE set
  - ALLMULTI BAM, ROMPE and MPE set

If a guest VF user wants over 30 MAC multicast addresses, set IFF_ALLMULTI to 
request PF to update xcast mode to enable VF multicast promiscuous mode.

On the other hand, enabling VF multicast promiscuous mode may affect security 
and performance in the network of the NIC. Only trusted VF can enable multicast 
promiscuous mode. The behavior of untrusted VF is the same as previous version.

Signed-off-by: Hiroshi Shimamoto 
---
 
Tested-by: Krishneil Singh 


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v8 2/3] ixgbe: Add new ndo to trust VF

2015-10-13 Thread Singh, Krishneil K

-Original Message-
From: Intel-wired-lan [mailto:intel-wired-lan-boun...@lists.osuosl.org] On 
Behalf Of Hiroshi Shimamoto
Sent: Thursday, August 27, 2015 11:59 PM
To: Or Gerlitz ; Alexander Duyck 
; Skidmore, Donald C ; 
Rose, Gregory V ; Kirsher, Jeffrey T 
; intel-wired-...@lists.osuosl.org; 
nhor...@redhat.com; jogre...@redhat.com; Linux Netdev List 
; Choi, Sy Jong ; Rony Efraim 
; Edward Cree ; David Miller 
; sassm...@redhat.com
Subject: [Intel-wired-lan] [PATCH v8 2/3] ixgbe: Add new ndo to trust VF

From: Hiroshi Shimamoto 

Implements the new netdev op to trust VF in ixgbe.

The administrator can turn on and off VF trusted by ip command which supports 
trust message.
 # ip link set dev eth0 vf 1 trust on
or
 # ip link set dev eth0 vf 1 trust off

Send a ping to reset VF on changing the status of trusting.
VF driver will reconfigure its features on reset.

Signed-off-by: Hiroshi Shimamoto 
---

Tested-by: Krishneil Singh 


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v8 1/3] if_link: Add control trust VF

2015-10-13 Thread Singh, Krishneil K

-Original Message-
From: Intel-wired-lan [mailto:intel-wired-lan-boun...@lists.osuosl.org] On 
Behalf Of Hiroshi Shimamoto
Sent: Thursday, August 27, 2015 11:58 PM
To: Or Gerlitz ; Alexander Duyck 
; Skidmore, Donald C ; 
Rose, Gregory V ; Kirsher, Jeffrey T 
; intel-wired-...@lists.osuosl.org; 
nhor...@redhat.com; jogre...@redhat.com; Linux Netdev List 
; Choi, Sy Jong ; Rony Efraim 
; Edward Cree ; David Miller 
; sassm...@redhat.com
Subject: [Intel-wired-lan] [PATCH v8 1/3] if_link: Add control trust VF

From: Hiroshi Shimamoto 

Add netlink directives and ndo entry to trust VF user.

This controls the special permission of VF user.
The administrator will dedicatedly trust VF user to use some features which 
impacts security and/or performance.

The administrator never turn it on unless VF user is fully trusted.

Signed-off-by: Hiroshi Shimamoto 
CC: Choi, Sy Jong 
---
Tested-by: Krishneil Singh 


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [bug report or not] ping6 will lost packets when ping6 lots of ipv6 address

2015-10-13 Thread Martin KaFai Lau
On Tue, Oct 13, 2015 at 08:46:49PM +0800, Li RongQing wrote:
> 1. in a machine, configure 3000 ipv6 address in one interface
>
> for i in {1..3000}; do ip -6 addr add 4001:5013::$i/0 dev eth0; done
>
>
> 2. in other machine, ping6 the upper configured ipv6 address, then
> lots of lost packets
>
> ip -6 addr add 4001:5013::0/64 dev eth0
> for i in {1..2000}; do ping6 -q -c1 4001:5013::$i; done;
>
> 3. increasing the gc thresh can handles these lost
>
> sysctl -w  net.ipv6.neigh.default.gc_thresh1=2000
> sysctl -w  net.ipv6.neigh.default.gc_thresh2=3000
> sysctl -w  net.ipv6.neigh.default.gc_thresh3=4000
> sysctl -w net.ipv6.route.gc_thresh=3000
> sysctl -w net.ipv6.route.max_size =3000
Which kernel is used in this test?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


pull-request: can-next 2015-09-17

2015-10-13 Thread Marc Kleine-Budde
Hello David,

this is a pull request of 4 patches for net-next/master.

Two patches are by Gerhard Bertelsmann, fixing some problems in the
sun4i driver. The patch by Arnd Bergmann stops using timeval for the
CAN broadcast manager. The last patch by Alexandre Belloni removes the
otherwise unused struct at91_can_data from the driver.

Marc

---

The following changes since commit bbb300eb976b613a8e4e666d3af39f5ab1031d22:

  Merge branch 'bridge-vlan' (2015-10-13 04:58:04 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git 
tags/linux-can-next-for-4.4-20151013

for you to fetch changes up to 42160a041db89807691b2a3fbf42e36a98b6019e:

  can: at91: remove at91_can_data (2015-10-13 17:42:35 +0200)


linux-can-next-for-4.4-20151013


Alexandre Belloni (1):
  can: at91: remove at91_can_data

Arnd Bergmann (1):
  can: avoid using timeval for uapi

Gerhard Bertelsmann (2):
  can: sun4i: fix arbitration lost error reporting
  can: sun4i: fix MODULE_DESCRIPTION

 drivers/net/can/at91_can.c  | 21 -
 drivers/net/can/sun4i_can.c |  4 ++--
 include/linux/platform_data/atmel.h |  5 -
 include/uapi/linux/can/bcm.h|  7 ++-
 net/can/bcm.c   | 15 ++-
 5 files changed, 18 insertions(+), 34 deletions(-)

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


[PATCH net-next 1/1] tipc: eliminate risk of stalled link synchronization

2015-10-13 Thread Jon Maloy
In commit 6e498158a827 ("tipc: move link synch and failover to link aggregation 
level")
we introduced a new mechanism for performing link failover and
synchronization. We have now detected a bug in this mechanism.

During link synchronization we use the arrival of any packet on
the tunnel link to trig a check for whether it has reached the
synchronization point or not. This has turned out to be too
permissive, since it may cause an arriving non-last SYNCH packet to
end the synch state, just to see the next SYNCH packet initiate a
new synch state with a new, higher synch point. This is not fatal,
but should be avoided, because it may significantly extend the
synchronization period, while at the same time we are not allowed
to send NACKs if packets are lost. In the worst case, a low-traffic
user may see its traffic stall until a LINK_PROTOCOL state message
trigs the link to leave synchronization state.

At the same time, LINK_PROTOCOL packets which happen to have a (non-
valid) sequence number lower than the tunnel link's rcv_nxt value will
be consistently dropped, and will never be able to resolve the situation
described above.

We fix this by exempting LINK_PROTOCOL packets from the sequence number
check, as they should be. We also reduce (but don't completely
eliminate) the risk of entering multiple synchronization states by only
allowing the (logically) first SYNCH packet to initiate a synchronization
state. This works independently of actual packet arrival order.

Fixes: commit 6e498158a827 ("tipc: move link synch and failover to link 
aggregation level")

Signed-off-by: Jon Maloy 
Acked-by: Ying Xue 
---
 net/tipc/node.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/tipc/node.c b/net/tipc/node.c
index 703875f..2c32a83 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -1116,7 +1116,7 @@ static bool tipc_node_check_state(struct tipc_node *n, 
struct sk_buff *skb,
}
 
/* Ignore duplicate packets */
-   if (less(oseqno, rcv_nxt))
+   if ((usr != LINK_PROTOCOL) && less(oseqno, rcv_nxt))
return true;
 
/* Initiate or update failover mode if applicable */
@@ -1146,8 +1146,8 @@ static bool tipc_node_check_state(struct tipc_node *n, 
struct sk_buff *skb,
if (!pl || !tipc_link_is_up(pl))
return true;
 
-   /* Initiate or update synch mode if applicable */
-   if ((usr == TUNNEL_PROTOCOL) && (mtyp == SYNCH_MSG)) {
+   /* Initiate synch mode if applicable */
+   if ((usr == TUNNEL_PROTOCOL) && (mtyp == SYNCH_MSG) && (oseqno == 1)) {
syncpt = iseqno + exp_pkts - 1;
if (!tipc_link_is_up(l)) {
tipc_link_fsm_evt(l, LINK_ESTABLISH_EVT);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 0/6] net: dsa: implement port_fdb_dump in drivers

2015-10-13 Thread Vivien Didelot
Not all switch chips provide a Get Next kind of operation to dump FDB entries.
It is preferred to let the driver handle the dump operation the way it works
best for the chip. Thus, drop port_fdb_getnext and implement the port_fdb_dump
operation in DSA, which pushes the switchdev FDB dump callback down to the
drivers. mv88e6xxx is the only driver affected and is updated accordingly.

Vivien Didelot (6):
  net: dsa: mv88e6xxx: write VID outside of VTU Get Next code
  net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code
  net: dsa: add port_fdb_dump function
  net: dsa: mv88e6xxx: implement port_fdb_dump
  net: dsa: mv88e6xxx: remove port_fdb_getnext
  net: dsa: remove port_fdb_getnext

 drivers/net/dsa/mv88e6171.c |   2 +-
 drivers/net/dsa/mv88e6352.c |   2 +-
 drivers/net/dsa/mv88e6xxx.c | 140 
 drivers/net/dsa/mv88e6xxx.h |   5 +-
 include/net/dsa.h   |   8 ++-
 net/dsa/slave.c |  26 +---
 6 files changed, 90 insertions(+), 93 deletions(-)

-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 3/6] net: dsa: add port_fdb_dump function

2015-10-13 Thread Vivien Didelot
Not all switch chips support a Get Next operation to iterate on its FDB.
So add a more simple port_fdb_dump function for them.

Signed-off-by: Vivien Didelot 
---
 include/net/dsa.h | 5 +
 net/dsa/slave.c   | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index e005886..c5c48c5 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -198,7 +198,9 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
 }
 
 struct switchdev_trans;
+struct switchdev_obj;
 struct switchdev_obj_port_fdb;
+typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj);
 
 struct dsa_switch_driver {
struct list_headlist;
@@ -330,6 +332,9 @@ struct dsa_switch_driver {
int (*port_fdb_getnext)(struct dsa_switch *ds, int port,
unsigned char *addr, u16 *vid,
bool *is_static);
+   int (*port_fdb_dump)(struct dsa_switch *ds, int port,
+struct switchdev_obj_port_fdb *fdb,
+switchdev_obj_dump_cb_t *cb);
 };
 
 void register_switch_driver(struct dsa_switch_driver *type);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 43d7342..a4e3416 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -382,6 +382,9 @@ static int dsa_slave_port_fdb_dump(struct net_device *dev,
u16 vid = 0;
int ret;
 
+   if (ds->drv->port_fdb_dump)
+   return ds->drv->port_fdb_dump(ds, p->port, fdb, cb);
+
if (!ds->drv->port_fdb_getnext)
return -EOPNOTSUPP;
 
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 5/6] net: dsa: mv88e6xxx: remove port_fdb_getnext

2015-10-13 Thread Vivien Didelot
Now that port_fdb_dump is implemented and even simpler, get rid of
port_fdb_getnext.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/mv88e6171.c |  1 -
 drivers/net/dsa/mv88e6352.c |  1 -
 drivers/net/dsa/mv88e6xxx.c | 73 -
 drivers/net/dsa/mv88e6xxx.h |  2 --
 4 files changed, 77 deletions(-)

diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index 489deb8..2c8eb6f 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -122,7 +122,6 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
.port_fdb_prepare   = mv88e6xxx_port_fdb_prepare,
.port_fdb_add   = mv88e6xxx_port_fdb_add,
.port_fdb_del   = mv88e6xxx_port_fdb_del,
-   .port_fdb_getnext   = mv88e6xxx_port_fdb_getnext,
.port_fdb_dump  = mv88e6xxx_port_fdb_dump,
 };
 
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index 6b8fd24..cbf4dd8 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -349,7 +349,6 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
.port_fdb_prepare   = mv88e6xxx_port_fdb_prepare,
.port_fdb_add   = mv88e6xxx_port_fdb_add,
.port_fdb_del   = mv88e6xxx_port_fdb_del,
-   .port_fdb_getnext   = mv88e6xxx_port_fdb_getnext,
.port_fdb_dump  = mv88e6xxx_port_fdb_dump,
 };
 
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 41e630a..5657f5b 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1559,33 +1559,6 @@ unlock:
return err;
 }
 
-static int _mv88e6xxx_port_vtu_getnext(struct dsa_switch *ds, int port, u16 
vid,
-  struct mv88e6xxx_vtu_stu_entry *entry)
-{
-   int err;
-
-   do {
-   if (vid == 4095)
-   return -ENOENT;
-
-   err = _mv88e6xxx_vtu_vid_write(ds, vid);
-   if (err)
-   return err;
-
-   err = _mv88e6xxx_vtu_getnext(ds, entry);
-   if (err)
-   return err;
-
-   if (!entry->valid)
-   return -ENOENT;
-
-   vid = entry->vid;
-   } while (entry->data[port] != GLOBAL_VTU_DATA_MEMBER_TAG_TAGGED &&
-entry->data[port] != GLOBAL_VTU_DATA_MEMBER_TAG_UNTAGGED);
-
-   return 0;
-}
-
 int mv88e6xxx_vlan_getnext(struct dsa_switch *ds, u16 *vid,
   unsigned long *ports, unsigned long *untagged)
 {
@@ -1864,52 +1837,6 @@ unlock:
return err;
 }
 
-/* get next entry for port */
-int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
-  unsigned char *addr, u16 *vid, bool *is_static)
-{
-   struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
-   struct mv88e6xxx_atu_entry next;
-   u16 fid = *vid; /* We use one FID per VLAN */
-   int ret;
-
-   mutex_lock(&ps->smi_mutex);
-
-   do {
-   if (is_broadcast_ether_addr(addr)) {
-   struct mv88e6xxx_vtu_stu_entry vtu;
-
-   ret = _mv88e6xxx_port_vtu_getnext(ds, port, *vid, &vtu);
-   if (ret < 0)
-   goto unlock;
-
-   *vid = vtu.vid;
-   fid = vtu.fid;
-   }
-
-   ret = _mv88e6xxx_atu_mac_write(ds, addr);
-   if (ret < 0)
-   goto unlock;
-
-   ret = _mv88e6xxx_atu_getnext(ds, fid, &next);
-   if (ret < 0)
-   goto unlock;
-
-   ether_addr_copy(addr, next.mac);
-
-   if (next.state == GLOBAL_ATU_DATA_STATE_UNUSED)
-   continue;
-   } while (next.trunk || (next.portv_trunkid & BIT(port)) == 0);
-
-   *is_static = next.state == (is_multicast_ether_addr(addr) ?
-   GLOBAL_ATU_DATA_STATE_MC_STATIC :
-   GLOBAL_ATU_DATA_STATE_UC_STATIC);
-unlock:
-   mutex_unlock(&ps->smi_mutex);
-
-   return ret;
-}
-
 static void mv88e6xxx_bridge_work(struct work_struct *work)
 {
struct mv88e6xxx_priv_state *ps;
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 08e0fbb..c921427 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -479,8 +479,6 @@ int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
   struct switchdev_trans *trans);
 int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
   const struct switchdev_obj_port_fdb *fdb);
-int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
-  unsigned char *addr, u16 *vid, bool *is_static);
 int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
struct switchdev_obj_por

[PATCH net-next 2/6] net: dsa: mv88e6xxx: write MAC outside of ATU Get Next code

2015-10-13 Thread Vivien Didelot
There is no need to write the MAC address before every Get Next
operation, since ATU MAC registers are not cleared between calls.

Move the _mv88e6xxx_atu_mac_write call outside of _mv88e6xxx_atu_getnext
so future code could call ATU Get Next multiple times and save a few
register access.
---
 drivers/net/dsa/mv88e6xxx.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 1edefe0..b4e97c1 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1751,7 +1751,6 @@ int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int 
port,
 }
 
 static int _mv88e6xxx_atu_getnext(struct dsa_switch *ds, u16 fid,
- const unsigned char *addr,
  struct mv88e6xxx_atu_entry *entry)
 {
struct mv88e6xxx_atu_entry next = { 0 };
@@ -1763,10 +1762,6 @@ static int _mv88e6xxx_atu_getnext(struct dsa_switch *ds, 
u16 fid,
if (ret < 0)
return ret;
 
-   ret = _mv88e6xxx_atu_mac_write(ds, addr);
-   if (ret < 0)
-   return ret;
-
ret = _mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_ATU_FID, fid);
if (ret < 0)
return ret;
@@ -1827,7 +1822,11 @@ int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, 
int port,
fid = vtu.fid;
}
 
-   ret = _mv88e6xxx_atu_getnext(ds, fid, addr, &next);
+   ret = _mv88e6xxx_atu_mac_write(ds, addr);
+   if (ret < 0)
+   goto unlock;
+
+   ret = _mv88e6xxx_atu_getnext(ds, fid, &next);
if (ret < 0)
goto unlock;
 
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 1/6] net: dsa: mv88e6xxx: write VID outside of VTU Get Next code

2015-10-13 Thread Vivien Didelot
There is no need to write the VLAN ID before every Get Next operation,
since the VTU VID register is not cleared between calls.

Move the VID write call in a _mv88e6xxx_vtu_vid_write function outside
of _mv88e6xxx_vtu_getnext so future code could call VTU Get Next
multiple times and save a few register accesses.

Signed-off-by: Vivien Didelot 
---
 drivers/net/dsa/mv88e6xxx.c | 45 ++---
 1 file changed, 34 insertions(+), 11 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 63736f9..1edefe0 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1259,7 +1259,13 @@ static int _mv88e6xxx_vtu_stu_data_write(struct 
dsa_switch *ds,
return 0;
 }
 
-static int _mv88e6xxx_vtu_getnext(struct dsa_switch *ds, u16 vid,
+static int _mv88e6xxx_vtu_vid_write(struct dsa_switch *ds, u16 vid)
+{
+   return _mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_VTU_VID,
+   vid & GLOBAL_VTU_VID_MASK);
+}
+
+static int _mv88e6xxx_vtu_getnext(struct dsa_switch *ds,
  struct mv88e6xxx_vtu_stu_entry *entry)
 {
struct mv88e6xxx_vtu_stu_entry next = { 0 };
@@ -1269,11 +1275,6 @@ static int _mv88e6xxx_vtu_getnext(struct dsa_switch *ds, 
u16 vid,
if (ret < 0)
return ret;
 
-   ret = _mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_VTU_VID,
-  vid & GLOBAL_VTU_VID_MASK);
-   if (ret < 0)
-   return ret;
-
ret = _mv88e6xxx_vtu_cmd(ds, GLOBAL_VTU_OP_VTU_GET_NEXT);
if (ret < 0)
return ret;
@@ -1485,7 +1486,12 @@ int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int 
port, u16 vid,
int err;
 
mutex_lock(&ps->smi_mutex);
-   err = _mv88e6xxx_vtu_getnext(ds, vid - 1, &vlan);
+
+   err = _mv88e6xxx_vtu_vid_write(ds, vid - 1);
+   if (err)
+   return err;
+
+   err = _mv88e6xxx_vtu_getnext(ds, &vlan);
if (err)
goto unlock;
 
@@ -1514,7 +1520,11 @@ int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int 
port, u16 vid)
 
mutex_lock(&ps->smi_mutex);
 
-   err = _mv88e6xxx_vtu_getnext(ds, vid - 1, &vlan);
+   err = _mv88e6xxx_vtu_vid_write(ds, vid - 1);
+   if (err)
+   return err;
+
+   err = _mv88e6xxx_vtu_getnext(ds, &vlan);
if (err)
goto unlock;
 
@@ -1558,7 +1568,11 @@ static int _mv88e6xxx_port_vtu_getnext(struct dsa_switch 
*ds, int port, u16 vid,
if (vid == 4095)
return -ENOENT;
 
-   err = _mv88e6xxx_vtu_getnext(ds, vid, entry);
+   err = _mv88e6xxx_vtu_vid_write(ds, vid);
+   if (err)
+   return err;
+
+   err = _mv88e6xxx_vtu_getnext(ds, entry);
if (err)
return err;
 
@@ -1584,7 +1598,12 @@ int mv88e6xxx_vlan_getnext(struct dsa_switch *ds, u16 
*vid,
return -ENOENT;
 
mutex_lock(&ps->smi_mutex);
-   err = _mv88e6xxx_vtu_getnext(ds, *vid, &next);
+   err = _mv88e6xxx_vtu_vid_write(ds, *vid);
+   if (err)
+   goto unlock;
+
+   err = _mv88e6xxx_vtu_getnext(ds, &next);
+unlock:
mutex_unlock(&ps->smi_mutex);
 
if (err)
@@ -2274,10 +2293,14 @@ static int mv88e6xxx_vtu_show(struct seq_file *s, void 
*p)
 
mutex_lock(&ps->smi_mutex);
 
+   ret = _mv88e6xxx_vtu_vid_write(ds, vid);
+   if (ret < 0)
+   goto unlock;
+
do {
struct mv88e6xxx_vtu_stu_entry next = { 0 };
 
-   ret = _mv88e6xxx_vtu_getnext(ds, vid, &next);
+   ret = _mv88e6xxx_vtu_getnext(ds, &next);
if (ret < 0)
goto unlock;
 
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 1/4] net/mlx5_core: Fix internal error detection conditions

2015-10-13 Thread Or Gerlitz
From: Eli Cohen 

The detection of a fatal condition has been updated to take into account
the state reported by the device or by detecting an all ones read of the
firmware version which indicates that the device is not accessible.

Signed-off-by: Eli Cohen 
Signed-off-by: Or Gerlitz 
---
 drivers/net/ethernet/mellanox/mlx5/core/health.c | 51 
 include/linux/mlx5/driver.h  |  1 +
 2 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c 
b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index 9b81e1c..b007e83 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -57,6 +57,31 @@ enum {
MLX5_HEALTH_SYNDR_HIGH_TEMP = 0x10
 };
 
+enum {
+   MLX5_NIC_IFC_FULL   = 0,
+   MLX5_NIC_IFC_DISABLED   = 1,
+   MLX5_NIC_IFC_NO_DRAM_NIC= 2
+};
+
+static u8 get_nic_interface(struct mlx5_core_dev *dev)
+{
+   return (ioread32be(&dev->iseg->cmdq_addr_l_sz) >> 8) & 3;
+}
+
+static int in_fatal(struct mlx5_core_dev *dev)
+{
+   struct mlx5_core_health *health = &dev->priv.health;
+   struct health_buffer __iomem *h = health->health;
+
+   if (get_nic_interface(dev) == MLX5_NIC_IFC_DISABLED)
+   return 1;
+
+   if (ioread32be(&h->fw_ver) == 0x)
+   return 1;
+
+   return 0;
+}
+
 static void health_care(struct work_struct *work)
 {
struct mlx5_core_health *health;
@@ -136,11 +161,21 @@ static void print_health_info(struct mlx5_core_dev *dev)
dev_err(&dev->pdev->dev, "ext_synd 0x%04x\n", ioread16be(&h->ext_synd));
 }
 
+static unsigned long get_next_poll_jiffies(void)
+{
+   unsigned long next;
+
+   get_random_bytes(&next, sizeof(next));
+   next %= HZ;
+   next += jiffies + MLX5_HEALTH_POLL_INTERVAL;
+
+   return next;
+}
+
 static void poll_health(unsigned long data)
 {
struct mlx5_core_dev *dev = (struct mlx5_core_dev *)data;
struct mlx5_core_health *health = &dev->priv.health;
-   unsigned long next;
u32 count;
 
count = ioread32be(health->health_counter);
@@ -151,14 +186,16 @@ static void poll_health(unsigned long data)
 
health->prev = count;
if (health->miss_counter == MAX_MISSES) {
-   mlx5_core_err(dev, "device's health compromised\n");
+   dev_err(&dev->pdev->dev, "device's health compromised - reached 
miss count\n");
print_health_info(dev);
-   queue_work(health->wq, &health->work);
} else {
-   get_random_bytes(&next, sizeof(next));
-   next %= HZ;
-   next += jiffies + MLX5_HEALTH_POLL_INTERVAL;
-   mod_timer(&health->timer, next);
+   mod_timer(&health->timer, get_next_poll_jiffies());
+   }
+
+   if (in_fatal(dev) && !health->sick) {
+   health->sick = 1;
+   print_health_info(dev);
+   queue_work(health->wq, &health->work);
}
 }
 
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index 41a3287..cd469b9 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -393,6 +393,7 @@ struct mlx5_core_health {
struct timer_list   timer;
u32 prev;
int miss_counter;
+   int sick;
struct workqueue_struct*wq;
struct work_struct  work;
 };
-- 
2.3.7

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 4/4] net/mlx4_core: Replace VF zero mac with random mac in mlx4_core

2015-10-13 Thread Or Gerlitz
From: Jack Morgenstein 

By design, when no default MAC addresses are set in the Hypervisor for VFs,
the VFs are passed zero-macs. When such a MAC is received by the VF, it
generates a random MAC address and registers that MAC address
with the Hypervisor.

This random mac generation is currently done in the mlx4_en module.
There is a problem, though, if the mlx4_ib module is loaded by a VF before
the mlx4_en module. In this case, for RoCE, mlx4_ib will see the un-replaced
zero-mac and register that zero-mac as part of QP1 initialization.

Having a zero-mac in the port's MAC table creates problems for a
Baseboard Management Console. The BMC occasionally sends packets with a
zero-mac destination MAC. If there is a zero-mac present in the port's
MAC table, the FW will send such BMC packets to the host driver rather than
to the wire, and BMC will stop working.

To address this problem, we move the replacement of zero-mac addresses
with random-mac addresses to procedure mlx4_slave_cap(), which is part of the
driver startup for VFs, and is before activation of mlx4_ib and mlx4_en.
As a result, zero-mac addresses will never be registered in the port MAC table
by the driver.

In addition, when mlx4_en does initialize the net device, it needs to set
the NET_ADDR_RANDOM flag in the netdev structure if the address was
randomly generated. This is done so that udev on the VM does not create
a new device name after each VF probe (VM boot and such). To accomplish this,
we add a per-port flag in mlx4_dev which gets set whenever mlx4_core replaces
a zero-mac with a randomly-generated mac. This flag is examined when mlx4_en
initializes the net-device.

Fix was suggested by Matan Barak 

Signed-off-by: Jack Morgenstein 
Signed-off-by: Or Gerlitz 
---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 23 +++
 drivers/net/ethernet/mellanox/mlx4/fw.c| 16 
 drivers/net/ethernet/mellanox/mlx4/main.c  |  2 ++
 drivers/net/ethernet/mellanox/mlx4/mlx4.h  |  2 ++
 include/linux/mlx4/device.h|  1 +
 5 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c 
b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 597d892..886e1bc 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2816,7 +2816,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int 
port,
struct mlx4_en_priv *priv;
int i;
int err;
-   u64 mac_u64;
 
dev = alloc_etherdev_mqs(sizeof(struct mlx4_en_priv),
 MAX_TX_RINGS, MAX_RX_RINGS);
@@ -2908,17 +2907,17 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int 
port,
dev->addr_len = ETH_ALEN;
mlx4_en_u64_to_mac(dev->dev_addr, mdev->dev->caps.def_mac[priv->port]);
if (!is_valid_ether_addr(dev->dev_addr)) {
-   if (mlx4_is_slave(priv->mdev->dev)) {
-   eth_hw_addr_random(dev);
-   en_warn(priv, "Assigned random MAC address %pM\n", 
dev->dev_addr);
-   mac_u64 = mlx4_mac_to_u64(dev->dev_addr);
-   mdev->dev->caps.def_mac[priv->port] = mac_u64;
-   } else {
-   en_err(priv, "Port: %d, invalid mac burned: %pM, 
quiting\n",
-  priv->port, dev->dev_addr);
-   err = -EINVAL;
-   goto out;
-   }
+   en_err(priv, "Port: %d, invalid mac burned: %pM, quiting\n",
+  priv->port, dev->dev_addr);
+   err = -EINVAL;
+   goto out;
+   } else if (mlx4_is_slave(priv->mdev->dev) &&
+  (priv->mdev->dev->port_random_macs & 1 << priv->port)) {
+   /* Random MAC was assigned in mlx4_slave_cap
+* in mlx4_core module
+*/
+   dev->addr_assign_type |= NET_ADDR_RANDOM;
+   en_warn(priv, "Assigned random MAC address %pM\n", 
dev->dev_addr);
}
 
memcpy(priv->current_mac, dev->dev_addr, sizeof(priv->current_mac));
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c 
b/drivers/net/ethernet/mellanox/mlx4/fw.c
index e8ec1de..f13a4d7 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -2840,3 +2840,19 @@ int set_phv_bit(struct mlx4_dev *dev, u8 port, int 
new_val)
return -EOPNOTSUPP;
 }
 EXPORT_SYMBOL(set_phv_bit);
+
+void mlx4_replace_zero_macs(struct mlx4_dev *dev)
+{
+   int i;
+   u8 mac_addr[ETH_ALEN];
+
+   dev->port_random_macs = 0;
+   for (i = 1; i <= dev->caps.num_ports; ++i)
+   if (!dev->caps.def_mac[i] &&
+   dev->caps.port_type[i] == MLX4_PORT_TYPE_ETH) {
+   eth_random_addr(mac_addr);
+   dev->port_random_macs |= 1 << i;
+   dev->caps.def_mac[i] =

[PATCH net-next 3/4] net/mlx5_core: Wait for FW readiness on startup

2015-10-13 Thread Or Gerlitz
From: Eli Cohen 

On device initialization, wait till firmware indicates that that it is done
with initialization before proceeding to initialize the device.

Also update initialization segment layout to match driver/firmware
interface definitions.

Signed-off-by: Eli Cohen 
Signed-off-by: Or Gerlitz 
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 27 ++
 include/linux/mlx5/device.h|  3 ++-
 include/linux/mlx5/driver.h|  5 +
 3 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 368c2ea..c55bb37 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -152,6 +153,25 @@ static struct mlx5_profile profile[] = {
},
 };
 
+#define FW_INIT_TIMEOUT_MILI   2000
+#define FW_INIT_WAIT_MS2
+
+static int wait_fw_init(struct mlx5_core_dev *dev, u32 max_wait_mili)
+{
+   unsigned long end = jiffies + msecs_to_jiffies(max_wait_mili);
+   int err = 0;
+
+   while (fw_initializing(dev)) {
+   if (time_after(jiffies, end)) {
+   err = -EBUSY;
+   break;
+   }
+   msleep(FW_INIT_WAIT_MS);
+   }
+
+   return err;
+}
+
 static int set_dma_caps(struct pci_dev *pdev)
 {
int err;
@@ -913,6 +933,13 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct 
mlx5_priv *priv)
goto out_err;
}
 
+   err = wait_fw_init(dev, FW_INIT_TIMEOUT_MILI);
+   if (err) {
+   dev_err(&dev->pdev->dev, "Firmware over %d MS in initializing 
state, aborting\n",
+   FW_INIT_TIMEOUT_MILI);
+   goto out_err;
+   }
+
mlx5_pagealloc_init(dev);
 
err = mlx5_core_enable_hca(dev);
diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h
index 2a0b956..0b473cb 100644
--- a/include/linux/mlx5/device.h
+++ b/include/linux/mlx5/device.h
@@ -439,7 +439,8 @@ struct mlx5_init_seg {
__be32  cmdq_addr_h;
__be32  cmdq_addr_l_sz;
__be32  cmd_dbell;
-   __be32  rsvd1[121];
+   __be32  rsvd1[120];
+   __be32  initializing;
struct health_bufferhealth;
__be32  rsvd2[884];
__be32  health_counter;
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index 9d77b8d..c2ea5aa 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -826,6 +826,11 @@ void mlx5_core_put_rsc(struct mlx5_core_rsc_common 
*common);
 int mlx5_query_odp_caps(struct mlx5_core_dev *dev,
struct mlx5_odp_caps *odp_caps);
 
+static inline int fw_initializing(struct mlx5_core_dev *dev)
+{
+   return ioread32be(&dev->iseg->initializing) >> 31;
+}
+
 static inline u32 mlx5_mkey_to_idx(u32 mkey)
 {
return mkey >> 8;
-- 
2.3.7

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >