Skip to contentSkip to conversation

msm: rmnet: msm rmnet smd virtual ethernet driver

PATCH Superseded Niranjana Vishwanathapura 3 participants 9 messages Dec 15, 2010 – Dec 21, 2010

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 msm: rmnet: msm rmnet smd virtual ethernet driver

Virtual ethernet interface for MSM RMNET SMD transport. This driver creates network devices which use underlaying SMD ports as transport. This driver enables sending and receving IP packets to baseband processor in MSM chipsets.

---
 drivers/net/Kconfig         |   17 ++
 drivers/net/Makefile        |    1 +
 drivers/net/msm_rmnet_smd.c |  357 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 375 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/msm_rmnet_smd.c
drivers/net/Kconfig +17 -0
index f6668cd..94ddee3 100644
@@ -3407,4 +3407,21 @@ config VMXNET3
          To compile this driver as a module, choose M here: the
          module will be called vmxnet3.
 
+config MSM_RMNET_SMD
+	bool "MSM RMNET Virtual Network Device over SMD transport"
+	depends on MSM_SMD
+	default n
+	help
+	  Virtual ethernet interface for MSM RMNET SMD transport.
+	  This driver creates network devices which use underlaying
+	  SMD ports as transport.  This driver enables sending and
+	  receving IP packets to baseband processor in MSM chipsets.
+
+config MSM_RMNET_DEBUG
+	bool "MSM RMNET debug interface"
+	depends on MSM_RMNET_SMD
+	default n
+	help
+	  Debug stats on wakeup counts for MSM RMNET devices.
+
 endif # NETDEVICES
drivers/net/Makefile +1 -0
index 652fc6b..51c0443 100644
@@ -301,3 +301,4 @@ obj-$(CONFIG_CAIF) += caif/
 
 obj-$(CONFIG_OCTEON_MGMT_ETHERNET) += octeon/
 obj-$(CONFIG_PCH_GBE) += pch_gbe/
+obj-$(CONFIG_MSM_RMNET_SMD) += msm_rmnet_smd.o
drivers/net/msm_rmnet_smd.c new file +357 -0

357 lines not on this page · raw message

Signature · 4 lines
1.5.6.3

Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#1 lore raw
Quoted 5 lines · On Wednesday 15 December 2010 19:31:06 Niranjana Vishwanathapura wrote:
drivers/net/msm_rmnet_smd.c new file +5 -0
+struct rmnet_private {
+       smd_channel_t *ch;
+       struct net_device_stats stats;
+       const char *chname;
+#ifdef CONFIG_MSM_RMNET_DEBUG

drivers/net/msm_rmnet_smd.c line 49

Quoted 10 lines
drivers/net/msm_rmnet_smd.c new file +10 -0
+       ktime_t last_packet;
+       short active_countdown; /* Number of times left to check */
+       short restart_count; /* Number of polls seems so far */
+       unsigned long wakeups_xmit;
+       unsigned long wakeups_rcv;
+       unsigned long timeout_us;
+       unsigned long awake_time_ms;
+       struct delayed_work work;
+#endif
+};

It feels like a significant portion of the code and the complexity (of which there fortunately is very little otherwise) is in the debugging code. How important is that debugging code still?

In my experience, once a driver gets stable enough for inclusion, most of the debugging code that you have put in there to write the driver becomes obsolete, because the next bug is not going to be found with it anyway.

How about deleting the debug code now? You still have the code and if something goes wrong, you can always put it back to analyse the problem.

Quoted 7 lines
drivers/net/msm_rmnet_smd.c new file +6 -0
+/* Called in soft-irq context */
+static void smd_net_data_handler(unsigned long arg)
+{
...
+}
+
+static DECLARE_TASKLET(smd_net_data_tasklet, smd_net_data_handler, 0);

drivers/net/msm_rmnet_smd.c line 215

