Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next-2.6] mlx4:  make functions local and remove dead code.
From: Stephen Hemminger @ 2010-10-18 15:30 UTC (permalink / raw)
  To: David Miller, Yevgeny Petrilin; +Cc: netdev

There is a whole section of code in this driver related to vlan tables
which is not accessed from any kernel code.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

---
 drivers/net/mlx4/cq.c       |    3 +
 drivers/net/mlx4/en_rx.c    |    3 -
 drivers/net/mlx4/icm.c      |   28 ------------
 drivers/net/mlx4/icm.h      |    2 
 drivers/net/mlx4/mlx4_en.h  |    3 -
 drivers/net/mlx4/port.c     |   97 --------------------------------------------
 include/linux/mlx4/device.h |    3 -
 7 files changed, 6 insertions(+), 133 deletions(-)

--- a/drivers/net/mlx4/en_rx.c	2010-10-15 16:06:32.842275374 -0700
+++ b/drivers/net/mlx4/en_rx.c	2010-10-15 16:06:44.642682840 -0700
@@ -524,7 +524,8 @@ out_loopback:
 	dev_kfree_skb_any(skb);
 }
 
-int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int budget)
+static int mlx4_en_process_rx_cq(struct net_device *dev,
+				 struct mlx4_en_cq *cq, int budget)
 {
 	struct mlx4_en_priv *priv = netdev_priv(dev);
 	struct mlx4_cqe *cqe;
--- a/drivers/net/mlx4/icm.c	2010-10-15 16:03:02.783025372 -0700
+++ b/drivers/net/mlx4/icm.c	2010-10-15 16:08:09.977629991 -0700
@@ -210,38 +210,12 @@ static int mlx4_MAP_ICM(struct mlx4_dev
 	return mlx4_map_cmd(dev, MLX4_CMD_MAP_ICM, icm, virt);
 }
 
-int mlx4_UNMAP_ICM(struct mlx4_dev *dev, u64 virt, u32 page_count)
+static int mlx4_UNMAP_ICM(struct mlx4_dev *dev, u64 virt, u32 page_count)
 {
 	return mlx4_cmd(dev, virt, page_count, 0, MLX4_CMD_UNMAP_ICM,
 			MLX4_CMD_TIME_CLASS_B);
 }
 
-int mlx4_MAP_ICM_page(struct mlx4_dev *dev, u64 dma_addr, u64 virt)
-{
-	struct mlx4_cmd_mailbox *mailbox;
-	__be64 *inbox;
-	int err;
-
-	mailbox = mlx4_alloc_cmd_mailbox(dev);
-	if (IS_ERR(mailbox))
-		return PTR_ERR(mailbox);
-	inbox = mailbox->buf;
-
-	inbox[0] = cpu_to_be64(virt);
-	inbox[1] = cpu_to_be64(dma_addr);
-
-	err = mlx4_cmd(dev, mailbox->dma, 1, 0, MLX4_CMD_MAP_ICM,
-		       MLX4_CMD_TIME_CLASS_B);
-
-	mlx4_free_cmd_mailbox(dev, mailbox);
-
-	if (!err)
-		mlx4_dbg(dev, "Mapped page at %llx to %llx for ICM.\n",
-			  (unsigned long long) dma_addr, (unsigned long long) virt);
-
-	return err;
-}
-
 int mlx4_MAP_ICM_AUX(struct mlx4_dev *dev, struct mlx4_icm *icm)
 {
 	return mlx4_map_cmd(dev, MLX4_CMD_MAP_ICM_AUX, icm, -1);
--- a/drivers/net/mlx4/icm.h	2010-10-15 16:05:35.580298413 -0700
+++ b/drivers/net/mlx4/icm.h	2010-10-15 16:05:54.912965820 -0700
@@ -128,8 +128,6 @@ static inline unsigned long mlx4_icm_siz
 	return sg_dma_len(&iter->chunk->mem[iter->page_idx]);
 }
 
-int mlx4_UNMAP_ICM(struct mlx4_dev *dev, u64 virt, u32 page_count);
-int mlx4_MAP_ICM_page(struct mlx4_dev *dev, u64 dma_addr, u64 virt);
 int mlx4_MAP_ICM_AUX(struct mlx4_dev *dev, struct mlx4_icm *icm);
 int mlx4_UNMAP_ICM_AUX(struct mlx4_dev *dev);
 
--- a/drivers/net/mlx4/port.c	2010-10-15 16:03:13.639399914 -0700
+++ b/drivers/net/mlx4/port.c	2010-10-15 16:11:09.571835685 -0700
@@ -161,103 +161,6 @@ out:
 }
 EXPORT_SYMBOL_GPL(mlx4_unregister_mac);
 
-static int mlx4_set_port_vlan_table(struct mlx4_dev *dev, u8 port,
-				    __be32 *entries)
-{
-	struct mlx4_cmd_mailbox *mailbox;
-	u32 in_mod;
-	int err;
-
-	mailbox = mlx4_alloc_cmd_mailbox(dev);
-	if (IS_ERR(mailbox))
-		return PTR_ERR(mailbox);
-
-	memcpy(mailbox->buf, entries, MLX4_VLAN_TABLE_SIZE);
-	in_mod = MLX4_SET_PORT_VLAN_TABLE << 8 | port;
-	err = mlx4_cmd(dev, mailbox->dma, in_mod, 1, MLX4_CMD_SET_PORT,
-		       MLX4_CMD_TIME_CLASS_B);
-
-	mlx4_free_cmd_mailbox(dev, mailbox);
-
-	return err;
-}
-
-int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index)
-{
-	struct mlx4_vlan_table *table = &mlx4_priv(dev)->port[port].vlan_table;
-	int i, err = 0;
-	int free = -1;
-
-	mutex_lock(&table->mutex);
-	for (i = MLX4_VLAN_REGULAR; i < MLX4_MAX_VLAN_NUM; i++) {
-		if (free < 0 && (table->refs[i] == 0)) {
-			free = i;
-			continue;
-		}
-
-		if (table->refs[i] &&
-		    (vlan == (MLX4_VLAN_MASK &
-			      be32_to_cpu(table->entries[i])))) {
-			/* Vlan already registered, increase refernce count */
-			*index = i;
-			++table->refs[i];
-			goto out;
-		}
-	}
-
-	if (table->total == table->max) {
-		/* No free vlan entries */
-		err = -ENOSPC;
-		goto out;
-	}
-
-	/* Register new MAC */
-	table->refs[free] = 1;
-	table->entries[free] = cpu_to_be32(vlan | MLX4_VLAN_VALID);
-
-	err = mlx4_set_port_vlan_table(dev, port, table->entries);
-	if (unlikely(err)) {
-		mlx4_warn(dev, "Failed adding vlan: %u\n", vlan);
-		table->refs[free] = 0;
-		table->entries[free] = 0;
-		goto out;
-	}
-
-	*index = free;
-	++table->total;
-out:
-	mutex_unlock(&table->mutex);
-	return err;
-}
-EXPORT_SYMBOL_GPL(mlx4_register_vlan);
-
-void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index)
-{
-	struct mlx4_vlan_table *table = &mlx4_priv(dev)->port[port].vlan_table;
-
-	if (index < MLX4_VLAN_REGULAR) {
-		mlx4_warn(dev, "Trying to free special vlan index %d\n", index);
-		return;
-	}
-
-	mutex_lock(&table->mutex);
-	if (!table->refs[index]) {
-		mlx4_warn(dev, "No vlan entry for index %d\n", index);
-		goto out;
-	}
-	if (--table->refs[index]) {
-		mlx4_dbg(dev, "Have more references for index %d,"
-			 "no need to modify vlan table\n", index);
-		goto out;
-	}
-	table->entries[index] = 0;
-	mlx4_set_port_vlan_table(dev, port, table->entries);
-	--table->total;
-out:
-	mutex_unlock(&table->mutex);
-}
-EXPORT_SYMBOL_GPL(mlx4_unregister_vlan);
-
 int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps)
 {
 	struct mlx4_cmd_mailbox *inmailbox, *outmailbox;
--- a/include/linux/mlx4/device.h	2010-10-15 16:07:38.204532549 -0700
+++ b/include/linux/mlx4/device.h	2010-10-15 16:07:44.988766865 -0700
@@ -474,9 +474,6 @@ int mlx4_multicast_detach(struct mlx4_de
 int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *index);
 void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, int index);
 
-int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
-void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index);
-
 int mlx4_map_phys_fmr(struct mlx4_dev *dev, struct mlx4_fmr *fmr, u64 *page_list,
 		      int npages, u64 iova, u32 *lkey, u32 *rkey);
 int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages,
--- a/drivers/net/mlx4/mlx4_en.h	2010-10-15 16:08:26.146188502 -0700
+++ b/drivers/net/mlx4/mlx4_en.h	2010-10-15 16:08:31.706380578 -0700
@@ -518,9 +518,6 @@ void mlx4_en_destroy_rx_ring(struct mlx4
 int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv);
 void mlx4_en_deactivate_rx_ring(struct mlx4_en_priv *priv,
 				struct mlx4_en_rx_ring *ring);
-int mlx4_en_process_rx_cq(struct net_device *dev,
-			  struct mlx4_en_cq *cq,
-			  int budget);
 int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget);
 void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride,
 			     int is_tx, int rss, int qpn, int cqn,
