enic updates
Subsystems (3)
v3 cover enic updates
This series fixes minor bugs and adds new features like Accelerated RFS, busy_poll, tx clean-up in napi_poll.
Please apply it to net-next.
v3:
* While doing tx cleanup in napi, ignore budget and clean up all desc possible.
v2:
* Fix #ifdef coding style issue in '[PATCH 4/8] enic: alloc/free rx_cpu_rmap' And [PATCH 5/8] enic: Add Accelerated RFS support'
Govindarajulu Varadarajan (7):
flow_keys: Record IP layer protocol in skb_flow_dissect()
enic: fix return value in _vnic_dev_cmd
enic: devcmd for adding IP 5 tuple hardware filters
enic: alloc/free rx_cpu_rmap
enic: Add Accelerated RFS support
enic: add low latency socket busy_poll support
enic: do tx cleanup in napi poll
Tony Camuso (1):
enic: fix lockdep around devcmd_lock
drivers/net/ethernet/cisco/enic/Makefile | 2 +- drivers/net/ethernet/cisco/enic/enic.h | 43 +++- drivers/net/ethernet/cisco/enic/enic_api.c | 4 +- drivers/net/ethernet/cisco/enic/enic_clsf.c | 279 ++++++++++++++++++++++++++ drivers/net/ethernet/cisco/enic/enic_clsf.h | 19 ++ drivers/net/ethernet/cisco/enic/enic_dev.c | 80 ++++---- drivers/net/ethernet/cisco/enic/enic_dev.h | 4 +- drivers/net/ethernet/cisco/enic/enic_main.c | 245 +++++++++++++++++----- drivers/net/ethernet/cisco/enic/enic_res.c | 1 + drivers/net/ethernet/cisco/enic/vnic_dev.c | 65 +++++- drivers/net/ethernet/cisco/enic/vnic_dev.h | 2 + drivers/net/ethernet/cisco/enic/vnic_devcmd.h | 5 + drivers/net/ethernet/cisco/enic/vnic_enet.h | 2 + drivers/net/ethernet/cisco/enic/vnic_rq.h | 122 +++++++++++ include/net/flow_keys.h | 14 ++ include/net/sch_generic.h | 2 +- net/core/flow_dissector.c | 1 + 17 files changed, 786 insertions(+), 104 deletions(-) create mode 100644 drivers/net/ethernet/cisco/enic/enic_clsf.c create mode 100644 drivers/net/ethernet/cisco/enic/enic_clsf.h
Signature · 1 line
2.0.0
PATCH v3 1/8 flow_keys: Record IP layer protocol in skb_flow_dissect()
skb_flow_dissect() dissects only transport header type in ip_proto. It dose not give any information about IPv4 or IPv6.
This patch adds new member, n_proto, to struct flow_keys. Which records the IP layer type. i.e IPv4 or IPv6.
This can be used in netdev->ndo_rx_flow_steer driver function to dissect flow.
Adding new member to flow_keys increases the struct size by around 4 bytes. This causes BUILD_BUG_ON(sizeof(qcb->data) < sz); to fail in qdisc_cb_private_validate()
So increase data size by 4
--- include/net/flow_keys.h | 14 ++++++++++++++ include/net/sch_generic.h | 2 +- net/core/flow_dissector.c | 1 + 3 files changed, 16 insertions(+), 1 deletion(-)
include/net/flow_keys.h +14 -0
@@ -1,6 +1,19 @@ #ifndef _NET_FLOW_KEYS_H #define _NET_FLOW_KEYS_H +/* struct flow_keys: + * @src: source ip address in case of IPv4 + * For IPv6 it contains 32bit hash of src address + * @dst: destination ip address in case of IPv4 + * For IPv6 it contains 32bit hash of dst address + * @ports: port numbers of Transport header + * port16[0]: src port number + * port16[1]: dst port number + * @thoff: Transport header offset + * @n_proto: Network header protocol (eg. IPv4/IPv6) + * @ip_proto: Transport header protocol (eg. TCP/UDP) + * All the members, except thoff, are in network byte order. + */ struct flow_keys { /* (src,dst) must be grouped, in the same way than in IP header */ __be32 src;
@@ -10,6 +23,7 @@ struct flow_keys {__be16 port16[2 ]; };u16 thoff; +u16 n_proto;u8 ip_proto; };
include/net/sch_generic.h +1 -1
@@ -231,7 +231,7 @@ struct qdisc_skb_cb {unsigned int pkt_len;u16 slave_dev_queue_mapping;u16 _pad; -unsigned char data[20 ]; +unsigned char data[24 ]; };static inline void qdisc_cb_private_validate (const struct sk_buff *skb,int sz)
net/core/flow_dissector.c +1 -0
@@ -175,6 +175,7 @@ ipv6:break ; } + flow->n_proto = proto; flow->ip_proto = ip_proto; flow->ports =skb_flow_get_ports (skb, nhoff, ip_proto); flow->thoff = (u16 ) nhoff;
Signature · 1 line
2.0.0
PATCH v3 2/8 enic: fix return value in _vnic_dev_cmd
In reply to Govindarajulu VaradarajanHardware (in readq(&devcmd->args[0])) returns positive number in case of error. But _vnic_dev_cmd should return a negative value in case of error.
--- drivers/net/ethernet/cisco/enic/vnic_dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/cisco/enic/vnic_dev.c +2 -2
@@ -312,12 +312,12 @@ static int _vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, err = (int )readq (&devcmd->args[0 ]);if (err ==ERR_EINVAL && cmd ==CMD_CAPABILITY ) -return err; +return -err;if (err !=ERR_ECMDUNKNOWN || cmd !=CMD_CAPABILITY )pr_err ("Error %d devcmd %d\n" , err,_CMD_N (cmd)); -return err; +return -err; }if (_CMD_DIR (cmd) & _CMD_DIR_READ) {
Signature · 1 line
2.0.0
PATCH v3 3/8 enic: devcmd for adding IP 5 tuple hardware filters
In reply to Govindarajulu VaradarajanThis patch adds interface to add and delete IP 5 tuple filter. This interface is used by Accelerated RFS code to steer a flow to corresponding receive queue.
As of now adaptor supports only ipv4 + tcp/udp packet steering.
--- drivers/net/ethernet/cisco/enic/Makefile | 2 +- drivers/net/ethernet/cisco/enic/enic_clsf.c | 66 +++++++++++++++++++++++++++ drivers/net/ethernet/cisco/enic/enic_clsf.h | 10 ++++ drivers/net/ethernet/cisco/enic/vnic_dev.c | 61 +++++++++++++++++++++++++ drivers/net/ethernet/cisco/enic/vnic_dev.h | 2 + drivers/net/ethernet/cisco/enic/vnic_devcmd.h | 5 ++ 6 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/cisco/enic/enic_clsf.c create mode 100644 drivers/net/ethernet/cisco/enic/enic_clsf.h
drivers/net/ethernet/cisco/enic/Makefile +1 -1
@@ -2,5 +2,5 @@ obj-$(CONFIG_ENIC) := enic.o enic-y := enic_main.o vnic_cq.o vnic_intr.o vnic_wq.o \ enic_res.o enic_dev.o enic_pp.o vnic_dev.o vnic_rq.o vnic_vic.o \ - enic_ethtool.o enic_api.o + enic_ethtool.o enic_api.o enic_clsf.o
drivers/net/ethernet/cisco/enic/enic_clsf.c new file +66 -0
66 lines not on this page · raw message
drivers/net/ethernet/cisco/enic/enic_clsf.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef _ENIC_CLSF_H_ +#define _ENIC_CLSF_H_ + +#include "vnic_dev.h" +#include "enic.h" + +int enic_addfltr_5t (struct enic *enic,struct flow_keys *keys,u16 rq); +int enic_delfltr (struct enic *enic,u16 filter_id); + +#endif /* _ENIC_CLSF_H_ */
drivers/net/ethernet/cisco/enic/vnic_dev.c +61 -0
64 lines not on this page · raw message
drivers/net/ethernet/cisco/enic/vnic_dev.h +2 -0
@@ -133,5 +133,7 @@ int vnic_dev_enable2(struct vnic_dev *vdev, int active);int vnic_dev_enable2_done (struct vnic_dev *vdev,int *status);int vnic_dev_deinit_done (struct vnic_dev *vdev,int *status);int vnic_dev_set_mac_addr (struct vnic_dev *vdev,u8 *mac_addr); +int vnic_dev_classifier (struct vnic_dev *vdev,u8 cmd,u16 *entry, +struct filter *data);#endif /* _VNIC_DEV_H_ */
drivers/net/ethernet/cisco/enic/vnic_devcmd.h +5 -0
@@ -603,6 +603,11 @@ struct filter_tlv {u_int32_t val[0 ]; }; +enum { +CLSF_ADD =0 , +CLSF_DEL =1 , +}; +/* * Writing cmd register causes STAT_BUSY to get set in status register. * When cmd completes, STAT_BUSY will be cleared.
Signature · 1 line
2.0.0
PATCH v3 4/8 enic: alloc/free rx_cpu_rmap
In reply to Govindarajulu Varadarajanrx_cpu_rmap provides the reverse irq cpu affinity. This patch allocates and sets drivers netdev->rx_cpu_rmap accordingly.
rx_cpu_rmap is set in enic_request_intr() which is called by enic_open and rx_cpu_rmap is freed in enic_free_intr() which is called by enic_stop.
This is used by Accelerated RFS.
--- drivers/net/ethernet/cisco/enic/enic_main.c | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
drivers/net/ethernet/cisco/enic/enic_main.c +43 -0
@@ -39,6 +39,9 @@#include <linux/prefetch.h> #include <net/ip6_checksum.h> #include <linux/ktime.h> +#ifdef CONFIG_RFS_ACCEL +#include <linux/cpu_rmap.h> +#endif #include "cq_enet_desc.h" #include "vnic_dev.h"
@@ -1192,6 +1195,44 @@ static void enic_calc_int_moderation(struct enic *enic, struct vnic_rq *rq) pkt_size_counter->small_pkt_bytes_cnt =0 ; } +#ifdef CONFIG_RFS_ACCEL +static void enic_free_rx_cpu_rmap (struct enic *enic) +{ +free_irq_cpu_rmap (enic->netdev->rx_cpu_rmap); + enic->netdev->rx_cpu_rmap =NULL ; +} + +static void enic_set_rx_cpu_rmap (struct enic *enic) +{ +int i, res; + +if (vnic_dev_get_intr_mode (enic->vdev) ==VNIC_DEV_INTR_MODE_MSIX ) { + enic->netdev->rx_cpu_rmap =alloc_irq_cpu_rmap (enic->rq_count); +if (unlikely (!enic->netdev->rx_cpu_rmap)) +return ; +for (i =0 ; i < enic->rq_count; i++) { + res =irq_cpu_rmap_add (enic->netdev->rx_cpu_rmap, + enic->msix_entry[i].vector); +if (unlikely (res)) { +enic_free_rx_cpu_rmap (enic); +return ; + } + } + } +} + +#else + +static void enic_free_rx_cpu_rmap (struct enic *enic) +{ +} + +static void enic_set_rx_cpu_rmap (struct enic *enic) +{ +} + +#endif /* CONFIG_RFS_ACCEL */ +static int enic_poll_msix (struct napi_struct *napi,int budget) {struct net_device *netdev = napi->dev;
@@ -1267,6 +1308,7 @@ static void enic_free_intr(struct enic *enic)struct net_device *netdev = enic->netdev;unsigned int i; +enic_free_rx_cpu_rmap (enic);switch (vnic_dev_get_intr_mode (enic->vdev)) {case VNIC_DEV_INTR_MODE_INTX :free_irq (enic->pdev->irq, netdev);
@@ -1291,6 +1333,7 @@ static int enic_request_intr(struct enic *enic)unsigned int i, intr;int err =0 ; +enic_set_rx_cpu_rmap (enic);switch (vnic_dev_get_intr_mode (enic->vdev)) {case VNIC_DEV_INTR_MODE_INTX :
Signature · 1 line
2.0.0
PATCH v3 5/8 enic: Add Accelerated RFS support
In reply to Govindarajulu VaradarajanThis patch adds supports for Accelerated Receive Flow Steering.
When the desired rx is different from current rq, for a flow, kernel calls the driver function enic_rx_flow_steer(). enic_rx_flow_steer adds a IP-TCP/UDP hardware filter.
Driver registers a timer function enic_flow_may_expire. This function is called every HZ/4 seconds. In this function we check if the added filter has expired by calling rps_may_expire_flow(). If the flow has expired, it removes the hw filter.
As of now adaptor supports only IPv4 - TCP/UDP filters.
--- drivers/net/ethernet/cisco/enic/enic.h | 41 ++++++ drivers/net/ethernet/cisco/enic/enic_clsf.c | 213 ++++++++++++++++++++++++++++ drivers/net/ethernet/cisco/enic/enic_clsf.h | 9 ++ drivers/net/ethernet/cisco/enic/enic_main.c | 13 ++ drivers/net/ethernet/cisco/enic/enic_res.c | 1 + drivers/net/ethernet/cisco/enic/vnic_enet.h | 2 + 6 files changed, 279 insertions(+)
drivers/net/ethernet/cisco/enic/enic.h +41 -0
@@ -99,6 +99,44 @@ struct enic_port_profile {u8 mac_addr[ETH_ALEN ]; }; +#ifdef CONFIG_RFS_ACCEL +/* enic_rfs_fltr_node - rfs filter node in hash table +* @@keys: IPv4 5 tuple +* @flow_id: flow_id of clsf filter provided by kernel +* @fltr_id: filter id of clsf filter returned by adaptor +* @rq_id: desired rq index +* @node: hlist_node +*/ +struct enic_rfs_fltr_node { +struct flow_keys keys; +u32 flow_id; +u16 fltr_id; +u16 rq_id; +struct hlist_node node; +}; + +/* enic_rfs_flw_tbl - rfs flow table +* @max: Maximum number of filters vNIC supports +* @free: Number of free filters available +* @toclean: hash table index to clean next +* @ht_head: hash table list head +* @lock: spin lock +* @rfs_may_expire: timer function for enic_rps_may_expire_flow +*/ +struct enic_rfs_flw_tbl { +u16 max; +int free; + +#define ENIC_RFS_FLW_BITSHIFT (10) +#define ENIC_RFS_FLW_MASK ((1 << ENIC_RFS_FLW_BITSHIFT) - 1) +u16 toclean:ENIC_RFS_FLW_BITSHIFT ; +struct hlist_head ht_head[1 <<ENIC_RFS_FLW_BITSHIFT ]; +spinlock_t lock; +struct timer_list rfs_may_expire; +}; + +#endif /* CONFIG_RFS_ACCEL */ +/* Per-instance private data structure */ struct enic {struct net_device *netdev;
@@ -150,6 +188,9 @@ struct enic {/* completion queue cache line section */ ____cacheline_aligned struct vnic_cq cq[ENIC_CQ_MAX ];unsigned int cq_count; +#ifdef CONFIG_RFS_ACCEL +struct enic_rfs_flw_tbl rfs_h; +#endif };static inline struct device *enic_get_dev (struct enic *enic)
drivers/net/ethernet/cisco/enic/enic_clsf.c +213 -0
216 lines not on this page · raw message
drivers/net/ethernet/cisco/enic/enic_clsf.h +9 -0
@@ -4,7 +4,16 @@#include "vnic_dev.h" #include "enic.h" +#define ENIC_CLSF_EXPIRE_COUNT 128 +int enic_addfltr_5t (struct enic *enic,struct flow_keys *keys,u16 rq);int enic_delfltr (struct enic *enic,u16 filter_id); +#ifdef CONFIG_RFS_ACCEL +void enic_rfs_flw_tbl_init (struct enic *enic); +void enic_rfs_flw_tbl_free (struct enic *enic); +int enic_rx_flow_steer (struct net_device *dev,const struct sk_buff *skb, +u16 rxq_index,u32 flow_id); +#endif /* CONFIG_RFS_ACCEL */ +#endif /* _ENIC_CLSF_H_ */
drivers/net/ethernet/cisco/enic/enic_main.c +13 -0
@@ -52,6 +52,7 @@#include "enic.h" #include "enic_dev.h" #include "enic_pp.h" +#include "enic_clsf.h" #define ENIC_NOTIFY_TIMER_PERIOD (2 * HZ)#define WQ_ENET_MAX_DESC_LEN (1 << WQ_ENET_LEN_BITS)
@@ -1546,6 +1547,7 @@ static int enic_open(struct net_device *netdev)vnic_intr_unmask (&enic->intr[i]);enic_notify_timer_start (enic); +enic_rfs_flw_tbl_init (enic);return 0 ;
@@ -1572,6 +1574,7 @@ static int enic_stop(struct net_device *netdev)enic_synchronize_irqs (enic);del_timer_sync (&enic->notify_timer); +enic_rfs_flw_tbl_free (enic);enic_dev_disable (enic);
@@ -2064,6 +2067,9 @@ static const struct net_device_ops enic_netdev_dynamic_ops = {#ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = enic_poll_controller,#endif +#ifdef CONFIG_RFS_ACCEL + .ndo_rx_flow_steer = enic_rx_flow_steer, +#endif };static const struct net_device_ops enic_netdev_ops = {
@@ -2084,6 +2090,9 @@ static const struct net_device_ops enic_netdev_ops = {#ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = enic_poll_controller,#endif +#ifdef CONFIG_RFS_ACCEL + .ndo_rx_flow_steer = enic_rx_flow_steer, +#endif };static void enic_dev_deinit (struct enic *enic)
@@ -2429,6 +2438,10 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netdev->features |= netdev->hw_features; +#ifdef CONFIG_RFS_ACCEL + netdev->hw_features |=NETIF_F_NTUPLE ; +#endif +if (using_dac) netdev->features |=NETIF_F_HIGHDMA ;
drivers/net/ethernet/cisco/enic/enic_res.c +1 -0
@@ -71,6 +71,7 @@ int enic_get_vnic_config(struct enic *enic)GET_CONFIG (intr_mode);GET_CONFIG (intr_timer_usec);GET_CONFIG (loop_tag); +GET_CONFIG (num_arfs); c->wq_desc_count = min_t(u32, ENIC_MAX_WQ_DESCS,
drivers/net/ethernet/cisco/enic/vnic_enet.h +2 -0
@@ -32,6 +32,8 @@ struct vnic_enet_config {char devname[16 ];u32 intr_timer_usec;u16 loop_tag; +u16 vf_rq_count; +u16 num_arfs; };#define VENETF_TSO 0x1/* TSO enabled */
Signature · 1 line
2.0.0
PATCH v3 6/8 enic: fix lockdep around devcmd_lock
In reply to Govindarajulu VaradarajanFrom: Tony Camuso <[email protected]>
We were experiencing occasional "BUG: scheduling while atomic" splats in our testing. Enabling DEBUG_SPINLOCK and DEBUG_LOCKDEP in the kernel exposed a lockdep in the enic driver.
enic 0000:0b:00.0 eth2: Link UP
======================================================
[ INFO: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected ]
3.12.0-rc1.x86_64-dbg+ #2 Tainted: GF W
------------------------------------------------------
NetworkManager/4209 [HC0[0]:SC0[2]:HE1:SE0] is trying to acquire:
(&(&enic->devcmd_lock)->rlock){+.+...}, at: [<ffffffffa026b7e4>] enic_dev_packet_filter+0x44/0x90 [enic]
The fix was to replace spin_lock with spin_lock_bh for the enic devcmd_lock, so that soft irqs would be disabled while the lock is held.
--- drivers/net/ethernet/cisco/enic/enic_api.c | 4 +- drivers/net/ethernet/cisco/enic/enic_dev.c | 80 ++++++++++++++--------------- drivers/net/ethernet/cisco/enic/enic_dev.h | 4 +- drivers/net/ethernet/cisco/enic/enic_main.c | 16 +++--- 4 files changed, 52 insertions(+), 52 deletions(-)
drivers/net/ethernet/cisco/enic/enic_api.c +2 -2
@@ -34,13 +34,13 @@ int enic_api_devcmd_proxy_by_index(struct net_device *netdev, int vf,struct vnic_dev *vdev = enic->vdev;spin_lock (&enic->enic_api_lock); -spin_lock (&enic->devcmd_lock); +spin_lock_bh (&enic->devcmd_lock);vnic_dev_cmd_proxy_by_index_start (vdev, vf); err =vnic_dev_cmd (vdev, cmd, a0, a1, wait);vnic_dev_cmd_proxy_end (vdev); -spin_unlock (&enic->devcmd_lock); +spin_unlock_bh (&enic->devcmd_lock);spin_unlock (&enic->enic_api_lock);return err;
drivers/net/ethernet/cisco/enic/enic_dev.c +40 -40
223 lines not on this page · raw message
drivers/net/ethernet/cisco/enic/enic_dev.h +2 -2
@@ -28,7 +28,7 @@*/ #define ENIC_DEVCMD_PROXY_BY_INDEX (vf, err, enic, vnicdevcmdfn, ...) \ do { \ - spin_lock(&enic->devcmd_lock); \ + spin_lock_bh(&enic->devcmd_lock); \ if (enic_is_valid_vf(enic, vf)) { \ vnic_dev_cmd_proxy_by_index_start(enic->vdev, vf); \ err = vnicdevcmdfn(enic->vdev, ##__VA_ARGS__); \
@@ -36,7 +36,7 @@ }else { \ err = vnicdevcmdfn(enic->vdev, ##__VA_ARGS__); \ } \ -spin_unlock (&enic->devcmd_lock); \ +spin_unlock_bh (&enic->devcmd_lock); \ }while (0 ) int enic_dev_fw_info(struct enic *enic, struct vnic_devcmd_fw_info **fw_info);
drivers/net/ethernet/cisco/enic/enic_main.c +8 -8
@@ -1465,7 +1465,7 @@ static int enic_dev_notify_set(struct enic *enic) {int err; -spin_lock (&enic->devcmd_lock); +spin_lock_bh (&enic->devcmd_lock);switch (vnic_dev_get_intr_mode (enic->vdev)) {case VNIC_DEV_INTR_MODE_INTX : err = vnic_dev_notify_set(enic->vdev,
@@ -1479,7 +1479,7 @@ static int enic_dev_notify_set(struct enic *enic) err =vnic_dev_notify_set (enic->vdev,-1 /* no intr */ );break ; } -spin_unlock (&enic->devcmd_lock); +spin_unlock_bh (&enic->devcmd_lock);return err; }
@@ -1804,11 +1804,11 @@ static int enic_set_rsskey(struct enic *enic)memcpy (rss_key_buf_va, &rss_key,sizeof (union vnic_rss_key )); -spin_lock (&enic->devcmd_lock); +spin_lock_bh (&enic->devcmd_lock); err =enic_set_rss_key (enic, rss_key_buf_pa,sizeof (union vnic_rss_key )); -spin_unlock (&enic->devcmd_lock); +spin_unlock_bh (&enic->devcmd_lock);pci_free_consistent (enic->pdev,sizeof (union vnic_rss_key ), rss_key_buf_va, rss_key_buf_pa);
@@ -1831,11 +1831,11 @@ static int enic_set_rsscpu(struct enic *enic, u8 rss_hash_bits)for (i =0 ; i < (1 << rss_hash_bits); i++) (*rss_cpu_buf_va).cpu[i/4 ].b[i%4 ] = i % enic->rq_count; -spin_lock (&enic->devcmd_lock); +spin_lock_bh (&enic->devcmd_lock); err =enic_set_rss_cpu (enic, rss_cpu_buf_pa,sizeof (union vnic_rss_cpu )); -spin_unlock (&enic->devcmd_lock); +spin_unlock_bh (&enic->devcmd_lock);pci_free_consistent (enic->pdev,sizeof (union vnic_rss_cpu ), rss_cpu_buf_va, rss_cpu_buf_pa);
@@ -1853,13 +1853,13 @@ static int enic_set_niccfg(struct enic *enic, u8 rss_default_cpu,/* Enable VLAN tag stripping. */ -spin_lock (&enic->devcmd_lock); +spin_lock_bh (&enic->devcmd_lock); err =enic_set_nic_cfg (enic, rss_default_cpu, rss_hash_type, rss_hash_bits, rss_base_cpu, rss_enable, tso_ipid_split_en, ig_vlan_strip_en); -spin_unlock (&enic->devcmd_lock); +spin_unlock_bh (&enic->devcmd_lock);return err; }
Signature · 1 line
2.0.0
PATCH v3 7/8 enic: add low latency socket busy_poll support
In reply to Govindarajulu VaradarajanThis patch adds support for low latency busy_poll.
* Introduce drivers ndo_busy_poll function enic_busy_poll, which is called by socket waiting for data.
* Introduce locking between napi_poll nad busy_poll
* enic_busy_poll cleans up all the rx pkts possible. While in busy_poll, rq holds the state ENIC_POLL_STATE_POLL. While in napi_poll, rq holds the state ENIC_POLL_STATE_NAPI.
* in napi_poll we return if we are in busy_poll. Incase of INTx & msix, we just service wq and return if busy_poll is going on.
--- drivers/net/ethernet/cisco/enic/enic_main.c | 85 ++++++++++++++++--- drivers/net/ethernet/cisco/enic/vnic_rq.h | 122 ++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 12 deletions(-)
drivers/net/ethernet/cisco/enic/enic_main.c +73 -12
@@ -42,6 +42,9 @@#ifdef CONFIG_RFS_ACCEL #include <linux/cpu_rmap.h> #endif +#ifdef CONFIG_NET_RX_BUSY_POLL +#include <net/busy_poll.h> +#endif #include "cq_enet_desc.h" #include "vnic_dev.h"
@@ -1053,10 +1056,12 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq,if (vlan_stripped)__vlan_hwaccel_put_tag (skb,htons (ETH_P_8021Q ), vlan_tci); -if (netdev->features &NETIF_F_GRO ) -napi_gro_receive (&enic->napi[q_number], skb); -else +skb_mark_napi_id (skb, &enic->napi[rq->index]); +if (enic_poll_busy_polling (rq) || + !(netdev->features &NETIF_F_GRO ))netif_receive_skb (skb); +else +napi_gro_receive (&enic->napi[q_number], skb);if (enic->rx_coalesce_setting.use_adaptive_rx_coalesce)enic_intr_update_pkt_size (&cq->pkt_size_counter, bytes_written);
@@ -1093,16 +1098,22 @@ static int enic_poll(struct napi_struct *napi, int budget)unsigned int work_done, rq_work_done =0 , wq_work_done;int err; -/* Service RQ (first) and WQ -*/ + wq_work_done =vnic_cq_service (&enic->cq[cq_wq], wq_work_to_do, + enic_wq_service,NULL ); + +if (!enic_poll_lock_napi (&enic->rq[cq_rq])) { +if (wq_work_done >0 ) +vnic_intr_return_credits (&enic->intr[intr], + wq_work_done, +0 /* dont unmask intr */ , +0 /* dont reset intr timer */ ); +return rq_work_done; + }if (budget >0 ) rq_work_done =vnic_cq_service (&enic->cq[cq_rq], rq_work_to_do, enic_rq_service,NULL ); - wq_work_done =vnic_cq_service (&enic->cq[cq_wq], - wq_work_to_do, enic_wq_service,NULL ); -/* Accumulate intr event credits for this polling * cycle. An intr event is the completion of a * a WQ or RQ packet.
@@ -1134,6 +1145,7 @@ static int enic_poll(struct napi_struct *napi, int budget)napi_complete (napi);vnic_intr_unmask (&enic->intr[intr]); } +enic_poll_unlock_napi (&enic->rq[cq_rq]);return rq_work_done; }
@@ -1234,6 +1246,34 @@ static void enic_set_rx_cpu_rmap(struct enic *enic)#endif /* CONFIG_RFS_ACCEL */ +#ifdef CONFIG_NET_RX_BUSY_POLL +int enic_busy_poll (struct napi_struct *napi) +{ +struct net_device *netdev = napi->dev; +struct enic *enic =netdev_priv (netdev); +unsigned int rq = (napi - &enic->napi[0 ]); +unsigned int cq =enic_cq_rq (enic, rq); +unsigned int intr =enic_msix_rq_intr (enic, rq); +unsigned int work_to_do =-1 ;/* clean all pkts possible */ +unsigned int work_done; + +if (!enic_poll_lock_poll (&enic->rq[rq])) +return LL_FLUSH_BUSY ; + work_done =vnic_cq_service (&enic->cq[cq], work_to_do, + enic_rq_service,NULL ); + +if (work_done >0 ) +vnic_intr_return_credits (&enic->intr[intr], + work_done,0 ,0 ); +vnic_rq_fill (&enic->rq[rq], enic_rq_alloc_buf); +if (enic->rx_coalesce_setting.use_adaptive_rx_coalesce) +enic_calc_int_moderation (enic, &enic->rq[rq]); +enic_poll_unlock_poll (&enic->rq[rq]); + +return work_done; +} +#endif /* CONFIG_NET_RX_BUSY_POLL */ +static int enic_poll_msix (struct napi_struct *napi,int budget) {struct net_device *netdev = napi->dev;
@@ -1245,6 +1285,8 @@ static int enic_poll_msix(struct napi_struct *napi, int budget)unsigned int work_done =0 ;int err; +if (!enic_poll_lock_napi (&enic->rq[rq])) +return work_done;/* Service RQ */
@@ -1290,6 +1332,7 @@ static int enic_poll_msix(struct napi_struct *napi, int budget)enic_set_int_moderation (enic, &enic->rq[rq]);vnic_intr_unmask (&enic->intr[intr]); } +enic_poll_unlock_napi (&enic->rq[rq]);return work_done; }
@@ -1538,8 +1581,10 @@ static int enic_open(struct net_device *netdev)netif_tx_wake_all_queues (netdev); -for (i =0 ; i < enic->rq_count; i++) +for (i =0 ; i < enic->rq_count; i++) { +enic_busy_poll_init_lock (&enic->rq[i]);napi_enable (&enic->napi[i]); + }enic_dev_enable (enic);
@@ -1578,8 +1623,13 @@ static int enic_stop(struct net_device *netdev)enic_dev_disable (enic); -for (i =0 ; i < enic->rq_count; i++) +local_bh_disable (); +for (i =0 ; i < enic->rq_count; i++) {napi_disable (&enic->napi[i]); +while (!enic_poll_lock_napi (&enic->rq[i])) +mdelay (1 ); + } +local_bh_enable ();netif_carrier_off (netdev);netif_tx_disable (netdev);
@@ -2070,6 +2120,9 @@ static const struct net_device_ops enic_netdev_dynamic_ops = {#ifdef CONFIG_RFS_ACCEL .ndo_rx_flow_steer = enic_rx_flow_steer,#endif +#ifdef CONFIG_NET_RX_BUSY_POLL + .ndo_busy_poll = enic_busy_poll, +#endif };static const struct net_device_ops enic_netdev_ops = {
@@ -2093,14 +2146,19 @@ static const struct net_device_ops enic_netdev_ops = {#ifdef CONFIG_RFS_ACCEL .ndo_rx_flow_steer = enic_rx_flow_steer,#endif +#ifdef CONFIG_NET_RX_BUSY_POLL + .ndo_busy_poll = enic_busy_poll, +#endif };static void enic_dev_deinit (struct enic *enic) {unsigned int i; -for (i =0 ; i < enic->rq_count; i++) +for (i =0 ; i < enic->rq_count; i++) { +napi_hash_del (&enic->napi[i]);netif_napi_del (&enic->napi[i]); + }enic_free_vnic_resources (enic);enic_clear_intr_mode (enic);
@@ -2166,11 +2224,14 @@ static int enic_dev_init(struct enic *enic)switch (vnic_dev_get_intr_mode (enic->vdev)) {default :netif_napi_add (netdev, &enic->napi[0 ], enic_poll,64 ); +napi_hash_add (&enic->napi[0 ]);break ;case VNIC_DEV_INTR_MODE_MSIX : -for (i =0 ; i < enic->rq_count; i++) +for (i =0 ; i < enic->rq_count; i++) {netif_napi_add (netdev, &enic->napi[i], enic_poll_msix,64 ); +napi_hash_add (&enic->napi[i]); + }break ; }
drivers/net/ethernet/cisco/enic/vnic_rq.h +122 -0
134 lines not on this page · raw message
Signature · 1 line
2.0.0
PATCH v3 8/8 enic: do tx cleanup in napi poll
In reply to Govindarajulu VaradarajanTill now enic had been doing tx clean in isr.
Using napi infrastructure to move the tx clean up out of isr to softirq. Now, wq isr schedules napi poll. In enic_poll_msix_wq we clean up the tx queus.
This is applicable only on MSIX. In INTx and MSI we use single napi to clean both rx & tx queues.
--- drivers/net/ethernet/cisco/enic/enic.h | 2 +- drivers/net/ethernet/cisco/enic/enic_main.c | 88 +++++++++++++++++------------ 2 files changed, 54 insertions(+), 36 deletions(-)
drivers/net/ethernet/cisco/enic/enic.h +1 -1
@@ -178,7 +178,7 @@ struct enic {unsigned int rq_count;u64 rq_truncated_pkts;u64 rq_bad_fcs; -struct napi_struct napi[ENIC_RQ_MAX ]; +struct napi_struct napi[ENIC_RQ_MAX +ENIC_WQ_MAX ];/* interrupt resource cache line section */ ____cacheline_aligned struct vnic_intr intr[ENIC_INTR_MAX ];
drivers/net/ethernet/cisco/enic/enic_main.c +53 -35
158 lines not on this page · raw message
Signature · 1 line
2.0.0
David Miller
maintainerFrom: Govindarajulu Varadarajan <[email protected]>
Date: Mon, 23 Jun 2014 16:07:57 +0530
Quoted 2 lines
This series fixes minor bugs and adds new features like Accelerated RFS,
busy_poll, tx clean-up innapi_poll.
...
Quoted 6 lines
v3:
* While doing tx cleanup in napi, ignore budget and clean up all desc possible.v2:
* Fix #ifdef coding style issue in '[PATCH 4/8] enic: alloc/freerx_cpu_rmap' And [PATCH 5/8] enic: Add Accelerated RFS support'
Series applied, thanks.