Quoted 10 lines
drivers/net/msm_rmnet_smd.c new file +10 -0
+
+static void smd_net_notify(void *_dev, unsigned event)
+{
+       if (event != SMD_EVENT_DATA)
+               return;
+
+       smd_net_data_tasklet.data = (unsigned long) _dev;
+
+       tasklet_schedule(&smd_net_data_tasklet);
+}

It appears strange to do all the receive work in a tasklet. The common networking code already has infrastructure for deferring the rx to softirq time, and using the NAPI poll() logic likely gives you better performance as well.

Aside from these, the driver looks very nice and clean to me.

Arnd

#3 lore raw
In reply to Niranjana Vishwanathapura

drivers/net/msm_rmnet_smd.c line 267

Quoted 6 lines · On Wed, 15 Dec 2010 10:31:06 -0800 Niranjana Vishwanathapura…
drivers/net/msm_rmnet_smd.c new file +6 -0
+static struct net_device_stats *rmnet_get_stats(struct net_device *dev)
+{
+	struct rmnet_private *p = netdev_priv(dev);
+	return &p->stats;
+}
+

Just use dev->stats and this function would no longer be needed.

#5 lore raw
In reply to Niranjana Vishwanathapura

drivers/net/msm_rmnet_smd.c line 275

Quoted 5 lines · On Wed, 15 Dec 2010 10:31:06 -0800 Niranjana Vishwanathapura…
drivers/net/msm_rmnet_smd.c new file +5 -0
+
+static void rmnet_tx_timeout(struct net_device *dev)
+{
+	pr_info("rmnet_tx_timeout()\n");
+}

The purpose of having a tx_timeout is to clear the pending request.

#7 lore raw
In reply to Niranjana Vishwanathapura

drivers/net/msm_rmnet_smd.c line 216

Quoted 13 lines · On Wed, 15 Dec 2010 10:31:06 -0800 Niranjana Vishwanathapura…
drivers/net/msm_rmnet_smd.c new file +13 -0
+
+static DECLARE_TASKLET(smd_net_data_tasklet, smd_net_data_handler, 0);
+
+static void smd_net_notify(void *_dev, unsigned event)
+{
+	if (event != SMD_EVENT_DATA)
+		return;
+
+	smd_net_data_tasklet.data = (unsigned long) _dev;
+
+	tasklet_schedule(&smd_net_data_tasklet);
+}
+

Rather than having private tasklet, maybe using NAPI would be better?

Also since you are already in tasklet, no need to call netif_rx() when receiving packet; instead use netif_receive_skb directly.

#2 lore raw
In reply to Arnd Bergmann
Quoted 21 lines · On Wednesday 15 December 2010 19:31:06 Niranjana Vishwanathapura wrote:
Quoted 5 lines
drivers/net/msm_rmnet_smd.c new file +5 -0
+struct rmnet_private {
+       smd_channel_t *ch;
+       struct net_device_stats stats;
+       const char *chname;
+#ifdef CONFIG_MSM_RMNET_DEBUG

drivers/net/msm_rmnet_smd.c line 49

Quoted 10 lines
drivers/net/msm_rmnet_smd.c new file +10 -0
+       ktime_t last_packet;
+       short active_countdown; /* Number of times left to check */
+       short restart_count; /* Number of polls seems so far */
+       unsigned long wakeups_xmit;
+       unsigned long wakeups_rcv;
+       unsigned long timeout_us;
+       unsigned long awake_time_ms;
+       struct delayed_work work;
+#endif
+};

It feels like a significant portion of the code and the complexity (of which there fortunately is very little otherwise) is in the debugging code. How important is that debugging code still?

Quoted 9 lines

In my experience, once a driver gets stable enough for inclusion, most of the debugging code that you have put in there to write the driver becomes obsolete, because the next bug is not going to be found with it anyway.

How about deleting the debug code now? You still have the code and if something goes wrong, you can always put it back to analyse the problem.