--- a/drivers/net/mlx4/cq.c	2010-10-15 16:02:59.774921596 -0700
+++ b/drivers/net/mlx4/cq.c	2010-10-15 16:11:49.937227452 -0700
@@ -73,6 +73,9 @@ struct mlx4_cq_context {
 #define MLX4_CQ_STATE_ARMED_SOL		( 6 <<  8)
 #define MLX4_EQ_STATE_FIRED		(10 <<  8)
 
+static int mlx4_ib_umem_write_mtt(struct mlx4_ib_dev *dev, struct mlx4_mtt *mtt,
+				  struct ib_umem *umem);
+
 void mlx4_cq_completion(struct mlx4_dev *dev, u32 cqn)
 {
 	struct mlx4_cq *cq;

^ permalink raw reply

* [PATCH 2/3] cxgb4: function namespace cleanup (v3)
From: Stephen Hemminger @ 2010-10-18 15:39 UTC (permalink / raw)
  To: David Miller; +Cc: swise, dm, divy, leedom, netdev
In-Reply-To: <20101018.073145.189710492.davem@davemloft.net>

Make functions only used in one file local.
Remove lots of dead code, relating to unsupported functions
in mainline driver like RSS, IPv6, and TCP offload.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

---
Patch against version in linux-next. It keeps the hooks
necessary for iscsi and get_tcp_stats.

 drivers/net/cxgb4/cxgb4.h      |   15 -
 drivers/net/cxgb4/cxgb4_main.c |   68 --------
 drivers/net/cxgb4/cxgb4_uld.h  |    6 
 drivers/net/cxgb4/l2t.c        |   34 ----
 drivers/net/cxgb4/l2t.h        |    3 
 drivers/net/cxgb4/t4_hw.c      |  332 -----------------------------------------
 6 files changed, 3 insertions(+), 455 deletions(-)

--- a/drivers/net/cxgb4/cxgb4_main.c	2010-10-18 08:33:48.369371944 -0700
+++ b/drivers/net/cxgb4/cxgb4_main.c	2010-10-18 08:34:44.910406405 -0700
@@ -880,7 +880,7 @@ void *t4_alloc_mem(size_t size)
 /*
  * Free memory allocated through alloc_mem().
  */
-void t4_free_mem(void *addr)
+static void t4_free_mem(void *addr)
 {
 	if (is_vmalloc_addr(addr))
 		vfree(addr);
@@ -2206,8 +2206,8 @@ static void mk_tid_release(struct sk_buf
  * Queue a TID release request and if necessary schedule a work queue to
  * process it.
  */
-void cxgb4_queue_tid_release(struct tid_info *t, unsigned int chan,
-			     unsigned int tid)
+static void cxgb4_queue_tid_release(struct tid_info *t, unsigned int chan,
+				    unsigned int tid)
 {
 	void **p = &t->tid_tab[tid];
 	struct adapter *adap = container_of(t, struct adapter, tids);
@@ -2222,7 +2222,6 @@ void cxgb4_queue_tid_release(struct tid_
 	}
 	spin_unlock_bh(&adap->tid_release_lock);
 }
-EXPORT_SYMBOL(cxgb4_queue_tid_release);
 
 /*
  * Process the list of pending TID release requests.
@@ -2355,48 +2354,6 @@ int cxgb4_create_server(const struct net
 EXPORT_SYMBOL(cxgb4_create_server);
 
 /**
- *	cxgb4_create_server6 - create an IPv6 server
- *	@dev: the device
- *	@stid: the server TID
- *	@sip: local IPv6 address to bind server to
- *	@sport: the server's TCP port
- *	@queue: queue to direct messages from this server to
- *
- *	Create an IPv6 server for the given port and address.
- *	Returns <0 on error and one of the %NET_XMIT_* values on success.
- */
-int cxgb4_create_server6(const struct net_device *dev, unsigned int stid,
-			 const struct in6_addr *sip, __be16 sport,
-			 unsigned int queue)
-{
-	unsigned int chan;
-	struct sk_buff *skb;
-	struct adapter *adap;
-	struct cpl_pass_open_req6 *req;
-
-	skb = alloc_skb(sizeof(*req), GFP_KERNEL);
-	if (!skb)
-		return -ENOMEM;
-
-	adap = netdev2adap(dev);
-	req = (struct cpl_pass_open_req6 *)__skb_put(skb, sizeof(*req));
-	INIT_TP_WR(req, 0);
-	OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_PASS_OPEN_REQ6, stid));
-	req->local_port = sport;
-	req->peer_port = htons(0);
-	req->local_ip_hi = *(__be64 *)(sip->s6_addr);
-	req->local_ip_lo = *(__be64 *)(sip->s6_addr + 8);
-	req->peer_ip_hi = cpu_to_be64(0);
-	req->peer_ip_lo = cpu_to_be64(0);
-	chan = rxq_to_chan(&adap->sge, queue);
-	req->opt0 = cpu_to_be64(TX_CHAN(chan));
-	req->opt1 = cpu_to_be64(CONN_POLICY_ASK |
-				SYN_RSS_ENABLE | SYN_RSS_QUEUE(queue));
-	return t4_mgmt_tx(adap, skb);
-}
-EXPORT_SYMBOL(cxgb4_create_server6);
-
-/**
  *	cxgb4_best_mtu - find the entry in the MTU table closest to an MTU
  *	@mtus: the HW MTU table
  *	@mtu: the target MTU
@@ -2455,25 +2412,6 @@ unsigned int cxgb4_port_idx(const struct
 }
 EXPORT_SYMBOL(cxgb4_port_idx);
 
-/**
- *	cxgb4_netdev_by_hwid - return the net device of a HW port
- *	@pdev: identifies the adapter
- *	@id: the HW port id
- *
- *	Return the net device associated with the interface with the given HW
- *	id.
- */
-struct net_device *cxgb4_netdev_by_hwid(struct pci_dev *pdev, unsigned int id)
-{
-	const struct adapter *adap = pci_get_drvdata(pdev);
-
-	if (!adap || id >= NCHAN)
-		return NULL;
-	id = adap->chan_map[id];
-	return id < MAX_NPORTS ? adap->port[id] : NULL;
-}
-EXPORT_SYMBOL(cxgb4_netdev_by_hwid);
-
 void cxgb4_get_tcp_stats(struct pci_dev *pdev, struct tp_tcp_stats *v4,
 			 struct tp_tcp_stats *v6)
 {
--- a/drivers/net/cxgb4/cxgb4_uld.h	2010-10-18 08:33:48.339371406 -0700
+++ b/drivers/net/cxgb4/cxgb4_uld.h	2010-10-18 08:34:44.910406405 -0700
@@ -139,16 +139,11 @@ int cxgb4_alloc_stid(struct tid_info *t,
 void cxgb4_free_atid(struct tid_info *t, unsigned int atid);
 void cxgb4_free_stid(struct tid_info *t, unsigned int stid, int family);
 void cxgb4_remove_tid(struct tid_info *t, unsigned int qid, unsigned int tid);
-void cxgb4_queue_tid_release(struct tid_info *t, unsigned int chan,
-			     unsigned int tid);
 
 struct in6_addr;
 
 int cxgb4_create_server(const struct net_device *dev, unsigned int stid,
 			__be32 sip, __be16 sport, unsigned int queue);
-int cxgb4_create_server6(const struct net_device *dev, unsigned int stid,
-			 const struct in6_addr *sip, __be16 sport,
-			 unsigned int queue);
 
 static inline void set_wr_txq(struct sk_buff *skb, int prio, int queue)
 {
@@ -233,7 +228,6 @@ int cxgb4_ofld_send(struct net_device *d
 unsigned int cxgb4_port_chan(const struct net_device *dev);
 unsigned int cxgb4_port_viid(const struct net_device *dev);
 unsigned int cxgb4_port_idx(const struct net_device *dev);
-struct net_device *cxgb4_netdev_by_hwid(struct pci_dev *pdev, unsigned int id);
 unsigned int cxgb4_best_mtu(const unsigned short *mtus, unsigned short mtu,
 			    unsigned int *idx);
 void cxgb4_get_tcp_stats(struct pci_dev *pdev, struct tp_tcp_stats *v4,
--- a/drivers/net/cxgb4/cxgb4.h	2010-10-18 08:33:48.319371031 -0700
+++ b/drivers/net/cxgb4/cxgb4.h	2010-10-18 08:34:44.910406405 -0700
@@ -592,7 +592,6 @@ void t4_os_portmod_changed(const struct
 void t4_os_link_changed(struct adapter *adap, int port_id, int link_stat);
 
 void *t4_alloc_mem(size_t size);
-void t4_free_mem(void *addr);
 
 void t4_free_sge_resources(struct adapter *adap);
 irq_handler_t t4_intr_handler(struct adapter *adap);
@@ -651,7 +650,6 @@ static inline int t4_wr_mbox_ns(struct a
 
 void t4_intr_enable(struct adapter *adapter);
 void t4_intr_disable(struct adapter *adapter);
-void t4_intr_clear(struct adapter *adapter);
 int t4_slow_intr_handler(struct adapter *adapter);
 
 int t4_wait_dev_ready(struct adapter *adap);
@@ -664,24 +662,16 @@ int t4_check_fw_version(struct adapter *
 int t4_prep_adapter(struct adapter *adapter);
 int t4_port_init(struct adapter *adap, int mbox, int pf, int vf);
 void t4_fatal_err(struct adapter *adapter);
-int t4_set_trace_filter(struct adapter *adapter, const struct trace_params *tp,
-			int filter_index, int enable);
-void t4_get_trace_filter(struct adapter *adapter, struct trace_params *tp,
-			 int filter_index, int *enabled);
 int t4_config_rss_range(struct adapter *adapter, int mbox, unsigned int viid,
 			int start, int n, const u16 *rspq, unsigned int nrspq);
 int t4_config_glbl_rss(struct adapter *adapter, int mbox, unsigned int mode,
 		       unsigned int flags);
-int t4_read_rss(struct adapter *adapter, u16 *entries);
 int t4_mc_read(struct adapter *adap, u32 addr, __be32 *data, u64 *parity);
 int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data,
 		u64 *parity);
 
 void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p);
-void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p);
-
 void t4_read_mtu_tbl(struct adapter *adap, u16 *mtus, u8 *mtu_log);
-void t4_tp_get_err_stats(struct adapter *adap, struct tp_err_stats *st);
 void t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4,
 			 struct tp_tcp_stats *v6);
 void t4_load_mtus(struct adapter *adap, const unsigned short *mtus,
@@ -711,8 +701,6 @@ int t4_cfg_pfvf(struct adapter *adap, un
 int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
 		unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac,
 		unsigned int *rss_size);
-int t4_free_vi(struct adapter *adap, unsigned int mbox, unsigned int pf,
-	       unsigned int vf, unsigned int viid);
 int t4_set_rxmode(struct adapter *adap, unsigned int mbox, unsigned int viid,
 		int mtu, int promisc, int all_multi, int bcast, int vlanex,
 		bool sleep_ok);
@@ -731,9 +719,6 @@ int t4_mdio_rd(struct adapter *adap, uns
 	       unsigned int mmd, unsigned int reg, u16 *valp);
 int t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
 	       unsigned int mmd, unsigned int reg, u16 val);
-int t4_iq_start_stop(struct adapter *adap, unsigned int mbox, bool start,
-		     unsigned int pf, unsigned int vf, unsigned int iqid,
-		     unsigned int fl0id, unsigned int fl1id);
 int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
 	       unsigned int vf, unsigned int iqtype, unsigned int iqid,
 	       unsigned int fl0id, unsigned int fl1id);
--- a/drivers/net/cxgb4/l2t.c	2010-10-18 08:33:48.349371585 -0700
+++ b/drivers/net/cxgb4/l2t.c	2010-10-18 08:34:44.920406584 -0700
@@ -481,40 +481,6 @@ void t4_l2t_update(struct adapter *adap,
 		handle_failed_resolution(adap, arpq);
 }
 
-/*
- * Allocate an L2T entry for use by a switching rule.  Such entries need to be
- * explicitly freed and while busy they are not on any hash chain, so normal
- * address resolution updates do not see them.
- */
-struct l2t_entry *t4_l2t_alloc_switching(struct l2t_data *d)
-{
-	struct l2t_entry *e;
-
-	write_lock_bh(&d->lock);
-	e = alloc_l2e(d);
-	if (e) {
-		spin_lock(&e->lock);          /* avoid race with t4_l2t_free */
-		e->state = L2T_STATE_SWITCHING;
-		atomic_set(&e->refcnt, 1);
-		spin_unlock(&e->lock);
-	}
-	write_unlock_bh(&d->lock);
-	return e;
-}
-
-/*
- * Sets/updates the contents of a switching L2T entry that has been allocated
- * with an earlier call to @t4_l2t_alloc_switching.
- */
-int t4_l2t_set_switching(struct adapter *adap, struct l2t_entry *e, u16 vlan,
-			 u8 port, u8 *eth_addr)
-{
-	e->vlan = vlan;
-	e->lport = port;
-	memcpy(e->dmac, eth_addr, ETH_ALEN);
-	return write_l2e(adap, e, 0);
-}
-
 struct l2t_data *t4_init_l2t(void)
 {
 	int i;
--- a/drivers/net/cxgb4/l2t.h	2010-10-18 08:33:48.329371216 -0700
+++ b/drivers/net/cxgb4/l2t.h	2010-10-18 08:34:44.920406584 -0700
@@ -100,9 +100,6 @@ struct l2t_entry *cxgb4_l2t_get(struct l
 				unsigned int priority);
 
 void t4_l2t_update(struct adapter *adap, struct neighbour *neigh);
-struct l2t_entry *t4_l2t_alloc_switching(struct l2t_data *d);
-int t4_l2t_set_switching(struct adapter *adap, struct l2t_entry *e, u16 vlan,
-			 u8 port, u8 *eth_addr);
 struct l2t_data *t4_init_l2t(void);
 void do_l2t_write_rpl(struct adapter *p, const struct cpl_l2t_write_rpl *rpl);
 
--- a/drivers/net/cxgb4/t4_hw.c	2010-10-18 08:33:48.309370846 -0700
+++ b/drivers/net/cxgb4/t4_hw.c	2010-10-18 08:34:44.920406584 -0700
@@ -120,30 +120,6 @@ static void t4_read_indirect(struct adap
 	}
 }
 
-#if 0
-/**
- *	t4_write_indirect - write indirectly addressed registers
- *	@adap: the adapter
- *	@addr_reg: register holding the indirect addresses
- *	@data_reg: register holding the value for the indirect registers
- *	@vals: values to write
- *	@nregs: how many indirect registers to write
- *	@start_idx: address of first indirect register to write
- *
- *	Writes a sequential block of registers that are accessed indirectly
- *	through an address/data register pair.
- */
-static void t4_write_indirect(struct adapter *adap, unsigned int addr_reg,
-			      unsigned int data_reg, const u32 *vals,
-			      unsigned int nregs, unsigned int start_idx)
-{
-	while (nregs--) {
-		t4_write_reg(adap, addr_reg, start_idx++);
-		t4_write_reg(adap, data_reg, *vals++);
-	}
-}
-#endif
-
 /*
  * Get the reply to a mailbox command and store it in @rpl in big-endian order.
  */
@@ -1560,44 +1536,6 @@ void t4_intr_disable(struct adapter *ada
 }
 
 /**
- *	t4_intr_clear - clear all interrupts
- *	@adapter: the adapter whose interrupts should be cleared
- *
- *	Clears all interrupts.  The caller must be a PCI function managing
- *	global interrupts.
- */
-void t4_intr_clear(struct adapter *adapter)
-{
-	static const unsigned int cause_reg[] = {
-		SGE_INT_CAUSE1, SGE_INT_CAUSE2, SGE_INT_CAUSE3,
-		PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS,
-		PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS,
-		PCIE_NONFAT_ERR, PCIE_INT_CAUSE,
-		MC_INT_CAUSE,
-		MA_INT_WRAP_STATUS, MA_PARITY_ERROR_STATUS, MA_INT_CAUSE,
-		EDC_INT_CAUSE, EDC_REG(EDC_INT_CAUSE, 1),
-		CIM_HOST_INT_CAUSE, CIM_HOST_UPACC_INT_CAUSE,
-		MYPF_REG(CIM_PF_HOST_INT_CAUSE),
-		TP_INT_CAUSE,
-		ULP_RX_INT_CAUSE, ULP_TX_INT_CAUSE,
-		PM_RX_INT_CAUSE, PM_TX_INT_CAUSE,
-		MPS_RX_PERR_INT_CAUSE,
-		CPL_INTR_CAUSE,
-		MYPF_REG(PL_PF_INT_CAUSE),
-		PL_PL_INT_CAUSE,
-		LE_DB_INT_CAUSE,
-	};
-
-	unsigned int i;
-
-	for (i = 0; i < ARRAY_SIZE(cause_reg); ++i)
-		t4_write_reg(adapter, cause_reg[i], 0xffffffff);
-
-	t4_write_reg(adapter, PL_INT_CAUSE, GLBL_INTR_MASK);
-	(void) t4_read_reg(adapter, PL_INT_CAUSE);          /* flush */
-}
-
-/**
  *	hash_mac_addr - return the hash value of a MAC address
  *	@addr: the 48-bit Ethernet MAC address
  *
@@ -1709,36 +1647,6 @@ int t4_config_glbl_rss(struct adapter *a
 	return t4_wr_mbox(adapter, mbox, &c, sizeof(c), NULL);
 }
 
-/* Read an RSS table row */
-static int rd_rss_row(struct adapter *adap, int row, u32 *val)
-{
-	t4_write_reg(adap, TP_RSS_LKP_TABLE, 0xfff00000 | row);
-	return t4_wait_op_done_val(adap, TP_RSS_LKP_TABLE, LKPTBLROWVLD, 1,
-				   5, 0, val);
-}
-
-/**
- *	t4_read_rss - read the contents of the RSS mapping table
- *	@adapter: the adapter
- *	@map: holds the contents of the RSS mapping table
- *
- *	Reads the contents of the RSS hash->queue mapping table.
- */
-int t4_read_rss(struct adapter *adapter, u16 *map)
-{
-	u32 val;
-	int i, ret;
-
-	for (i = 0; i < RSS_NENTRIES / 2; ++i) {
-		ret = rd_rss_row(adapter, i, &val);
-		if (ret)
-			return ret;
-		*map++ = LKPTBLQUEUE0_GET(val);
-		*map++ = LKPTBLQUEUE1_GET(val);
-	}
-	return 0;
-}
-
 /**
  *	t4_tp_get_tcp_stats - read TP's TCP MIB counters
  *	@adap: the adapter
@@ -1779,29 +1687,6 @@ void t4_tp_get_tcp_stats(struct adapter
 }
 
 /**
- *	t4_tp_get_err_stats - read TP's error MIB counters
- *	@adap: the adapter
- *	@st: holds the counter values
- *
- *	Returns the values of TP's error counters.
- */
-void t4_tp_get_err_stats(struct adapter *adap, struct tp_err_stats *st)
-{
-	t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->macInErrs,
-			 12, TP_MIB_MAC_IN_ERR_0);
-	t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->tnlCongDrops,
-			 8, TP_MIB_TNL_CNG_DROP_0);
-	t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->tnlTxDrops,
-			 4, TP_MIB_TNL_DROP_0);
-	t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->ofldVlanDrops,
-			 4, TP_MIB_OFD_VLN_DROP_0);
-	t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->tcp6InErrs,
-			 4, TP_MIB_TCP_V6IN_ERR_0);
-	t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, &st->ofldNoNeigh,
-			 2, TP_MIB_OFD_ARP_DROP);
-}
-
-/**
  *	t4_read_mtu_tbl - returns the values in the HW path MTU table
  *	@adap: the adapter
  *	@mtus: where to store the MTU values
@@ -1916,122 +1801,6 @@ void t4_load_mtus(struct adapter *adap,
 }
 
 /**
- *	t4_set_trace_filter - configure one of the tracing filters
- *	@adap: the adapter
- *	@tp: the desired trace filter parameters
- *	@idx: which filter to configure
- *	@enable: whether to enable or disable the filter
- *
- *	Configures one of the tracing filters available in HW.  If @enable is
- *	%0 @tp is not examined and may be %NULL.
- */
-int t4_set_trace_filter(struct adapter *adap, const struct trace_params *tp,
-			int idx, int enable)
-{
-	int i, ofst = idx * 4;
-	u32 data_reg, mask_reg, cfg;
-	u32 multitrc = TRCMULTIFILTER;
-
-	if (!enable) {
-		t4_write_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + ofst, 0);
-		goto out;
-	}
-
-	if (tp->port > 11 || tp->invert > 1 || tp->skip_len > 0x1f ||
-	    tp->skip_ofst > 0x1f || tp->min_len > 0x1ff ||
-	    tp->snap_len > 9600 || (idx && tp->snap_len > 256))
-		return -EINVAL;
-
-	if (tp->snap_len > 256) {            /* must be tracer 0 */
-		if ((t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + 4) |
-		     t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + 8) |
-		     t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + 12)) & TFEN)
-			return -EINVAL;  /* other tracers are enabled */
-		multitrc = 0;
-	} else if (idx) {
-		i = t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_B);
-		if (TFCAPTUREMAX_GET(i) > 256 &&
-		    (t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A) & TFEN))
-			return -EINVAL;
-	}
-
-	/* stop the tracer we'll be changing */
-	t4_write_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + ofst, 0);
-
-	/* disable tracing globally if running in the wrong single/multi mode */
-	cfg = t4_read_reg(adap, MPS_TRC_CFG);
-	if ((cfg & TRCEN) && multitrc != (cfg & TRCMULTIFILTER)) {
-		t4_write_reg(adap, MPS_TRC_CFG, cfg ^ TRCEN);
-		t4_read_reg(adap, MPS_TRC_CFG);                  /* flush */
-		msleep(1);
-		if (!(t4_read_reg(adap, MPS_TRC_CFG) & TRCFIFOEMPTY))
-			return -ETIMEDOUT;
-	}
-	/*
-	 * At this point either the tracing is enabled and in the right mode or
-	 * disabled.
-	 */
-
-	idx *= (MPS_TRC_FILTER1_MATCH - MPS_TRC_FILTER0_MATCH);
-	data_reg = MPS_TRC_FILTER0_MATCH + idx;
-	mask_reg = MPS_TRC_FILTER0_DONT_CARE + idx;
-
-	for (i = 0; i < TRACE_LEN / 4; i++, data_reg += 4, mask_reg += 4) {
-		t4_write_reg(adap, data_reg, tp->data[i]);
-		t4_write_reg(adap, mask_reg, ~tp->mask[i]);
-	}
-	t4_write_reg(adap, MPS_TRC_FILTER_MATCH_CTL_B + ofst,
-		     TFCAPTUREMAX(tp->snap_len) |
-		     TFMINPKTSIZE(tp->min_len));
-	t4_write_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + ofst,
-		     TFOFFSET(tp->skip_ofst) | TFLENGTH(tp->skip_len) |
-		     TFPORT(tp->port) | TFEN |
-		     (tp->invert ? TFINVERTMATCH : 0));
-
-	cfg &= ~TRCMULTIFILTER;
-	t4_write_reg(adap, MPS_TRC_CFG, cfg | TRCEN | multitrc);
-out:	t4_read_reg(adap, MPS_TRC_CFG);  /* flush */
-	return 0;
-}
-
-/**
- *	t4_get_trace_filter - query one of the tracing filters
- *	@adap: the adapter
- *	@tp: the current trace filter parameters
- *	@idx: which trace filter to query
- *	@enabled: non-zero if the filter is enabled
- *
- *	Returns the current settings of one of the HW tracing filters.
- */
-void t4_get_trace_filter(struct adapter *adap, struct trace_params *tp, int idx,
-			 int *enabled)
-{
-	u32 ctla, ctlb;
-	int i, ofst = idx * 4;
-	u32 data_reg, mask_reg;
-
-	ctla = t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + ofst);
-	ctlb = t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_B + ofst);
-
-	*enabled = !!(ctla & TFEN);
-	tp->snap_len = TFCAPTUREMAX_GET(ctlb);
-	tp->min_len = TFMINPKTSIZE_GET(ctlb);
-	tp->skip_ofst = TFOFFSET_GET(ctla);
-	tp->skip_len = TFLENGTH_GET(ctla);
-	tp->invert = !!(ctla & TFINVERTMATCH);
-	tp->port = TFPORT_GET(ctla);
-
-	ofst = (MPS_TRC_FILTER1_MATCH - MPS_TRC_FILTER0_MATCH) * idx;
-	data_reg = MPS_TRC_FILTER0_MATCH + ofst;
-	mask_reg = MPS_TRC_FILTER0_DONT_CARE + ofst;
-
-	for (i = 0; i < TRACE_LEN / 4; i++, data_reg += 4, mask_reg += 4) {
-		tp->mask[i] = ~t4_read_reg(adap, mask_reg);
-		tp->data[i] = t4_read_reg(adap, data_reg) & tp->mask[i];
-	}
-}
-
-/**
  *	get_mps_bg_map - return the buffer groups associated with a port
  *	@adap: the adapter
  *	@idx: the port index
@@ -2133,52 +1902,6 @@ void t4_get_port_stats(struct adapter *a
 }
 
 /**
- *	t4_get_lb_stats - collect loopback port statistics
- *	@adap: the adapter
- *	@idx: the loopback port index
- *	@p: the stats structure to fill
- *
- *	Return HW statistics for the given loopback port.
- */
-void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p)
-{
-	u32 bgmap = get_mps_bg_map(adap, idx);
-
-#define GET_STAT(name) \
-	t4_read_reg64(adap, PORT_REG(idx, MPS_PORT_STAT_LB_PORT_##name##_L))
-#define GET_STAT_COM(name) t4_read_reg64(adap, MPS_STAT_##name##_L)
-
-	p->octets           = GET_STAT(BYTES);
-	p->frames           = GET_STAT(FRAMES);
-	p->bcast_frames     = GET_STAT(BCAST);
-	p->mcast_frames     = GET_STAT(MCAST);
-	p->ucast_frames     = GET_STAT(UCAST);
-	p->error_frames     = GET_STAT(ERROR);
-
-	p->frames_64        = GET_STAT(64B);
-	p->frames_65_127    = GET_STAT(65B_127B);
-	p->frames_128_255   = GET_STAT(128B_255B);
-	p->frames_256_511   = GET_STAT(256B_511B);
-	p->frames_512_1023  = GET_STAT(512B_1023B);
-	p->frames_1024_1518 = GET_STAT(1024B_1518B);
-	p->frames_1519_max  = GET_STAT(1519B_MAX);
-	p->drop             = t4_read_reg(adap, PORT_REG(idx,
-					  MPS_PORT_STAT_LB_PORT_DROP_FRAMES));
-
-	p->ovflow0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_LB_DROP_FRAME) : 0;
-	p->ovflow1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_LB_DROP_FRAME) : 0;
-	p->ovflow2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_LB_DROP_FRAME) : 0;
-	p->ovflow3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_LB_DROP_FRAME) : 0;
-	p->trunc0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_LB_TRUNC_FRAME) : 0;
-	p->trunc1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_LB_TRUNC_FRAME) : 0;
-	p->trunc2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_LB_TRUNC_FRAME) : 0;
-	p->trunc3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_LB_TRUNC_FRAME) : 0;
-
-#undef GET_STAT
-#undef GET_STAT_COM
-}
-
-/**
  *	t4_wol_magic_enable - enable/disable magic packet WoL
  *	@adap: the adapter
  *	@port: the physical port index
@@ -2584,30 +2307,6 @@ int t4_alloc_vi(struct adapter *adap, un
 }
 
 /**
- *	t4_free_vi - free a virtual interface
- *	@adap: the adapter
- *	@mbox: mailbox to use for the FW command
- *	@pf: the PF owning the VI
- *	@vf: the VF owning the VI
- *	@viid: virtual interface identifiler
- *
- *	Free a previously allocated virtual interface.
- */
-int t4_free_vi(struct adapter *adap, unsigned int mbox, unsigned int pf,
-	       unsigned int vf, unsigned int viid)
-{
-	struct fw_vi_cmd c;
-
-	memset(&c, 0, sizeof(c));
-	c.op_to_vfn = htonl(FW_CMD_OP(FW_VI_CMD) | FW_CMD_REQUEST |
-			    FW_CMD_EXEC | FW_VI_CMD_PFN(pf) |
-			    FW_VI_CMD_VFN(vf));
-	c.alloc_to_len16 = htonl(FW_VI_CMD_FREE | FW_LEN16(c));
-	c.type_viid = htons(FW_VI_CMD_VIID(viid));
-	return t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
-}
-
-/**
  *	t4_set_rxmode - set Rx properties of a virtual interface
  *	@adap: the adapter
  *	@mbox: mailbox to use for the FW command
@@ -2832,37 +2531,6 @@ int t4_identify_port(struct adapter *ada
 	return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
 }
 
-/**
- *	t4_iq_start_stop - enable/disable an ingress queue and its FLs
- *	@adap: the adapter
- *	@mbox: mailbox to use for the FW command
- *	@start: %true to enable the queues, %false to disable them
- *	@pf: the PF owning the queues
- *	@vf: the VF owning the queues
- *	@iqid: ingress queue id
- *	@fl0id: FL0 queue id or 0xffff if no attached FL0
- *	@fl1id: FL1 queue id or 0xffff if no attached FL1
- *
- *	Starts or stops an ingress queue and its associated FLs, if any.
- */
-int t4_iq_start_stop(struct adapter *adap, unsigned int mbox, bool start,
-		     unsigned int pf, unsigned int vf, unsigned int iqid,
-		     unsigned int fl0id, unsigned int fl1id)
-{
-	struct fw_iq_cmd c;
-
-	memset(&c, 0, sizeof(c));
-	c.op_to_vfn = htonl(FW_CMD_OP(FW_IQ_CMD) | FW_CMD_REQUEST |
-			    FW_CMD_EXEC | FW_IQ_CMD_PFN(pf) |
-			    FW_IQ_CMD_VFN(vf));
-	c.alloc_to_len16 = htonl(FW_IQ_CMD_IQSTART(start) |
-				 FW_IQ_CMD_IQSTOP(!start) | FW_LEN16(c));
-	c.iqid = htons(iqid);
-	c.fl0id = htons(fl0id);
-	c.fl1id = htons(fl1id);
-	return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
-}
-
 /**
  *	t4_iq_free - free an ingress queue and its FLs
  *	@adap: the adapter

^ permalink raw reply

* [v2] Remaining BKL users, what to do
From: Arnd Bergmann @ 2010-10-18 15:42 UTC (permalink / raw)
  To: codalist, ksummit-2010-discuss
  Cc: autofs, linux-media, dri-devel, Christoph Hellwig,
	Mikulas Patocka, Trond Myklebust, Petr Vandrovec, Anders Larsen,
	Jan Kara, Evgeniy Dushistov, Ingo Molnar, netdev, Samuel Ortiz,
	Arnaldo Carvalho de Melo, linux-kernel, linux-fsdevel,
	Andrew Hendry, David Miller, Jan Harkes, Bryan Schumaker
In-Reply-To: <201009161632.59210.arnd@arndb.de>

This is a update on the current progress for the BKL removal, reflecting
what is currently in linux-next.

Maybe we can briefly discuss this at the kernel summit to decide if we
want a quick death of the BKL, i.e. fixing/disabling/staging-out the
remaining users in 2.6.38 or rather leave them there indefinitely.

On Thursday 16 September 2010, Arnd Bergmann wrote:
> The big kernel lock is gone from almost all code in linux-next, this is
> the status of what I think will happen to the remaining users:
> 
> drivers/gpu/drm/i810/{i810,i830}_dma.c:
> 	Fixable, but needs someone with the hardware to test. Can probably be
> 	marked CONFIG_BROKEN_ON_SMP if nobody cares.

Still open, no good solution for this.

> drivers/media/video (V4L):
> 	Mauro is working on it, some drivers get moved to staging while the
> 	others get fixed. An easy workaround would be possible by adding
> 	per-driver mutexes, but Mauro wants to it properly by locking all
> 	the right places.

Progressing well, patches are being worked on.

> fs/adfs:
> 	Probably not hard to fix, but needs someone to test it.
> 	adfs has only seen janitorial fixes for the last 5 years.
> 	Do we know of any users?

Nobody replied.

> fs/autofs:
> 	Pretty much dead, replaced by autofs4. I'd suggest moving this
> 	to drivers/staging in 2.6.37 and letting it die there.

Now in staging.

> fs/coda:
> 	Coda seems to have an active community, but not all of their
> 	code is actually part of linux (pioctl!), while the last official
> 	release is missing many of the cleanups that were don in Linux.
> 	Not sure what to do, if someone is interested, the best way might
> 	be a fresh start with a merger of the mainline linux and the
> 	coda.cs.cmu.edu	codebase in drivers/staging.
> 	Just removing the BKL without the Coda community seems like a heap
> 	of pointless work.

Jan Harkes showed interest, looks like this will get fixed eventually,
but probably not in time for 2.6.37.

> fs/freevxfs:
> 	Uses the BKL in readdir and lookup, should be easy to fix. Christoph?

Still waiting for confirmation from Christoph Hellwig that the BKL
is not needed here. I can do the patch to remove it then.

> fs/hpfs:
> 	Looks fixable, if anyone cares. Maybe it's time for retirement in
> 	drivers/staging though. The web page only has a Link to the
> 	linux-2.2 version.

No replies.

> fs/lockd:
> 	Trond writes that he has someone working on BKL removal here.

Bryan Schumaker took care of this, looks like the locking is independent
of the fs/locks.c locking now, although it still uses the BKL internally.

I assume that this will get fixed as well, doesn't seem hard. As long
as lockd uses the BKL, both nfs and nfsd depend on the BKL implicitly.

> fs/locks.c:
> 	Patch is under discussion, blocked by work on fs/lockd currently.

No longer blocked now, both lockd and ceph can deal with this converted
to spinlocks. I will follow up with the final patch once they hit mainline.

> fs/ncpfs:
> 	Should be fixable if Petr still cares about it. Otherwise suggest
> 	moving to drivers/staging if there are no users left.

Fixed by Petr Vandrovec.

> fs/qnx4:
> 	Should be easy to fix, there are only a few places in the code that
> 	use the BKL. Anders?

Anders Larsen volunteered.

> fs/smbfs:
> 	Last I heard this was considered obsolete. Should be move it to
> 	drivers/staging now?

Now in staging.

> fs/udf:
> 	Not completely trivial, but probably necessary to fix. Project web
> 	site is dead, I hope that Jan Kara can be motivated to fix it though.

Jan Kara volunteered to do it.

> fs/ufs:
> 	Evgeniy Dushistov is maintaining this, I hope he can take care of
> 	getting rid of the BKL in UFS.

No replies.

> kernel/trace/blktrace.c:
> 	Should be easy. Ingo? Steven?

Done.

> net/appletalk:
> net/ipx/af_ipx.c:
> net/irda/af_irda.c:
> 	Can probably be saved from retirement in drivers/staging if the
> 	maintainers still care.

Samuel Ortiz fixed irda.

David Miller volunteered to do appletalk and ipx.

> net/x25:
> 	Andrew Hendry has started working on it.

Patches have shown up in -next now, I suppose Andrew will finish it soon.

Out of the remaining modules, I guess i810/i830, adfs, hpfs and ufs might end
up not getting fixed at all, we can either mark them non-SMP or move them
to drivers/staging once all the others are done.

	Arnd

^ permalink raw reply

* Re: [PATCH] bonding: various fixes for bonding, netpoll & netconsole (v3)
From: Neil Horman @ 2010-10-18 15:57 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, bonding-devel, fubar, andy, amwang
In-Reply-To: <20101018.082728.48512103.davem@davemloft.net>

On Mon, Oct 18, 2010 at 08:27:28AM -0700, David Miller wrote:
> From: David Miller <davem@davemloft.net>
> Date: Mon, 18 Oct 2010 08:25:29 -0700 (PDT)
> 
> > From: nhorman@tuxdriver.com
> > Date: Wed, 13 Oct 2010 22:01:48 -0400
> > 
> >> Version 3, taking the following changes into account:
> >  ...
> >> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> > 
> > Applied, thanks Neil.
> 
> This doesn't build with netpoll disable:
> 
> drivers/net/bonding/bond_main.c: In function ‘bond_start_xmit’:
> drivers/net/bonding/bond_main.c:4578: error: expected expression before ‘)’ token
> 
> I'll fix this up but please properly build test your
> changes next time.


I apologize Dave, I thought I had tested with CONFIG_NET_POLL_CONTROLLER turned
off, but apparently it just got re-enabled automatically because I had
CONFIG_NETPOLL on.  I'll check that more carefully in the future.
Neil


P.S. I've got some minor cleanup patches to this series (little things that I
missed) in the next day or so.

Thanks!

Neil

^ permalink raw reply

* Linux 2.6.35/TIPC 2.0 ABI breaking changes [was: TIPC 2.0 and TIPC_SUB_SERVICE]
From: Leandro Lucarella @ 2010-10-18 15:04 UTC (permalink / raw)
  To: Jon Maloy
  Cc: Peter Litov, tipc-discussion@lists.sourceforge.net, davem,
	linux-kernel, netdev
In-Reply-To: <0434463FDA60A94FA978ACA44617682DEE8446A03B@EUSAACMS0702.eamcs.ericsson.se>

Jon Maloy, el  4 de octubre a las 11:08 me escribiste:
> Hi Peter,
> Adding the version as a sockopt is a very is a very good idea. 
> But actually, you can find out the version, and get around the two-binary problem aready now:
> 
> Check if TIPC_SUB_SERVICE is zero. If it is, the version is 2.0,
> otherwise it is pre-2.0, and you should use the TIPC_SUB_SERVICE with
> a value of 1.
> A little hackish, maybe, but it would solve your problem (which is
> temporary anyway) provided you can alter and recompile your code. 
> 
> And, since you are anyway altering the code, you should take the
> opportunity to add the necessary byte-order conversions, since
> TIPC-1.6/7 are forward compatible in that respect.
> 
> The only reason to introduce what Luca is suggesting, compatiblity
> code in the driver itself, is that you wouldn't need recompile your
> old apps.
> lf that is an absolute requirement we could do that, but our initial
> assessment was that most people recompile their code when moving to
> a new kernel. We may be wrong there, of course.

I thought the kernel usually went to great lengths to ensure old
userspace binaries work with newer kernels.

Since this, as you mention, is not hard to do, and does not impose
a penalty on new code, why not do it?

> It is also uncertain whether David M would accept such a change, or if
> he would see it as a way of sneaking back a functionality he already
> threw out.

By the way, this doesn't work at all for the "bindings" I've done to the
D programming language. D is ABI compatible with C, but not source
compatible, so to add TIPC support to D, I had to write all the constant
values again, in a D source file[1].

This means D can't be used to write code that uses TIPC if you target
kernels >= 2.6.35 (unless they write their own bindings, or at least use
a custom TIPC_SUB_SERVICE constant). I could change the TIPC_SUB_SERVICE
value, but then people using older kernels will be screwed. Another
option is to use the version statement (kind of like C's #ifdef):

	version (TIPC_2_0)
		const TIPC_SUB_SERVICE = 0x00;
	else
		const TIPC_SUB_SERVICE = 0x02;

But then, *users* (I mean *end-users* not developers) will need to use
a compiler switch to select for which kernel they would like to compile
their applications, which I find unacceptable.

I think is really very harsh too to force people to recompile their
applications if they want to switch to a newer/older kernel to try
something out.

What I expected is to have something like 2 port names assigned to the
topology services instead of one, TIPC_TOP_SRV which is compatible with
TIPC 1 and marked as deprecated, and TIPC_TOP_SRV2 which only accepts
the TIPC 2.0 standard. Then, nothing of this would have happened.

And I think breaking changes should be discussed (or at least announced)
in this list more thoughtfully before including them in a Linux kernel
release. Is really a shame to be at a point where no matter what is
done, at least a couple of kernel releases will be binary incompatible
with old TIPC applications.


[1] http://www.dsource.org/projects/phobos/browser/trunk/phobos/std/c/linux/tipc.d

PS: Since this is David Miller's call, I'm Cc-ing him (and other kernel
    mailing lists), as it makes no sense to speculate about what he
    thinks if we can just ask him.

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
I'll take a quiet life,
a handshake of carbon monoxide,
with no alarms and no surprises,
no alarms and no surprises.

^ permalink raw reply

* Re: 2.6.36-rc7: net/bridge causes temporary network I/O lockups [2]
From: Herbert Xu @ 2010-10-18 16:16 UTC (permalink / raw)
  To: Patrick Ringl; +Cc: netdev, linux-kernel, bridge
In-Reply-To: <4CB9EBC3.4070905@freenet.de>

On Sat, Oct 16, 2010 at 08:15:31PM +0200, Patrick Ringl wrote:
> Hi,
>
> okay I narrowed down the issue. I watched all function calls of the  
> 'bridge' module with the help of a small systemtap probe of mine. I  
> first traced a timespan where the issue did not occur, then one where it  
> did and composed an intersection of these two:

I can't reproduce this problem here so I'll need your help to
track it down.

Can you see if you can relate the lock-ups to specific events
such as a particular packet being sent through the bridge?

If we can recreate the problem on demand that that helps us to
find the root cause.

You mentioned that you took packet dumps on the system.  If you
can show us the packets through the bridge and its ports when
the problem occurs that would be great.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply

* Re: [v2] Remaining BKL users, what to do
From: Christoph Hellwig @ 2010-10-18 16:19 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: codalist, ksummit-2010-discuss, autofs, linux-media, dri-devel,
	Christoph Hellwig, Mikulas Patocka, Trond Myklebust,
	Petr Vandrovec, Anders Larsen, Jan Kara, Evgeniy Dushistov,
	Ingo Molnar, netdev, Samuel Ortiz, Arnaldo Carvalho de Melo,
	linux-kernel, linux-fsdevel, Andrew Hendry, David Miller,
	Jan Harkes, Bryan Schumaker
In-Reply-To: <201010181742.06678.arnd@arndb.de>

Before we get into all these fringe drivers:

 - I've not seen any progrss on ->get_sb BKL removal for a while
 - locks.c is probably a higher priorit, too.

^ permalink raw reply

* Re: [Bridge] EAPOL bridging
From: Stephen Hemminger @ 2010-10-18 16:38 UTC (permalink / raw)
  To: Benjamin Poirier; +Cc: bridge, netdev, linux-kernel
In-Reply-To: <4CBB3B24.2000106@gmail.com>

On Sun, 17 Oct 2010 14:06:28 -0400
Benjamin Poirier <benjamin.poirier@gmail.com> wrote:

> Hello,
> 
> I have some trouble bridging EAPOL frames. I'd like to do this to allow 
> wired 802.1x authentication from within a kvm virtual machine. I have 
> the following setup:
> 
> kvm -- tap0 -- br0 -- eth1 -- 802.1x authenticator (switch) -- more network
> 
> and it doesn't work. I've added a few logging rules to ebtables. I only 
> see an EAPOL frame going through the INPUT chain of tap0. It seems to be 
> dropped by the bridge. The EAPOL frame is an ethernet link local 
> multicast frame with destination address 01-80-C2-00-00-03, "IEEE Std 
> 802.1X PAE address".
> 
> I've looked at http://standards.ieee.org/regauth/groupmac/tutorial.html, 
> which says that frames with a destination in the range 01-80-C2-00-00-00 
> to 01-80-C2-00-00-0F should not be forwarded by standard conformant 
> bridges. I've also looked at net/bridge/br_input.c and br_handle_frame() 
> seems quite intent on "bending" the standard when STP is disabled, but 
> only for 01-80-C2-00-00-00. However there are more applications that use 
> similar addresses, EAPOL included: 
> http://standards.ieee.org/regauth/groupmac/Standard_Group_MAC_Address_assignments.pdf
> 
> Given the current state of affairs, would it be acceptable to make the 
> code more permissive by forwarding all the range of reserved group 
> addresses when STP is disabled? If not, what would be the way to go 
> about enabling 802.1x authentication from within a virtual machine?
> 
> BTW, it seems this issue has been raised before, 
> https://lists.linux-foundation.org/pipermail/bridge/2007-November/005629.html
> with the conclusion that
> > Despite what the standards say, many users are using bridging code for invisible
> > firewalls etc, and in those cases they want STP and EAPOL frames to be forwarded.

I would just take off the last byte (dest check).



-- 

^ permalink raw reply

* Re: [PATCH net-next] sfc: make functions static
From: Ben Hutchings @ 2010-10-18 17:05 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: David Miller, Steve Hodgson, Solarflare linux maintainers, netdev
In-Reply-To: <20101018082731.36cd65e4@nehalam>

On Mon, 2010-10-18 at 08:27 -0700, Stephen Hemminger wrote:
> Make local functions and variable static. Do some rearrangement
> of the string table stuff to put it where it gets used.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

Acked-by: Ben Hutchings <bhutchings@solarflare.com>

We might have to change some of these back in future, but I suppose
there is no harm in making them static now.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


^ permalink raw reply

* Re: [v2] Remaining BKL users, what to do
From: Arnd Bergmann @ 2010-10-18 17:38 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: codalist, ksummit-2010-discuss, autofs, linux-media, dri-devel,
	Mikulas Patocka, Trond Myklebust, Petr Vandrovec, Anders Larsen,
	Jan Kara, Evgeniy Dushistov, Ingo Molnar, netdev, Samuel Ortiz,
	Arnaldo Carvalho de Melo, linux-kernel, linux-fsdevel,
	Andrew Hendry, David Miller, Jan Harkes, Bryan Schumaker
In-Reply-To: <20101018161924.GA9571@infradead.org>

On Monday 18 October 2010 18:19:24 Christoph Hellwig wrote:
> Before we get into all these fringe drivers:
> 
>  - I've not seen any progrss on ->get_sb BKL removal for a while

Not sure what you mean. Jan Blunck did the pushdown into get_sb
last year, which is included into linux-next through my bkl/vfs
tree. Subsequent patches remove it from most file systems along with
the other BKL uses in them. If you like, I can post the series
once more, but it has been posted a few times now.

>  - locks.c is probably a higher priorit, too.

As mentioned in the list, I expect the trivial final patch to
be applied in 2.6.37-rc1 after Linus has pulled the trees that
this depends on (bkl/vfs, nfs, nfsd, ceph), see below.

This is currently not in -next because of the prerequisites.

	Arnd
---

diff --git a/fs/Kconfig b/fs/Kconfig
index c386a9f..25ce2dc 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -50,7 +50,6 @@ endif # BLOCK
 config FILE_LOCKING
 	bool "Enable POSIX file locking API" if EMBEDDED
 	default y
-	select BKL
 	help
 	  This option enables standard file locking support, required
           for filesystems like NFS and for the flock() system
diff --git a/fs/locks.c b/fs/locks.c
index 8b2b6ad..02b6e0e 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -142,6 +142,7 @@ int lease_break_time = 45;
 
 static LIST_HEAD(file_lock_list);
 static LIST_HEAD(blocked_list);
+static DEFINE_SPINLOCK(file_lock_lock);
 
 /*
  * Protects the two list heads above, plus the inode->i_flock list
@@ -149,13 +150,13 @@ static LIST_HEAD(blocked_list);
  */
 void lock_flocks(void)
 {
-	lock_kernel();
+	spin_lock(&file_lock_lock);
 }
 EXPORT_SYMBOL_GPL(lock_flocks);
 
 void unlock_flocks(void)
 {
-	unlock_kernel();
+	spin_unlock(&file_lock_lock);
 }
 EXPORT_SYMBOL_GPL(unlock_flocks);
 

