Skip to content

Commit b6e97c1

Browse files
Govindarajulu Varadarajandavem330
authored andcommitted
enic: alloc/free rx_cpu_rmap
rx_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. Signed-off-by: Govindarajulu Varadarajan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6311852 commit b6e97c1

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

drivers/net/ethernet/cisco/enic/enic_main.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
#include <linux/prefetch.h>
4040
#include <net/ip6_checksum.h>
4141
#include <linux/ktime.h>
42+
#ifdef CONFIG_RFS_ACCEL
43+
#include <linux/cpu_rmap.h>
44+
#endif
4245

4346
#include "cq_enet_desc.h"
4447
#include "vnic_dev.h"
@@ -1192,6 +1195,44 @@ static void enic_calc_int_moderation(struct enic *enic, struct vnic_rq *rq)
11921195
pkt_size_counter->small_pkt_bytes_cnt = 0;
11931196
}
11941197

1198+
#ifdef CONFIG_RFS_ACCEL
1199+
static void enic_free_rx_cpu_rmap(struct enic *enic)
1200+
{
1201+
free_irq_cpu_rmap(enic->netdev->rx_cpu_rmap);
1202+
enic->netdev->rx_cpu_rmap = NULL;
1203+
}
1204+
1205+
static void enic_set_rx_cpu_rmap(struct enic *enic)
1206+
{
1207+
int i, res;
1208+
1209+
if (vnic_dev_get_intr_mode(enic->vdev) == VNIC_DEV_INTR_MODE_MSIX) {
1210+
enic->netdev->rx_cpu_rmap = alloc_irq_cpu_rmap(enic->rq_count);
1211+
if (unlikely(!enic->netdev->rx_cpu_rmap))
1212+
return;
1213+
for (i = 0; i < enic->rq_count; i++) {
1214+
res = irq_cpu_rmap_add(enic->netdev->rx_cpu_rmap,
1215+
enic->msix_entry[i].vector);
1216+
if (unlikely(res)) {
1217+
enic_free_rx_cpu_rmap(enic);
1218+
return;
1219+
}
1220+
}
1221+
}
1222+
}
1223+
1224+
#else
1225+
1226+
static void enic_free_rx_cpu_rmap(struct enic *enic)
1227+
{
1228+
}
1229+
1230+
static void enic_set_rx_cpu_rmap(struct enic *enic)
1231+
{
1232+
}
1233+
1234+
#endif /* CONFIG_RFS_ACCEL */
1235+
11951236
static int enic_poll_msix(struct napi_struct *napi, int budget)
11961237
{
11971238
struct net_device *netdev = napi->dev;
@@ -1267,6 +1308,7 @@ static void enic_free_intr(struct enic *enic)
12671308
struct net_device *netdev = enic->netdev;
12681309
unsigned int i;
12691310

1311+
enic_free_rx_cpu_rmap(enic);
12701312
switch (vnic_dev_get_intr_mode(enic->vdev)) {
12711313
case VNIC_DEV_INTR_MODE_INTX:
12721314
free_irq(enic->pdev->irq, netdev);
@@ -1291,6 +1333,7 @@ static int enic_request_intr(struct enic *enic)
12911333
unsigned int i, intr;
12921334
int err = 0;
12931335

1336+
enic_set_rx_cpu_rmap(enic);
12941337
switch (vnic_dev_get_intr_mode(enic->vdev)) {
12951338

12961339
case VNIC_DEV_INTR_MODE_INTX:

0 commit comments

Comments
 (0)