These debug code proved to be very helpful in debugging with different baseband images on different targets. So, it would be very handy to keep it.

But, let me remove it for now, I can send another patch later for debug code.

Quoted 14 lines
Quoted 14 lines
drivers/net/msm_rmnet_smd.c new file +13 -0
+/* Called in soft-irq context */
+static void smd_net_data_handler(unsigned long arg)
+{
...
+}
+
+static DECLARE_TASKLET(smd_net_data_tasklet, smd_net_data_handler, 0);
+
+static void smd_net_notify(void *_dev, unsigned event)
+{
+       if (event != SMD_EVENT_DATA)
+               return;
+
+       smd_net_data_tasklet.data = (unsigned long) _dev;
Quoted 9 lines

drivers/net/msm_rmnet_smd.c line 215

Quoted 3 lines
drivers/net/msm_rmnet_smd.c new file +3 -0
+
+       tasklet_schedule(&smd_net_data_tasklet);
+}

It appears strange to do all the receive work in a tasklet. The common networking code already has infrastructure for deferring the rx to softirq time, and using the NAPI poll() logic likely gives you better performance as well.

NAPI will not buy much as the SMD transport doesn't provide a machanism to stop interrupts. I will consider using NAPI in the future (it requires performance testing on lot of different targets).

Quoted 4 lines

Aside from these, the driver looks very nice and clean to me.

Arnd

#4 lore raw
In reply to Stephen Hemminger
Quoted 12 lines

drivers/net/msm_rmnet_smd.c line 267

Quoted 6 lines · On Wed, 15 Dec 2010 10:31:06 -0800 Niranjana Vishwanathapura…
drivers/net/msm_rmnet_smd.c new file +6 -0
+static struct net_device_stats *rmnet_get_stats(struct net_device *dev)
+{
+	struct rmnet_private *p = netdev_priv(dev);
+	return &p->stats;
+}
+

Just use dev->stats and this function would no longer be needed.

Quoted 2 lines

--

This function will be a function pointer (ndo_get_stats) in net_device_ops structure.

#6 lore raw
In reply to Stephen Hemminger
Quoted 12 lines

drivers/net/msm_rmnet_smd.c line 275

Quoted 5 lines · On Wed, 15 Dec 2010 10:31:06 -0800 Niranjana Vishwanathapura…
drivers/net/msm_rmnet_smd.c new file +5 -0
+
+static void rmnet_tx_timeout(struct net_device *dev)
+{
+	pr_info("rmnet_tx_timeout()\n");
+}

The purpose of having a tx_timeout is to clear the pending request.

Quoted 2 lines

--

Currently, there is no mechanism to clear the transaction. This message is helpful in identifying the issue and fixing it.

#8 lore raw
In reply to Stephen Hemminger
Quoted 20 lines

drivers/net/msm_rmnet_smd.c line 216

Quoted 13 lines · On Wed, 15 Dec 2010 10:31:06 -0800 Niranjana Vishwanathapura…
drivers/net/msm_rmnet_smd.c new file +13 -0
+
+static DECLARE_TASKLET(smd_net_data_tasklet, smd_net_data_handler, 0);
+
+static void smd_net_notify(void *_dev, unsigned event)
+{
+	if (event != SMD_EVENT_DATA)
+		return;
+
+	smd_net_data_tasklet.data = (unsigned long) _dev;
+
+	tasklet_schedule(&smd_net_data_tasklet);
+}
+

Rather than having private tasklet, maybe using NAPI would be better?

Quoted 5 lines

Also since you are already in tasklet, no need to call netif_rx() when receiving packet; instead use netif_receive_skb directly.

--

NAPI will not buy much as the SMD transport doesn't provide a machanism to stop interrupts. I will consider using NAPI in the future (it requires performance testing on lot of different targets).

However, I can replace netif_rx() by netif_receive_skb() and send out new patch