^ permalink raw reply related

* Re: [Patch] Limit sysctl_tcp_mem and sysctl_udp_mem initializers to prevent integer overflows.
From: Robin Holt @ 2010-10-18 17:43 UTC (permalink / raw)
  To: David Miller
  Cc: holt, w, linux-kernel, netdev, kuznet, pekkas, jmorris, yoshfuji,
	kaber
In-Reply-To: <20101005.145032.25126909.davem@davemloft.net>

On Tue, Oct 05, 2010 at 02:50:32PM -0700, David Miller wrote:
> From: Robin Holt <holt@sgi.com>
> Date: Sat, 02 Oct 2010 06:24:06 -0500
> 
> > Subject: [Patch] Limit sysctl_tcp_mem and sysctl_udp_mem initializers to prevent integer overflows.
> > 
> > On a 16TB x86_64 machine, sysctl_tcp_mem[2], sysctl_udp_mem[2], and
> > sysctl_sctp_mem[2] can integer overflow.  Set limit such that they are
> > maximized without overflowing.
> > 
> > Signed-off-by: Robin Holt <holt@sgi.com>
> 
> Robin please resubmit this with the SCTP bits included.

David,

I did not mean to blow you off.  I was not going to resubmit because
Eric's patch is the preferred direction.  I had been given an indication
that my patch was preferred, but that indicator changed.

Robin

^ permalink raw reply

* Re: [Patch] Limit sysctl_tcp_mem and sysctl_udp_mem initializers to prevent integer overflows.
From: Eric Dumazet @ 2010-10-18 17:52 UTC (permalink / raw)
  To: Robin Holt
  Cc: David Miller, w, linux-kernel, netdev, kuznet, pekkas, jmorris,
	yoshfuji, kaber
In-Reply-To: <20101018174339.GC14068@sgi.com>

Le lundi 18 octobre 2010 à 12:43 -0500, Robin Holt a écrit :
> On Tue, Oct 05, 2010 at 02:50:32PM -0700, David Miller wrote:
> > From: Robin Holt <holt@sgi.com>
> > Date: Sat, 02 Oct 2010 06:24:06 -0500
> > 
> > > Subject: [Patch] Limit sysctl_tcp_mem and sysctl_udp_mem initializers to prevent integer overflows.
> > > 
> > > On a 16TB x86_64 machine, sysctl_tcp_mem[2], sysctl_udp_mem[2], and
> > > sysctl_sctp_mem[2] can integer overflow.  Set limit such that they are
> > > maximized without overflowing.
> > > 
> > > Signed-off-by: Robin Holt <holt@sgi.com>
> > 
> > Robin please resubmit this with the SCTP bits included.
> 
> David,
> 
> I did not mean to blow you off.  I was not going to resubmit because
> Eric's patch is the preferred direction.  I had been given an indication
> that my patch was preferred, but that indicator changed.
> 

Maybe there is some misunderstanding.

My patch was for net-next kernels (not before 2.6.37), while yours was
applicable to previous kernels.

^ permalink raw reply

* [PATCH 1/3] net: fail alloc_netdev_mq if queue count < 1
From: Tom Herbert @ 2010-10-18 18:02 UTC (permalink / raw)
  To: davem, netdev; +Cc: eric.dumazet, bhutchings

In alloc_netdev_mq fail if requested queue_count < 1.

Signed-off-by: Tom Herbert <therbert@google.com>
---
 net/core/dev.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 04972a4..76db105 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5511,6 +5511,12 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
 
 	BUG_ON(strlen(name) >= sizeof(dev->name));
 
+	if (queue_count < 0) {
+		printk(KERN_ERR "alloc_netdev: Unable to allocate device "
+		       "with zero queues.\n");
+		return NULL;
+	}
+
 	alloc_size = sizeof(struct net_device);
 	if (sizeof_priv) {
 		/* ensure 32-byte alignment of private area */
-- 
1.7.1


^ permalink raw reply related

* [PATCH 2/3] net: cleanups in RX queue allocation
From: Tom Herbert @ 2010-10-18 18:02 UTC (permalink / raw)
  To: davem, netdev; +Cc: eric.dumazet, bhutchings

Clean up in RX queue allocation.  In netif_set_real_num_rx_queues
return error on attempt to set zero queues, and set
dev->num_rx_queues if device not registered (similar to TX
allocation).  In netif_alloc_rx_queues, do BUG_ON if queue
count is zero.

Signed-off-by: Tom Herbert <therbert@google.com>
---
 net/core/dev.c |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 76db105..77b860d 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1583,6 +1583,9 @@ int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq)
 {
 	int rc;
 
+	if (rxq < 1)
+		return -EINVAL;
+
 	if (dev->reg_state == NETREG_REGISTERED) {
 		ASSERT_RTNL();
 
@@ -1593,7 +1596,8 @@ int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq)
 						  rxq);
 		if (rc)
 			return rc;
-	}
+	} else
+		dev->num_rx_queues = rxq;
 
 	dev->real_num_rx_queues = rxq;
 	return 0;
@@ -5013,25 +5017,23 @@ static int netif_alloc_rx_queues(struct net_device *dev)
 {
 #ifdef CONFIG_RPS
 	unsigned int i, count = dev->num_rx_queues;
+	struct netdev_rx_queue *rx;
 
-	if (count) {
-		struct netdev_rx_queue *rx;
-
-		rx = kcalloc(count, sizeof(struct netdev_rx_queue), GFP_KERNEL);
-		if (!rx) {
-			pr_err("netdev: Unable to allocate %u rx queues.\n",
-			       count);
-			return -ENOMEM;
-		}
-		dev->_rx = rx;
+	BUG_ON(count < 1);
 
-		/*
-		 * Set a pointer to first element in the array which holds the
-		 * reference count.
-		 */
-		for (i = 0; i < count; i++)
-			rx[i].first = rx;
+	rx = kcalloc(count, sizeof(struct netdev_rx_queue), GFP_KERNEL);
+	if (!rx) {
+		pr_err("netdev: Unable to allocate %u rx queues.\n", count);
+		return -ENOMEM;
 	}
+	dev->_rx = rx;
+
+	/*
+	 * Set a pointer to first element in the array which holds the
+	 * reference count.
+	 */
+	for (i = 0; i < count; i++)
+		rx[i].first = rx;
 #endif
 	return 0;
 }
-- 
1.7.1


^ permalink raw reply related

* [PATCH 0/3] net: RX and TX queue allocation cleanup
From: Tom Herbert @ 2010-10-18 18:02 UTC (permalink / raw)
  To: davem, netdev; +Cc: eric.dumazet, bhutchings

Move TX queue allocation to register_netdevice.  Enforce
alloc_netdev_mq & netif_set_real_num_[rt]x_queues netif_alloc_rx_queues
are called with at least one queue to allocate.

^ permalink raw reply

* [PATCH 3/3] net: allocate tx queues in register_netdevice
From: Tom Herbert @ 2010-10-18 18:02 UTC (permalink / raw)
  To: davem, netdev; +Cc: eric.dumazet, bhutchings

This patch introduces netif_alloc_netdev_queues which is called from
register_device instead of alloc_netdev_mq.  This makes TX queue
allocation symmetric with RX allocation similarly allows drivers to
change dev->num_tx_queues after allocating netdev and before
registering it.  Also, queue locks allocation is done in
netdev_init_one_queue.

Signed-off-by: Tom Herbert <therbert@google.com>
---
 include/linux/netdevice.h |    4 +-
 net/core/dev.c            |  112 +++++++++++++++++++++++----------------------
 2 files changed, 60 insertions(+), 56 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 14fbb04..880d565 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1696,8 +1696,8 @@ static inline int netif_is_multiqueue(const struct net_device *dev)
 	return dev->num_tx_queues > 1;
 }
 
-extern void netif_set_real_num_tx_queues(struct net_device *dev,
-					 unsigned int txq);
+extern int netif_set_real_num_tx_queues(struct net_device *dev,
+					unsigned int txq);
 
 #ifdef CONFIG_RPS
 extern int netif_set_real_num_rx_queues(struct net_device *dev,
diff --git a/net/core/dev.c b/net/core/dev.c
index 77b860d..c7b8d5a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1553,18 +1553,24 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
  * Routine to help set real_num_tx_queues. To avoid skbs mapped to queues
  * greater then real_num_tx_queues stale skbs on the qdisc must be flushed.
  */
-void netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
+int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
 {
-	unsigned int real_num = dev->real_num_tx_queues;
+	if (txq < 1)
+		return -EINVAL;
 
-	if (unlikely(txq > dev->num_tx_queues))
-		;
-	else if (txq > real_num)
-		dev->real_num_tx_queues = txq;
-	else if (txq < real_num) {
-		dev->real_num_tx_queues = txq;
-		qdisc_reset_all_tx_gt(dev, txq);
-	}
+	if (dev->reg_state == NETREG_REGISTERED) {
+		ASSERT_RTNL();
+
+		if (txq > dev->num_tx_queues)
+			return -EINVAL;
+
+		if (txq < dev->real_num_tx_queues)
+			qdisc_reset_all_tx_gt(dev, txq);
+	} else
+		dev->num_tx_queues = txq;
+
+	dev->real_num_tx_queues = txq;
+	return 0;
 }
 EXPORT_SYMBOL(netif_set_real_num_tx_queues);
 
@@ -4932,20 +4938,6 @@ static void rollback_registered(struct net_device *dev)
 	rollback_registered_many(&single);
 }
 
-static void __netdev_init_queue_locks_one(struct net_device *dev,
-					  struct netdev_queue *dev_queue,
-					  void *_unused)
-{
-	spin_lock_init(&dev_queue->_xmit_lock);
-	netdev_set_xmit_lockdep_class(&dev_queue->_xmit_lock, dev->type);
-	dev_queue->xmit_lock_owner = -1;
-}
-
-static void netdev_init_queue_locks(struct net_device *dev)
-{
-	netdev_for_each_tx_queue(dev, __netdev_init_queue_locks_one, NULL);
-}
-
 unsigned long netdev_fix_features(unsigned long features, const char *name)
 {
 	/* Fix illegal SG+CSUM combinations. */
@@ -5038,6 +5030,41 @@ static int netif_alloc_rx_queues(struct net_device *dev)
 	return 0;
 }
 
+static int netif_alloc_netdev_queues(struct net_device *dev)
+{
+	unsigned int count = dev->num_tx_queues;
+	struct netdev_queue *tx;
+
+	BUG_ON(count < 1);
+
+	tx = kcalloc(count, sizeof(struct netdev_queue), GFP_KERNEL);
+	if (!tx) {
+		pr_err("netdev: Unable to allocate %u tx queues.\n",
+		       count);
+			return -ENOMEM;
+	}
+	dev->_tx = tx;
+	return 0;
+}
+
+static void netdev_init_one_queue(struct net_device *dev,
+				  struct netdev_queue *queue,
+				  void *_unused)
+{
+	queue->dev = dev;
+
+	/* Initialize queue lock */
+	spin_lock_init(&queue->_xmit_lock);
+	netdev_set_xmit_lockdep_class(&queue->_xmit_lock, dev->type);
+	queue->xmit_lock_owner = -1;
+}
+
+static void netdev_init_queues(struct net_device *dev)
+{
+	netdev_for_each_tx_queue(dev, netdev_init_one_queue, NULL);
+	spin_lock_init(&dev->tx_global_lock);
+}
+
 /**
  *	register_netdevice	- register a network device
  *	@dev: device to register
@@ -5071,7 +5098,6 @@ int register_netdevice(struct net_device *dev)
 
 	spin_lock_init(&dev->addr_list_lock);
 	netdev_set_addr_lockdep_class(dev);
-	netdev_init_queue_locks(dev);
 
 	dev->iflink = -1;
 
@@ -5079,6 +5105,12 @@ int register_netdevice(struct net_device *dev)
 	if (ret)
 		goto out;
 
+	ret = netif_alloc_netdev_queues(dev);
+	if (ret)
+		goto out;
+
+	netdev_init_queues(dev);
+
 	/* Init, if this function is available */
 	if (dev->netdev_ops->ndo_init) {
 		ret = dev->netdev_ops->ndo_init(dev);
@@ -5460,19 +5492,6 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
 }
 EXPORT_SYMBOL(dev_get_stats);
 
-static void netdev_init_one_queue(struct net_device *dev,
-				  struct netdev_queue *queue,
-				  void *_unused)
-{
-	queue->dev = dev;
-}
-
-static void netdev_init_queues(struct net_device *dev)
-{
-	netdev_for_each_tx_queue(dev, netdev_init_one_queue, NULL);
-	spin_lock_init(&dev->tx_global_lock);
-}
-
 struct netdev_queue *dev_ingress_queue_create(struct net_device *dev)
 {
 	struct netdev_queue *queue = dev_ingress_queue(dev);
@@ -5484,7 +5503,6 @@ struct netdev_queue *dev_ingress_queue_create(struct net_device *dev)
 	if (!queue)
 		return NULL;
 	netdev_init_one_queue(dev, queue, NULL);
-	__netdev_init_queue_locks_one(dev, queue, NULL);
 	queue->qdisc = &noop_qdisc;
 	queue->qdisc_sleeping = &noop_qdisc;
 	rcu_assign_pointer(dev->ingress_queue, queue);
@@ -5506,7 +5524,6 @@ struct netdev_queue *dev_ingress_queue_create(struct net_device *dev)
 struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
 		void (*setup)(struct net_device *), unsigned int queue_count)
 {
-	struct netdev_queue *tx;
 	struct net_device *dev;
 	size_t alloc_size;
 	struct net_device *p;
@@ -5534,20 +5551,12 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
 		return NULL;
 	}
 
-	tx = kcalloc(queue_count, sizeof(struct netdev_queue), GFP_KERNEL);
-	if (!tx) {
-		printk(KERN_ERR "alloc_netdev: Unable to allocate "
-		       "tx qdiscs.\n");
-		goto free_p;
-	}
-
-
 	dev = PTR_ALIGN(p, NETDEV_ALIGN);
 	dev->padded = (char *)dev - (char *)p;
 
 	dev->pcpu_refcnt = alloc_percpu(int);
 	if (!dev->pcpu_refcnt)
-		goto free_tx;
+		goto free_p;
 
 	if (dev_addr_init(dev))
 		goto free_pcpu;
@@ -5557,7 +5566,6 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
 
 	dev_net_set(dev, &init_net);
 
-	dev->_tx = tx;
 	dev->num_tx_queues = queue_count;
 	dev->real_num_tx_queues = queue_count;
 
@@ -5568,8 +5576,6 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
 
 	dev->gso_max_size = GSO_MAX_SIZE;
 
-	netdev_init_queues(dev);
-
 	INIT_LIST_HEAD(&dev->ethtool_ntuple_list.list);
 	dev->ethtool_ntuple_list.count = 0;
 	INIT_LIST_HEAD(&dev->napi_list);
@@ -5580,8 +5586,6 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
 	strcpy(dev->name, name);
 	return dev;
 
-free_tx:
-	kfree(tx);
 free_pcpu:
 	free_percpu(dev->pcpu_refcnt);
 free_p:
-- 
1.7.1


^ permalink raw reply related

* Re: [Patch] Limit sysctl_tcp_mem and sysctl_udp_mem initializers to prevent integer overflows.
From: Robin Holt @ 2010-10-18 18:34 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Robin Holt, David Miller, w, linux-kernel, netdev, kuznet, pekkas,
	jmorris, yoshfuji, kaber
In-Reply-To: <1287424348.2359.1.camel@edumazet-laptop>

On Mon, Oct 18, 2010 at 07:52:28PM +0200, Eric Dumazet wrote:
> Le lundi 18 octobre 2010 à 12:43 -0500, Robin Holt a écrit :
> > On Tue, Oct 05, 2010 at 02:50:32PM -0700, David Miller wrote:
> > > From: Robin Holt <holt@sgi.com>
> > > Date: Sat, 02 Oct 2010 06:24:06 -0500
> > > 
> > > > Subject: [Patch] Limit sysctl_tcp_mem and sysctl_udp_mem initializers to prevent integer overflows.
> > > > 
> > > > On a 16TB x86_64 machine, sysctl_tcp_mem[2], sysctl_udp_mem[2], and
> > > > sysctl_sctp_mem[2] can integer overflow.  Set limit such that they are
> > > > maximized without overflowing.
> > > > 
> > > > Signed-off-by: Robin Holt <holt@sgi.com>
> > > 
> > > Robin please resubmit this with the SCTP bits included.
> > 
> > David,
> > 
> > I did not mean to blow you off.  I was not going to resubmit because
> > Eric's patch is the preferred direction.  I had been given an indication
> > that my patch was preferred, but that indicator changed.
> > 
> 
> Maybe there is some misunderstanding.
> 
> My patch was for net-next kernels (not before 2.6.37), while yours was
> applicable to previous kernels.

Ah.  I will resubmit then.

Sorry for the confusion,
Robin

^ permalink raw reply

* [PATCH] ethtool: add get permanent address option
From: Stephen Hemminger @ 2010-10-18 18:41 UTC (permalink / raw)
  To: Jeff Garzik, Jeff Garzik, netdev

Add command level support for showing permanent address.
The ioctl has been around for a long time but there was
no option to display it.

Note: MAX_ADDR_LEN is defined in netdevice.h but including
netdevice.h leads to multiple definition errors with if.h.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

---
 ethtool.8 |    6 ++++++
 ethtool.c |   36 +++++++++++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 1 deletions(-)

diff --git a/ethtool.8 b/ethtool.8
index 3ca403c..84d5cc0 100644
--- a/ethtool.8
+++ b/ethtool.8
@@ -176,6 +176,9 @@ ethtool \- Display or change ethernet card settings
 .I ethX
 .RI [ N ]
 
+.B ethtool \-P|\-\-show-permaddr
+.I ethX
+
 .B ethtool \-r|\-\-negotiate
 .I ethX
 
@@ -388,6 +391,9 @@ blinking one or more LEDs on the specific ethernet port.
 .B N
 Length of time to perform phys-id, in seconds.
 .TP
+.B \-P \-\-show-permaddr
+Queries the specified ethernet device for permanent hardware address.
+.TP
 .B \-r \-\-negotiate
 Restarts auto-negotiation on the specified ethernet device, if
 auto-negotiation is enabled.
diff --git a/ethtool.c b/ethtool.c
index 6b2b7c8..845e65d 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -51,6 +51,9 @@
 #ifndef SIOCETHTOOL
 #define SIOCETHTOOL     0x8946
 #endif
+#ifndef MAX_ADDR_LEN
+#define MAX_ADDR_LEN	32
+#endif
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 #endif
@@ -107,6 +110,8 @@ static int do_srxfhindir(int fd, struct ifreq *ifr);
 static int do_srxntuple(int fd, struct ifreq *ifr);
 static int do_grxntuple(int fd, struct ifreq *ifr);
 static int do_flash(int fd, struct ifreq *ifr);
+static int do_permaddr(int fd, struct ifreq *ifr);
+
 static int send_ioctl(int fd, struct ifreq *ifr);
 
 static enum {
@@ -136,6 +141,7 @@ static enum {
 	MODE_SNTUPLE,
 	MODE_GNTUPLE,
 	MODE_FLASHDEV,
+	MODE_PERMADDR,
 } mode = MODE_GSET;
 
 static struct option {
@@ -247,6 +253,8 @@ static struct option {
 		"action <queue or drop>\n" },
     { "-u", "--show-ntuple", MODE_GNTUPLE,
 		"Get Rx ntuple filters and actions\n" },
+    { "-P", "--show-permaddr", MODE_PERMADDR,
+      		"Show permanent hardware address" },
     { "-h", "--help", MODE_HELP, "Show this help" },
     {}
 };
@@ -750,7 +758,8 @@ static void parse_cmdline(int argc, char **argp)
 			    (mode == MODE_SNTUPLE) ||
 			    (mode == MODE_GNTUPLE) ||
 			    (mode == MODE_PHYS_ID) ||
-			    (mode == MODE_FLASHDEV)) {
+			    (mode == MODE_FLASHDEV) |
+			    (mode == MODE_PERMADDR)) {
 				devname = argp[i];
 				break;
 			}
@@ -1868,6 +1877,8 @@ static int doit(void)
 		return do_grxntuple(fd, &ifr);
 	} else if (mode == MODE_FLASHDEV) {
 		return do_flash(fd, &ifr);
+	} else if (mode == MODE_PERMADDR) {
+		return do_permaddr(fd, &ifr);
 	}
 
 	return 69;
@@ -2950,6 +2961,29 @@ static int do_flash(int fd, struct ifreq *ifr)
 	return err;
 }
 
+static int do_permaddr(int fd, struct ifreq *ifr)
+{
+	int i, err;
+	struct ethtool_perm_addr *epaddr;
+
+	epaddr = malloc(sizeof(struct ethtool_perm_addr) + MAX_ADDR_LEN);
+	epaddr->cmd = ETHTOOL_GPERMADDR;
+	epaddr->size = MAX_ADDR_LEN;
+	ifr->ifr_data = (caddr_t)epaddr;
+
+	err = send_ioctl(fd, ifr);
+	if (err < 0)
+		perror("Cannot read permanent address\n");
+	else {
+		printf("Permanent address:");
+		for (i = 0; i < epaddr->size; i++)
+			printf("%c%02x", (i == 0) ? ' ' : ':',
+			       epaddr->data[i]);
+		printf("\n");
+	}
+	return err;
+}
+
 static int do_srxntuple(int fd, struct ifreq *ifr)
 {
 	int err;
-- 
1.7.1


^ permalink raw reply related

* Re: [Ksummit-2010-discuss] [v2] Remaining BKL users, what to do
From: Greg KH @ 2010-10-18 18:43 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: codalist, ksummit-2010-discuss, autofs, Jan Harkes, Samuel Ortiz,
	Jan Kara, Arnaldo Carvalho de Melo, netdev, Anders Larsen,
	linux-kernel, dri-devel, Bryan Schumaker, Christoph Hellwig,
	Petr Vandrovec, Mikulas Patocka, linux-fsdevel, Evgeniy Dushistov,
	Ingo Molnar, Andrew Hendry, linux-media
In-Reply-To: <201010181742.06678.arnd@arndb.de>

On Mon, Oct 18, 2010 at 05:42:06PM +0200, Arnd Bergmann wrote:
> 
> Out of the remaining modules, I guess i810/i830, adfs, hpfs and ufs might end
> up not getting fixed at all, we can either mark them non-SMP or move them
> to drivers/staging once all the others are done.

I recommend moving them to staging, and then retire them from there if
no one steps up to maintain them.

thanks,

greg k-h

^ permalink raw reply

* Re: [PATCH] vmxnet3: remove set_flag_le{16,64} functions
From: Harvey Harrison @ 2010-10-18 18:44 UTC (permalink / raw)
  To: Shreyas Bhatewara; +Cc: netdev@vger.kernel.org, shemminger@vyatta.com
In-Reply-To: <89E2752CFA8EC044846EB8499819134102BD7E1856@EXCH-MBX-4.vmware.com>

On Sat, Oct 16, 2010 at 8:57 AM, Shreyas Bhatewara
<sbhatewara@vmware.com> wrote:
> This hunk is wrong, UPT1_F_RXVLAN should be reset here.
>
> I fail to understand why set/reset functions were not good enough and why this opencoding is required. I agree with your earlier suggestion about replacing two conversions with *data |= cpu_to_le16(flag); though.
>
>

There's nothing really _wrong_ with them, they are a bit special-case,
and they are incomplete in that there is only 16/64 and
no 32 bit version.  And the naming is usually set/clear rather than set/reset.

That, and they are used so infrequently, why not just define the
constants as little endian and then it's just
use regular bitwise math which is common everywhere in networking?
Then others reading your driver don't have
to go look at a special-case set/reset function...it's just or'ing a flag.

I'll send a patch this evening so you can see what it would look like.

Harvey

^ permalink raw reply

* Re: Linux 2.6.35/TIPC 2.0 ABI breaking changes [was: TIPC 2.0 and TIPC_SUB_SERVICE]
From: Leandro Lucarella @ 2010-10-18 18:46 UTC (permalink / raw)
  To: Jon Maloy
  Cc: davem, netdev, tipc-discussion@lists.sourceforge.net,
	linux-kernel
In-Reply-To: <20101018150422.GV8781@llucax.com.ar>

Leandro Lucarella, el 18 de octubre a las 12:04 me escribiste:
> This means D can't be used to write code that uses TIPC if you target
> kernels >= 2.6.35 (unless they write their own bindings, or at least use
> a custom TIPC_SUB_SERVICE constant). I could change the TIPC_SUB_SERVICE
> value, but then people using older kernels will be screwed. Another
> option is to use the version statement (kind of like C's #ifdef):
> 
> 	version (TIPC_2_0)
> 		const TIPC_SUB_SERVICE = 0x00;
> 	else
> 		const TIPC_SUB_SERVICE = 0x02;

I keep finding problems with this change. Another, no D-related, problem
with this change is old code could be silently (and very subtly) broken
if they check for TIPC_SUB_SERVICE as a flag with something like:

	if (s.filter & TIPC_SUB_SERVICE)
		/* do something */

Because TIPC_SUB_SERVICE has changed its semantics, not just its value,
and the new value (0x00) will give you always 0 in that test. This one
is really tricky, because the application code will fail silently, there
will be no dmesg indication of a failure, nor the connection to the
topology service be closed. You might get a compiler warning if you're
lucky.

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Novocaine for the soul
you better give me something
to fill the hole
before I sputter out

------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev

^ permalink raw reply

* Re: [PATCH] ethtool: add get permanent address option
From: Ben Hutchings @ 2010-10-18 19:52 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Jeff Garzik, netdev
In-Reply-To: <20101018114139.71073a40@nehalam>

On Mon, 2010-10-18 at 11:41 -0700, Stephen Hemminger wrote:
> Add command level support for showing permanent address.
> The ioctl has been around for a long time but there was
> no option to display it.
> 
> Note: MAX_ADDR_LEN is defined in netdevice.h but including
> netdevice.h leads to multiple definition errors with if.h.
[...]
> @@ -2950,6 +2961,29 @@ static int do_flash(int fd, struct ifreq *ifr)
>  	return err;
>  }
>  
> +static int do_permaddr(int fd, struct ifreq *ifr)
> +{
> +	int i, err;
> +	struct ethtool_perm_addr *epaddr;
> +
> +	epaddr = malloc(sizeof(struct ethtool_perm_addr) + MAX_ADDR_LEN);
> +	epaddr->cmd = ETHTOOL_GPERMADDR;
> +	epaddr->size = MAX_ADDR_LEN;
> +	ifr->ifr_data = (caddr_t)epaddr;
> +
> +	err = send_ioctl(fd, ifr);
> +	if (err < 0)
> +		perror("Cannot read permanent address\n");
[...]

Don't include a newline in the argument to perror().

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


^ permalink raw reply

* Re: [RFC PATCH 1/7] ebtables: Allow filtering of hardware accelerated vlan frames.
From: Ben Hutchings @ 2010-10-18 19:58 UTC (permalink / raw)
  To: Jesse Gross; +Cc: davem, netdev
In-Reply-To: <1287000177-7126-2-git-send-email-jesse@nicira.com>

On Wed, 2010-10-13 at 13:02 -0700, Jesse Gross wrote:
> An upcoming commit will allow packets with hardware vlan acceleration
> information to be passed though more parts of the network stack, including
> packets trunked through the bridge.  This adds support for matching and
> filtering those packets through ebtables.
> 
> Signed-off-by: Jesse Gross <jesse@nicira.com>
> ---
>  net/bridge/br_netfilter.c       |   16 +++++++++-------
>  net/bridge/netfilter/ebt_vlan.c |   38 +++++++++++++++++++++++---------------
>  net/bridge/netfilter/ebtables.c |   15 +++++++++++----
>  3 files changed, 43 insertions(+), 26 deletions(-)
> 
> diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
> index 7f9ce96..d6a4fec 100644
> --- a/net/bridge/br_netfilter.c
> +++ b/net/bridge/br_netfilter.c
> @@ -64,22 +64,24 @@ static int brnf_filter_pppoe_tagged __read_mostly = 0;
>  
>  static inline __be16 vlan_proto(const struct sk_buff *skb)
>  {
> -	return vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
> +	if (skb->protocol == htons(ETH_P_8021Q))
> +		return vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
> +	else if (vlan_tx_tag_present(skb))
> +		return skb->protocol;

If there are two levels of VLAN-encapsulation, this will return either
the inner or outer tag depending on whether VLAN acceleration is being
used.  It should behave consistently.

> +	else
> +		return 0;
>  }
>  
>  #define IS_VLAN_IP(skb) \
> -	(skb->protocol == htons(ETH_P_8021Q) && \
> -	 vlan_proto(skb) == htons(ETH_P_IP) && 	\
> +	(vlan_proto(skb) == htons(ETH_P_IP) && 	\
>  	 brnf_filter_vlan_tagged)
>  
>  #define IS_VLAN_IPV6(skb) \
> -	(skb->protocol == htons(ETH_P_8021Q) && \
> -	 vlan_proto(skb) == htons(ETH_P_IPV6) &&\
> +	(vlan_proto(skb) == htons(ETH_P_IPV6) &&\
>  	 brnf_filter_vlan_tagged)
>  
>  #define IS_VLAN_ARP(skb) \
> -	(skb->protocol == htons(ETH_P_8021Q) &&	\
> -	 vlan_proto(skb) == htons(ETH_P_ARP) &&	\
> +	(vlan_proto(skb) == htons(ETH_P_ARP) &&	\
>  	 brnf_filter_vlan_tagged)
>  
>  static inline __be16 pppoe_proto(const struct sk_buff *skb)
> diff --git a/net/bridge/netfilter/ebt_vlan.c b/net/bridge/netfilter/ebt_vlan.c
> index 87b53b3..a39d92d 100644
> --- a/net/bridge/netfilter/ebt_vlan.c
> +++ b/net/bridge/netfilter/ebt_vlan.c
> @@ -39,8 +39,6 @@ static bool
>  ebt_vlan_mt(const struct sk_buff *skb, struct xt_action_param *par)
>  {
>  	const struct ebt_vlan_info *info = par->matchinfo;
> -	const struct vlan_hdr *fp;
> -	struct vlan_hdr _frame;
>  
>  	unsigned short TCI;	/* Whole TCI, given from parsed frame */
>  	unsigned short id;	/* VLAN ID, given from frame TCI */
> @@ -48,21 +46,31 @@ ebt_vlan_mt(const struct sk_buff *skb, struct xt_action_param *par)
>  	/* VLAN encapsulated Type/Length field, given from orig frame */
>  	__be16 encap;
>  
> -	fp = skb_header_pointer(skb, 0, sizeof(_frame), &_frame);
> -	if (fp == NULL)
> -		return false;
> -
> -	/* Tag Control Information (TCI) consists of the following elements:
> -	 * - User_priority. The user_priority field is three bits in length,
> -	 * interpreted as a binary number.
> -	 * - Canonical Format Indicator (CFI). The Canonical Format Indicator
> -	 * (CFI) is a single bit flag value. Currently ignored.
> -	 * - VLAN Identifier (VID). The VID is encoded as
> -	 * an unsigned binary number. */
> -	TCI = ntohs(fp->h_vlan_TCI);
> +	if (skb->protocol == htons(ETH_P_8021Q)) {
> +		const struct vlan_hdr *fp;
> +		struct vlan_hdr _frame;
> +
> +		fp = skb_header_pointer(skb, 0, sizeof(_frame), &_frame);
> +		if (fp == NULL)
> +			return false;
> +
> +		/* Tag Control Information (TCI) consists of the following elements:
> +		 * - User_priority. The user_priority field is three bits in length,
> +		 * interpreted as a binary number.
> +		 * - Canonical Format Indicator (CFI). The Canonical Format Indicator
> +		 * (CFI) is a single bit flag value. Currently ignored.
> +		 * - VLAN Identifier (VID). The VID is encoded as
> +		 * an unsigned binary number. */
> +		TCI = ntohs(fp->h_vlan_TCI);
> +
> +		encap = fp->h_vlan_encapsulated_proto;
> +	} else {
> +		TCI = vlan_tx_tag_get(skb);
> +		encap = skb->protocol;
> +	}
> +
[...]

This has the same problem.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


^ permalink raw reply

* [PATCH] ethtool: add get permanent address option (v2)
From: Stephen Hemminger @ 2010-10-18 20:11 UTC (permalink / raw)
  To: Ben Hutchings, Jeff Garzik; +Cc: netdev
In-Reply-To: <1287431541.2252.556.camel@achroite.uk.solarflarecom.com>

Add command level support for showing permanent address.
The ioctl has been around for a long time but there was
no option to display it.

Note: MAX_ADDR_LEN is defined in netdevice.h but including
netdevice.h leads to multiple definition errors with if.h.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

---
Fix perror(), memory leak and indenting (v2)

 ethtool.8 |    6 ++++++
 ethtool.c |   38 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/ethtool.8 b/ethtool.8
index 3ca403c..84d5cc0 100644
--- a/ethtool.8
+++ b/ethtool.8
@@ -176,6 +176,9 @@ ethtool \- Display or change ethernet card settings
 .I ethX
 .RI [ N ]
 
+.B ethtool \-P|\-\-show-permaddr
+.I ethX
+
 .B ethtool \-r|\-\-negotiate
 .I ethX
 
@@ -388,6 +391,9 @@ blinking one or more LEDs on the specific ethernet port.
 .B N
 Length of time to perform phys-id, in seconds.
 .TP
+.B \-P \-\-show-permaddr
+Queries the specified ethernet device for permanent hardware address.
+.TP
 .B \-r \-\-negotiate
 Restarts auto-negotiation on the specified ethernet device, if
 auto-negotiation is enabled.
diff --git a/ethtool.c b/ethtool.c
index 6b2b7c8..1326f54 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -51,6 +51,9 @@
 #ifndef SIOCETHTOOL
 #define SIOCETHTOOL     0x8946
 #endif
+#ifndef MAX_ADDR_LEN
+#define MAX_ADDR_LEN	32
+#endif
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 #endif
@@ -107,6 +110,8 @@ static int do_srxfhindir(int fd, struct ifreq *ifr);
 static int do_srxntuple(int fd, struct ifreq *ifr);
 static int do_grxntuple(int fd, struct ifreq *ifr);
 static int do_flash(int fd, struct ifreq *ifr);
+static int do_permaddr(int fd, struct ifreq *ifr);
+
 static int send_ioctl(int fd, struct ifreq *ifr);
 
 static enum {
@@ -136,6 +141,7 @@ static enum {
 	MODE_SNTUPLE,
 	MODE_GNTUPLE,
 	MODE_FLASHDEV,
+	MODE_PERMADDR,
 } mode = MODE_GSET;
 
 static struct option {
@@ -247,6 +253,8 @@ static struct option {
 		"action <queue or drop>\n" },
     { "-u", "--show-ntuple", MODE_GNTUPLE,
 		"Get Rx ntuple filters and actions\n" },
+    { "-P", "--show-permaddr", MODE_PERMADDR,
+		"Show permanent hardware address" },
     { "-h", "--help", MODE_HELP, "Show this help" },
     {}
 };
@@ -750,7 +758,8 @@ static void parse_cmdline(int argc, char **argp)
 			    (mode == MODE_SNTUPLE) ||
 			    (mode == MODE_GNTUPLE) ||
 			    (mode == MODE_PHYS_ID) ||
-			    (mode == MODE_FLASHDEV)) {
+			    (mode == MODE_FLASHDEV) |
+			    (mode == MODE_PERMADDR)) {
 				devname = argp[i];
 				break;
 			}
@@ -1868,6 +1877,8 @@ static int doit(void)
 		return do_grxntuple(fd, &ifr);
 	} else if (mode == MODE_FLASHDEV) {
 		return do_flash(fd, &ifr);
+	} else if (mode == MODE_PERMADDR) {
+		return do_permaddr(fd, &ifr);
 	}
 
 	return 69;
@@ -2950,6 +2961,31 @@ static int do_flash(int fd, struct ifreq *ifr)
 	return err;
 }
 
+static int do_permaddr(int fd, struct ifreq *ifr)
+{
+	int i, err;
+	struct ethtool_perm_addr *epaddr;
+
+	epaddr = malloc(sizeof(struct ethtool_perm_addr) + MAX_ADDR_LEN);
+	epaddr->cmd = ETHTOOL_GPERMADDR;
+	epaddr->size = MAX_ADDR_LEN;
+	ifr->ifr_data = (caddr_t)epaddr;
+
+	err = send_ioctl(fd, ifr);
+	if (err < 0)
+		perror("Cannot read permanent address");
+	else {
+		printf("Permanent address:");
+		for (i = 0; i < epaddr->size; i++)
+			printf("%c%02x", (i == 0) ? ' ' : ':',
+			       epaddr->data[i]);
+		printf("\n");
+	}
+	free(epaddr);
+
+	return err;
+}
+
 static int do_srxntuple(int fd, struct ifreq *ifr)
 {
 	int err;
-- 
1.7.1


^ permalink raw reply related

* Re: [PATCH] ethtool: add get permanent address option (v2)
From: Joe Perches @ 2010-10-18 20:16 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Ben Hutchings, Jeff Garzik, netdev
In-Reply-To: <20101018131104.02681d60@nehalam>

On Mon, 2010-10-18 at 13:11 -0700, Stephen Hemminger wrote:
> diff --git a/ethtool.c b/ethtool.c
[]
> @@ -750,7 +758,8 @@ static void parse_cmdline(int argc, char **argp)
>  			    (mode == MODE_SNTUPLE) ||
>  			    (mode == MODE_GNTUPLE) ||
>  			    (mode == MODE_PHYS_ID) ||
> -			    (mode == MODE_FLASHDEV)) {
> +			    (mode == MODE_FLASHDEV) |
> +			    (mode == MODE_PERMADDR)) {

One more vertical bar please.



^ permalink raw reply


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