2 * Copyright 2011 Tilera Corporation. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
15 #include <linux/module.h>
16 #include <linux/init.h>
17 #include <linux/moduleparam.h>
18 #include <linux/sched.h>
19 #include <linux/kernel.h> /* printk() */
20 #include <linux/slab.h> /* kmalloc() */
21 #include <linux/errno.h> /* error codes */
22 #include <linux/types.h> /* size_t */
23 #include <linux/interrupt.h>
25 #include <linux/netdevice.h> /* struct device, and other headers */
26 #include <linux/etherdevice.h> /* eth_type_trans */
27 #include <linux/skbuff.h>
28 #include <linux/ioctl.h>
29 #include <linux/cdev.h>
30 #include <linux/hugetlb.h>
31 #include <linux/in6.h>
32 #include <linux/timer.h>
34 #include <linux/u64_stats_sync.h>
35 #include <asm/checksum.h>
36 #include <asm/homecache.h>
38 #include <hv/drv_xgbe_intf.h>
39 #include <hv/drv_xgbe_impl.h>
40 #include <hv/hypervisor.h>
41 #include <hv/netio_intf.h>
45 #include <linux/tcp.h>
49 * First, "tile_net_init_module()" initializes all four "devices" which
50 * can be used by linux.
52 * Then, "ifconfig DEVICE up" calls "tile_net_open()", which analyzes
53 * the network cpus, then uses "tile_net_open_aux()" to initialize
54 * LIPP/LEPP, and then uses "tile_net_open_inner()" to register all
55 * the tiles, provide buffers to LIPP, allow ingress to start, and
56 * turn on hypervisor interrupt handling (and NAPI) on all tiles.
58 * If registration fails due to the link being down, then "retry_work"
59 * is used to keep calling "tile_net_open_inner()" until it succeeds.
61 * If "ifconfig DEVICE down" is called, it uses "tile_net_stop()" to
62 * stop egress, drain the LIPP buffers, unregister all the tiles, stop
63 * LIPP/LEPP, and wipe the LEPP queue.
65 * We start out with the ingress interrupt enabled on each CPU. When
66 * this interrupt fires, we disable it, and call "napi_schedule()".
67 * This will cause "tile_net_poll()" to be called, which will pull
68 * packets from the netio queue, filtering them out, or passing them
69 * to "netif_receive_skb()". If our budget is exhausted, we will
70 * return, knowing we will be called again later. Otherwise, we
71 * reenable the ingress interrupt, and call "napi_complete()".
73 * HACK: Since disabling the ingress interrupt is not reliable, we
74 * ignore the interrupt if the global "active" flag is false.
77 * NOTE: The use of "native_driver" ensures that EPP exists, and that
78 * we are using "LIPP" and "LEPP".
80 * NOTE: Failing to free completions for an arbitrarily long time
81 * (which is defined to be illegal) does in fact cause bizarre
82 * problems. The "egress_timer" helps prevent this from happening.
86 /* HACK: Allow use of "jumbo" packets. */
87 /* This should be 1500 if "jumbo" is not set in LIPP. */
88 /* This should be at most 10226 (10240 - 14) if "jumbo" is set in LIPP. */
89 /* ISSUE: This has not been thoroughly tested (except at 1500). */
90 #define TILE_NET_MTU 1500
92 /* HACK: Define this to verify incoming packets. */
93 /* #define TILE_NET_VERIFY_INGRESS */
95 /* Use 3000 to enable the Linux Traffic Control (QoS) layer, else 0. */
96 #define TILE_NET_TX_QUEUE_LEN 0
98 /* Define to dump packets (prints out the whole packet on tx and rx). */
99 /* #define TILE_NET_DUMP_PACKETS */
101 /* Define to enable debug spew (all PDEBUG's are enabled). */
102 /* #define TILE_NET_DEBUG */
105 /* Define to activate paranoia checks. */
106 /* #define TILE_NET_PARANOIA */
108 /* Default transmit lockup timeout period, in jiffies. */
109 #define TILE_NET_TIMEOUT (5 * HZ)
111 /* Default retry interval for bringing up the NetIO interface, in jiffies. */
112 #define TILE_NET_RETRY_INTERVAL (5 * HZ)
114 /* Number of ports (xgbe0, xgbe1, gbe0, gbe1). */
115 #define TILE_NET_DEVS 4
120 #if NET_IP_ALIGN != LIPP_PACKET_PADDING
121 #error "NET_IP_ALIGN must match LIPP_PACKET_PADDING."
126 #ifdef TILE_NET_DEBUG
127 #define PDEBUG(fmt, args...) net_printk(fmt, ## args)
129 #define PDEBUG(fmt, args...)
133 MODULE_AUTHOR("Tilera");
134 MODULE_LICENSE("GPL");
138 * Queue of incoming packets for a specific cpu and device.
140 * Includes a pointer to the "system" data, and the actual "user" data.
142 struct tile_netio_queue {
143 netio_queue_impl_t *__system_part;
144 netio_queue_user_impl_t __user_part;
150 * Statistics counters for a specific cpu and device.
152 struct tile_net_stats_t {
153 struct u64_stats_sync syncp;
154 u64 rx_packets; /* total packets received */
155 u64 tx_packets; /* total packets transmitted */
156 u64 rx_bytes; /* total bytes received */
157 u64 tx_bytes; /* total bytes transmitted */
158 u64 rx_errors; /* packets truncated or marked bad by hw */
159 u64 rx_dropped; /* packets not for us or intf not up */
164 * Info for a specific cpu and device.
166 * ISSUE: There is a "dev" pointer in "napi" as well.
168 struct tile_net_cpu {
169 /* The NAPI struct. */
170 struct napi_struct napi;
172 struct tile_netio_queue queue;
174 struct tile_net_stats_t stats;
175 /* True iff NAPI is enabled. */
177 /* True if this tile has successfully registered with the IPP. */
179 /* True if the link was down last time we tried to register. */
181 /* True if "egress_timer" is scheduled. */
182 bool egress_timer_scheduled;
183 /* Number of small sk_buffs which must still be provided. */
184 unsigned int num_needed_small_buffers;
185 /* Number of large sk_buffs which must still be provided. */
186 unsigned int num_needed_large_buffers;
187 /* A timer for handling egress completions. */
188 struct timer_list egress_timer;
193 * Info for a specific device.
195 struct tile_net_priv {
196 /* Our network device. */
197 struct net_device *dev;
198 /* Pages making up the egress queue. */
199 struct page *eq_pages;
200 /* Address of the actual egress queue. */
204 /* The hypervisor handle for this interface. */
206 /* The intr bit mask that IDs this device. */
208 /* True iff "tile_net_open_aux()" has succeeded. */
210 /* True iff the device is "active". */
212 /* Effective network cpus. */
213 struct cpumask network_cpus_map;
214 /* Number of network cpus. */
215 int network_cpus_count;
216 /* Credits per network cpu. */
217 int network_cpus_credits;
218 /* For NetIO bringup retries. */
219 struct delayed_work retry_work;
220 /* Quick access to per cpu data. */
221 struct tile_net_cpu *cpu[NR_CPUS];
224 /* Log2 of the number of small pages needed for the egress queue. */
225 #define EQ_ORDER get_order(sizeof(lepp_queue_t))
226 /* Size of the egress queue's pages. */
227 #define EQ_SIZE (1 << (PAGE_SHIFT + EQ_ORDER))
230 * The actual devices (xgbe0, xgbe1, gbe0, gbe1).
232 static struct net_device *tile_net_devs[TILE_NET_DEVS];
235 * The "tile_net_cpu" structures for each device.
237 static DEFINE_PER_CPU(struct tile_net_cpu, hv_xgbe0);
238 static DEFINE_PER_CPU(struct tile_net_cpu, hv_xgbe1);
239 static DEFINE_PER_CPU(struct tile_net_cpu, hv_gbe0);
240 static DEFINE_PER_CPU(struct tile_net_cpu, hv_gbe1);
244 * True if "network_cpus" was specified.
246 static bool network_cpus_used;
249 * The actual cpus in "network_cpus".
251 static struct cpumask network_cpus_map;
255 #ifdef TILE_NET_DEBUG
257 * printk with extra stuff.
259 * We print the CPU we're running in brackets.
261 static void net_printk(char *fmt, ...)
266 static char buf[256];
268 len = sprintf(buf, "tile_net[%2.2d]: ", smp_processor_id());
270 i = vscnprintf(buf + len, sizeof(buf) - len - 1, fmt, args);
278 #ifdef TILE_NET_DUMP_PACKETS
282 static void dump_packet(unsigned char *data, unsigned long length, char *s)
284 int my_cpu = smp_processor_id();
289 static unsigned int count;
291 pr_info("dump_packet(data %p, length 0x%lx s %s count 0x%x)\n",
292 data, length, s, count++);
296 for (i = 0; i < length; i++) {
298 sprintf(buf, "[%02d] %8.8lx:", my_cpu, i);
299 sprintf(buf + strlen(buf), " %2.2x", data[i]);
300 if ((i & 0xf) == 0xf || i == length - 1) {
310 * Provide support for the __netio_fastio1() swint
311 * (see <hv/drv_xgbe_intf.h> for how it is used).
313 * The fastio swint2 call may clobber all the caller-saved registers.
314 * It rarely clobbers memory, but we allow for the possibility in
315 * the signature just to be on the safe side.
317 * Also, gcc doesn't seem to allow an input operand to be
318 * clobbered, so we fake it with dummy outputs.
320 * This function can't be static because of the way it is declared
321 * in the netio header.
323 inline int __netio_fastio1(u32 fastio_index, u32 arg0)
325 long result, clobber_r1, clobber_r10;
326 asm volatile("swint2"
328 "=R01" (clobber_r1), "=R10" (clobber_r10)
329 : "R10" (fastio_index), "R01" (arg0)
330 : "memory", "r2", "r3", "r4",
331 "r5", "r6", "r7", "r8", "r9",
332 "r11", "r12", "r13", "r14",
333 "r15", "r16", "r17", "r18", "r19",
334 "r20", "r21", "r22", "r23", "r24",
335 "r25", "r26", "r27", "r28", "r29");
340 static void tile_net_return_credit(struct tile_net_cpu *info)
342 struct tile_netio_queue *queue = &info->queue;
343 netio_queue_user_impl_t *qup = &queue->__user_part;
345 /* Return four credits after every fourth packet. */
346 if (--qup->__receive_credit_remaining == 0) {
347 u32 interval = qup->__receive_credit_interval;
348 qup->__receive_credit_remaining = interval;
349 __netio_fastio_return_credits(qup->__fastio_index, interval);
356 * Provide a linux buffer to LIPP.
358 static void tile_net_provide_linux_buffer(struct tile_net_cpu *info,
359 void *va, bool small)
361 struct tile_netio_queue *queue = &info->queue;
363 /* Convert "va" and "small" to "linux_buffer_t". */
364 unsigned int buffer = ((unsigned int)(__pa(va) >> 7) << 1) + small;
366 __netio_fastio_free_buffer(queue->__user_part.__fastio_index, buffer);
371 * Provide a linux buffer for LIPP.
373 * Note that the ACTUAL allocation for each buffer is a "struct sk_buff",
374 * plus a chunk of memory that includes not only the requested bytes, but
375 * also NET_SKB_PAD bytes of initial padding, and a "struct skb_shared_info".
377 * Note that "struct skb_shared_info" is 88 bytes with 64K pages and
378 * 268 bytes with 4K pages (since the frags[] array needs 18 entries).
380 * Without jumbo packets, the maximum packet size will be 1536 bytes,
381 * and we use 2 bytes (NET_IP_ALIGN) of padding. ISSUE: If we told
382 * the hardware to clip at 1518 bytes instead of 1536 bytes, then we
383 * could save an entire cache line, but in practice, we don't need it.
385 * Since CPAs are 38 bits, and we can only encode the high 31 bits in
386 * a "linux_buffer_t", the low 7 bits must be zero, and thus, we must
387 * align the actual "va" mod 128.
389 * We assume that the underlying "head" will be aligned mod 64. Note
390 * that in practice, we have seen "head" NOT aligned mod 128 even when
391 * using 2048 byte allocations, which is surprising.
393 * If "head" WAS always aligned mod 128, we could change LIPP to
394 * assume that the low SIX bits are zero, and the 7th bit is one, that
395 * is, align the actual "va" mod 128 plus 64, which would be "free".
397 * For now, the actual "head" pointer points at NET_SKB_PAD bytes of
398 * padding, plus 28 or 92 bytes of extra padding, plus the sk_buff
399 * pointer, plus the NET_IP_ALIGN padding, plus 126 or 1536 bytes for
400 * the actual packet, plus 62 bytes of empty padding, plus some
401 * padding and the "struct skb_shared_info".
403 * With 64K pages, a large buffer thus needs 32+92+4+2+1536+62+88
404 * bytes, or 1816 bytes, which fits comfortably into 2048 bytes.
406 * With 64K pages, a small buffer thus needs 32+92+4+2+126+88
407 * bytes, or 344 bytes, which means we are wasting 64+ bytes, and
408 * could presumably increase the size of small buffers.
410 * With 4K pages, a large buffer thus needs 32+92+4+2+1536+62+268
411 * bytes, or 1996 bytes, which fits comfortably into 2048 bytes.
413 * With 4K pages, a small buffer thus needs 32+92+4+2+126+268
414 * bytes, or 524 bytes, which is annoyingly wasteful.
416 * Maybe we should increase LIPP_SMALL_PACKET_SIZE to 192?
418 * ISSUE: Maybe we should increase "NET_SKB_PAD" to 64?
420 static bool tile_net_provide_needed_buffer(struct tile_net_cpu *info,
423 #if TILE_NET_MTU <= 1536
424 /* Without "jumbo", 2 + 1536 should be sufficient. */
425 unsigned int large_size = NET_IP_ALIGN + 1536;
427 /* ISSUE: This has not been tested. */
428 unsigned int large_size = NET_IP_ALIGN + TILE_NET_MTU + 100;
431 /* Avoid "false sharing" with last cache line. */
432 /* ISSUE: This is already done by "netdev_alloc_skb()". */
434 (((small ? LIPP_SMALL_PACKET_SIZE : large_size) +
435 CHIP_L2_LINE_SIZE() - 1) & -CHIP_L2_LINE_SIZE());
437 unsigned int padding = 128 - NET_SKB_PAD;
443 struct sk_buff **skb_ptr;
445 /* Request 96 extra bytes for alignment purposes. */
446 skb = netdev_alloc_skb(info->napi.dev, len + padding);
450 /* Skip 32 or 96 bytes to align "data" mod 128. */
451 align = -(long)skb->data & (128 - 1);
452 BUG_ON(align > padding);
453 skb_reserve(skb, align);
455 /* This address is given to IPP. */
458 /* Buffers must not span a huge page. */
459 BUG_ON(((((long)va & ~HPAGE_MASK) + len) & HPAGE_MASK) != 0);
461 #ifdef TILE_NET_PARANOIA
462 #if CHIP_HAS_CBOX_HOME_MAP()
464 HV_PTE pte = *virt_to_pte(current->mm, (unsigned long)va);
465 if (hv_pte_get_mode(pte) != HV_PTE_MODE_CACHE_HASH_L3)
466 panic("Non-HFH ingress buffer! VA=%p Mode=%d PTE=%llx",
467 va, hv_pte_get_mode(pte), hv_pte_val(pte));
472 /* Invalidate the packet buffer. */
474 __inv_buffer(va, len);
476 /* Skip two bytes to satisfy LIPP assumptions. */
477 /* Note that this aligns IP on a 16 byte boundary. */
478 /* ISSUE: Do this when the packet arrives? */
479 skb_reserve(skb, NET_IP_ALIGN);
481 /* Save a back-pointer to 'skb'. */
482 skb_ptr = va - sizeof(*skb_ptr);
485 /* Make sure "skb_ptr" has been flushed. */
488 /* Provide the new buffer. */
489 tile_net_provide_linux_buffer(info, va, small);
496 * Provide linux buffers for LIPP.
498 static void tile_net_provide_needed_buffers(struct tile_net_cpu *info)
500 while (info->num_needed_small_buffers != 0) {
501 if (!tile_net_provide_needed_buffer(info, true))
503 info->num_needed_small_buffers--;
506 while (info->num_needed_large_buffers != 0) {
507 if (!tile_net_provide_needed_buffer(info, false))
509 info->num_needed_large_buffers--;
516 /* Add a description to the page allocation failure dump. */
517 pr_notice("Could not provide a linux buffer to LIPP.\n");
522 * Grab some LEPP completions, and store them in "comps", of size
523 * "comps_size", and return the number of completions which were
524 * stored, so the caller can free them.
526 static unsigned int tile_net_lepp_grab_comps(lepp_queue_t *eq,
527 struct sk_buff *comps[],
528 unsigned int comps_size,
529 unsigned int min_size)
533 unsigned int comp_head = eq->comp_head;
534 unsigned int comp_busy = eq->comp_busy;
536 while (comp_head != comp_busy && n < comps_size) {
537 comps[n++] = eq->comps[comp_head];
538 LEPP_QINC(comp_head);
544 eq->comp_head = comp_head;
551 * Free some comps, and return true iff there are still some pending.
553 static bool tile_net_lepp_free_comps(struct net_device *dev, bool all)
555 struct tile_net_priv *priv = netdev_priv(dev);
557 lepp_queue_t *eq = priv->eq;
559 struct sk_buff *olds[64];
560 unsigned int wanted = 64;
564 spin_lock(&priv->eq_lock);
567 eq->comp_busy = eq->comp_tail;
569 n = tile_net_lepp_grab_comps(eq, olds, wanted, 0);
571 pending = (eq->comp_head != eq->comp_tail);
573 spin_unlock(&priv->eq_lock);
575 for (i = 0; i < n; i++)
583 * Make sure the egress timer is scheduled.
585 * Note that we use "schedule if not scheduled" logic instead of the more
586 * obvious "reschedule" logic, because "reschedule" is fairly expensive.
588 static void tile_net_schedule_egress_timer(struct tile_net_cpu *info)
590 if (!info->egress_timer_scheduled) {
591 mod_timer_pinned(&info->egress_timer, jiffies + 1);
592 info->egress_timer_scheduled = true;
598 * The "function" for "info->egress_timer".
600 * This timer will reschedule itself as long as there are any pending
601 * completions expected (on behalf of any tile).
603 * ISSUE: Realistically, will the timer ever stop scheduling itself?
605 * ISSUE: This timer is almost never actually needed, so just use a global
606 * timer that can run on any tile.
608 * ISSUE: Maybe instead track number of expected completions, and free
609 * only that many, resetting to zero if "pending" is ever false.
611 static void tile_net_handle_egress_timer(unsigned long arg)
613 struct tile_net_cpu *info = (struct tile_net_cpu *)arg;
614 struct net_device *dev = info->napi.dev;
616 /* The timer is no longer scheduled. */
617 info->egress_timer_scheduled = false;
619 /* Free comps, and reschedule timer if more are pending. */
620 if (tile_net_lepp_free_comps(dev, false))
621 tile_net_schedule_egress_timer(info);
625 static void tile_net_discard_aux(struct tile_net_cpu *info, int index)
627 struct tile_netio_queue *queue = &info->queue;
628 netio_queue_impl_t *qsp = queue->__system_part;
629 netio_queue_user_impl_t *qup = &queue->__user_part;
631 int index2_aux = index + sizeof(netio_pkt_t);
634 qsp->__packet_receive_queue.__last_packet_plus_one) ?
637 netio_pkt_t *pkt = (netio_pkt_t *)((unsigned long) &qsp[1] + index);
639 /* Extract the "linux_buffer_t". */
640 unsigned int buffer = pkt->__packet.word;
642 /* Convert "linux_buffer_t" to "va". */
643 void *va = __va((phys_addr_t)(buffer >> 1) << 7);
645 /* Acquire the associated "skb". */
646 struct sk_buff **skb_ptr = va - sizeof(*skb_ptr);
647 struct sk_buff *skb = *skb_ptr;
651 /* Consume this packet. */
652 qup->__packet_receive_read = index2;
657 * Like "tile_net_poll()", but just discard packets.
659 static void tile_net_discard_packets(struct net_device *dev)
661 struct tile_net_priv *priv = netdev_priv(dev);
662 int my_cpu = smp_processor_id();
663 struct tile_net_cpu *info = priv->cpu[my_cpu];
664 struct tile_netio_queue *queue = &info->queue;
665 netio_queue_impl_t *qsp = queue->__system_part;
666 netio_queue_user_impl_t *qup = &queue->__user_part;
668 while (qup->__packet_receive_read !=
669 qsp->__packet_receive_queue.__packet_write) {
670 int index = qup->__packet_receive_read;
671 tile_net_discard_aux(info, index);
677 * Handle the next packet. Return true if "processed", false if "filtered".
679 static bool tile_net_poll_aux(struct tile_net_cpu *info, int index)
681 struct net_device *dev = info->napi.dev;
683 struct tile_netio_queue *queue = &info->queue;
684 netio_queue_impl_t *qsp = queue->__system_part;
685 netio_queue_user_impl_t *qup = &queue->__user_part;
686 struct tile_net_stats_t *stats = &info->stats;
690 int index2_aux = index + sizeof(netio_pkt_t);
693 qsp->__packet_receive_queue.__last_packet_plus_one) ?
696 netio_pkt_t *pkt = (netio_pkt_t *)((unsigned long) &qsp[1] + index);
698 netio_pkt_metadata_t *metadata = NETIO_PKT_METADATA(pkt);
699 netio_pkt_status_t pkt_status = NETIO_PKT_STATUS_M(metadata, pkt);
701 /* Extract the packet size. FIXME: Shouldn't the second line */
702 /* get subtracted? Mostly moot, since it should be "zero". */
704 (NETIO_PKT_CUSTOM_LENGTH(pkt) +
705 NET_IP_ALIGN - NETIO_PACKET_PADDING);
707 /* Extract the "linux_buffer_t". */
708 unsigned int buffer = pkt->__packet.word;
710 /* Extract "small" (vs "large"). */
711 bool small = ((buffer & 1) != 0);
713 /* Convert "linux_buffer_t" to "va". */
714 void *va = __va((phys_addr_t)(buffer >> 1) << 7);
716 /* Extract the packet data pointer. */
717 /* Compare to "NETIO_PKT_CUSTOM_DATA(pkt)". */
718 unsigned char *buf = va + NET_IP_ALIGN;
720 /* Invalidate the packet buffer. */
722 __inv_buffer(buf, len);
724 /* ISSUE: Is this needed? */
725 dev->last_rx = jiffies;
727 #ifdef TILE_NET_DUMP_PACKETS
728 dump_packet(buf, len, "rx");
729 #endif /* TILE_NET_DUMP_PACKETS */
731 #ifdef TILE_NET_VERIFY_INGRESS
732 if (pkt_status == NETIO_PKT_STATUS_OVERSIZE && len >= 64) {
733 dump_packet(buf, len, "rx");
734 panic("Unexpected OVERSIZE.");
740 if (pkt_status == NETIO_PKT_STATUS_BAD) {
741 /* Handle CRC error and hardware truncation. */
743 } else if (!(dev->flags & IFF_UP)) {
744 /* Filter packets received before we're up. */
746 } else if (NETIO_PKT_ETHERTYPE_RECOGNIZED_M(metadata, pkt) &&
747 pkt_status == NETIO_PKT_STATUS_UNDERSIZE) {
748 /* Filter "truncated" packets. */
750 } else if (!(dev->flags & IFF_PROMISC)) {
751 if (!is_multicast_ether_addr(buf)) {
752 /* Filter packets not for our address. */
753 const u8 *mine = dev->dev_addr;
754 filter = !ether_addr_equal(mine, buf);
758 u64_stats_update_begin(&stats->syncp);
767 tile_net_provide_linux_buffer(info, va, small);
771 /* Acquire the associated "skb". */
772 struct sk_buff **skb_ptr = va - sizeof(*skb_ptr);
773 struct sk_buff *skb = *skb_ptr;
776 if (skb->data != buf)
777 panic("Corrupt linux buffer from LIPP! "
778 "VA=%p, skb=%p, skb->data=%p\n",
781 /* Encode the actual packet length. */
784 /* NOTE: This call also sets "skb->dev = dev". */
785 skb->protocol = eth_type_trans(skb, dev);
787 /* Avoid recomputing "good" TCP/UDP checksums. */
788 if (NETIO_PKT_L4_CSUM_CORRECT_M(metadata, pkt))
789 skb->ip_summed = CHECKSUM_UNNECESSARY;
791 netif_receive_skb(skb);
794 stats->rx_bytes += len;
797 u64_stats_update_end(&stats->syncp);
799 /* ISSUE: It would be nice to defer this until the packet has */
800 /* actually been processed. */
801 tile_net_return_credit(info);
803 /* Consume this packet. */
804 qup->__packet_receive_read = index2;
811 * Handle some packets for the given device on the current CPU.
813 * If "tile_net_stop()" is called on some other tile while this
814 * function is running, we will return, hopefully before that
815 * other tile asks us to call "napi_disable()".
817 * The "rotting packet" race condition occurs if a packet arrives
818 * during the extremely narrow window between the queue appearing to
819 * be empty, and the ingress interrupt being re-enabled. This happens
820 * a LOT under heavy network load.
822 static int tile_net_poll(struct napi_struct *napi, int budget)
824 struct net_device *dev = napi->dev;
825 struct tile_net_priv *priv = netdev_priv(dev);
826 int my_cpu = smp_processor_id();
827 struct tile_net_cpu *info = priv->cpu[my_cpu];
828 struct tile_netio_queue *queue = &info->queue;
829 netio_queue_impl_t *qsp = queue->__system_part;
830 netio_queue_user_impl_t *qup = &queue->__user_part;
832 unsigned int work = 0;
837 while (priv->active) {
838 int index = qup->__packet_receive_read;
839 if (index == qsp->__packet_receive_queue.__packet_write)
842 if (tile_net_poll_aux(info, index)) {
843 if (++work >= budget)
848 napi_complete(&info->napi);
853 /* Re-enable the ingress interrupt. */
854 enable_percpu_irq(priv->intr_id, 0);
856 /* HACK: Avoid the "rotting packet" problem (see above). */
857 if (qup->__packet_receive_read !=
858 qsp->__packet_receive_queue.__packet_write) {
859 /* ISSUE: Sometimes this returns zero, presumably */
860 /* because an interrupt was handled for this tile. */
861 (void)napi_reschedule(&info->napi);
867 tile_net_provide_needed_buffers(info);
874 * Handle an ingress interrupt for the given device on the current cpu.
876 * ISSUE: Sometimes this gets called after "disable_percpu_irq()" has
877 * been called! This is probably due to "pending hypervisor downcalls".
879 * ISSUE: Is there any race condition between the "napi_schedule()" here
880 * and the "napi_complete()" call above?
882 static irqreturn_t tile_net_handle_ingress_interrupt(int irq, void *dev_ptr)
884 struct net_device *dev = (struct net_device *)dev_ptr;
885 struct tile_net_priv *priv = netdev_priv(dev);
886 int my_cpu = smp_processor_id();
887 struct tile_net_cpu *info = priv->cpu[my_cpu];
889 /* Disable the ingress interrupt. */
890 disable_percpu_irq(priv->intr_id);
892 /* Ignore unwanted interrupts. */
896 /* ISSUE: Sometimes "info->napi_enabled" is false here. */
898 napi_schedule(&info->napi);
905 * One time initialization per interface.
907 static int tile_net_open_aux(struct net_device *dev)
909 struct tile_net_priv *priv = netdev_priv(dev);
913 unsigned int epp_lotar;
916 * Find out where EPP memory should be homed.
918 ret = hv_dev_pread(priv->hv_devhdl, 0,
919 (HV_VirtAddr)&epp_lotar, sizeof(epp_lotar),
922 pr_err("could not read epp_shm_queue lotar.\n");
927 * Home the page on the EPP.
930 int epp_home = hv_lotar_to_cpu(epp_lotar);
931 homecache_change_page_home(priv->eq_pages, EQ_ORDER, epp_home);
935 * Register the EPP shared memory queue.
938 netio_ipp_address_t ea = {
940 .pa = __pa(priv->eq),
944 ea.pte = hv_pte_set_lotar(ea.pte, epp_lotar);
945 ea.pte = hv_pte_set_mode(ea.pte, HV_PTE_MODE_CACHE_TILE_L3);
946 ret = hv_dev_pwrite(priv->hv_devhdl, 0,
957 if (hv_dev_pwrite(priv->hv_devhdl, 0, (HV_VirtAddr)&dummy,
958 sizeof(dummy), NETIO_IPP_START_SHIM_OFF) < 0) {
959 pr_warning("Failed to start LIPP/LEPP.\n");
968 * Register with hypervisor on the current CPU.
970 * Strangely, this function does important things even if it "fails",
971 * which is especially common if the link is not up yet. Hopefully
972 * these things are all "harmless" if done twice!
974 static void tile_net_register(void *dev_ptr)
976 struct net_device *dev = (struct net_device *)dev_ptr;
977 struct tile_net_priv *priv = netdev_priv(dev);
978 int my_cpu = smp_processor_id();
979 struct tile_net_cpu *info;
981 struct tile_netio_queue *queue;
983 /* Only network cpus can receive packets. */
985 cpumask_test_cpu(my_cpu, &priv->network_cpus_map) ? 0 : 255;
987 netio_input_config_t config = {
989 .num_receive_packets = priv->network_cpus_credits,
994 netio_queue_impl_t *queuep;
996 PDEBUG("tile_net_register(queue_id %d)\n", queue_id);
998 if (!strcmp(dev->name, "xgbe0"))
999 info = &__get_cpu_var(hv_xgbe0);
1000 else if (!strcmp(dev->name, "xgbe1"))
1001 info = &__get_cpu_var(hv_xgbe1);
1002 else if (!strcmp(dev->name, "gbe0"))
1003 info = &__get_cpu_var(hv_gbe0);
1004 else if (!strcmp(dev->name, "gbe1"))
1005 info = &__get_cpu_var(hv_gbe1);
1009 /* Initialize the egress timer. */
1010 init_timer(&info->egress_timer);
1011 info->egress_timer.data = (long)info;
1012 info->egress_timer.function = tile_net_handle_egress_timer;
1014 u64_stats_init(&info->stats.syncp);
1016 priv->cpu[my_cpu] = info;
1019 * Register ourselves with LIPP. This does a lot of stuff,
1020 * including invoking the LIPP registration code.
1022 ret = hv_dev_pwrite(priv->hv_devhdl, 0,
1023 (HV_VirtAddr)&config,
1024 sizeof(netio_input_config_t),
1025 NETIO_IPP_INPUT_REGISTER_OFF);
1026 PDEBUG("hv_dev_pwrite(NETIO_IPP_INPUT_REGISTER_OFF) returned %d\n",
1029 if (ret != NETIO_LINK_DOWN) {
1030 printk(KERN_DEBUG "hv_dev_pwrite "
1031 "NETIO_IPP_INPUT_REGISTER_OFF failure %d\n",
1034 info->link_down = (ret == NETIO_LINK_DOWN);
1039 * Get the pointer to our queue's system part.
1042 ret = hv_dev_pread(priv->hv_devhdl, 0,
1043 (HV_VirtAddr)&queuep,
1044 sizeof(netio_queue_impl_t *),
1045 NETIO_IPP_INPUT_REGISTER_OFF);
1046 PDEBUG("hv_dev_pread(NETIO_IPP_INPUT_REGISTER_OFF) returned %d\n",
1048 PDEBUG("queuep %p\n", queuep);
1050 /* ISSUE: Shouldn't this be a fatal error? */
1051 pr_err("hv_dev_pread NETIO_IPP_INPUT_REGISTER_OFF failure\n");
1055 queue = &info->queue;
1057 queue->__system_part = queuep;
1059 memset(&queue->__user_part, 0, sizeof(netio_queue_user_impl_t));
1061 /* This is traditionally "config.num_receive_packets / 2". */
1062 queue->__user_part.__receive_credit_interval = 4;
1063 queue->__user_part.__receive_credit_remaining =
1064 queue->__user_part.__receive_credit_interval;
1067 * Get a fastio index from the hypervisor.
1068 * ISSUE: Shouldn't this check the result?
1070 ret = hv_dev_pread(priv->hv_devhdl, 0,
1071 (HV_VirtAddr)&queue->__user_part.__fastio_index,
1072 sizeof(queue->__user_part.__fastio_index),
1073 NETIO_IPP_GET_FASTIO_OFF);
1074 PDEBUG("hv_dev_pread(NETIO_IPP_GET_FASTIO_OFF) returned %d\n", ret);
1076 /* Now we are registered. */
1077 info->registered = true;
1082 * Deregister with hypervisor on the current CPU.
1084 * This simply discards all our credits, so no more packets will be
1085 * delivered to this tile. There may still be packets in our queue.
1087 * Also, disable the ingress interrupt.
1089 static void tile_net_deregister(void *dev_ptr)
1091 struct net_device *dev = (struct net_device *)dev_ptr;
1092 struct tile_net_priv *priv = netdev_priv(dev);
1093 int my_cpu = smp_processor_id();
1094 struct tile_net_cpu *info = priv->cpu[my_cpu];
1096 /* Disable the ingress interrupt. */
1097 disable_percpu_irq(priv->intr_id);
1099 /* Do nothing else if not registered. */
1100 if (info == NULL || !info->registered)
1104 struct tile_netio_queue *queue = &info->queue;
1105 netio_queue_user_impl_t *qup = &queue->__user_part;
1107 /* Discard all our credits. */
1108 __netio_fastio_return_credits(qup->__fastio_index, -1);
1114 * Unregister with hypervisor on the current CPU.
1116 * Also, disable the ingress interrupt.
1118 static void tile_net_unregister(void *dev_ptr)
1120 struct net_device *dev = (struct net_device *)dev_ptr;
1121 struct tile_net_priv *priv = netdev_priv(dev);
1122 int my_cpu = smp_processor_id();
1123 struct tile_net_cpu *info = priv->cpu[my_cpu];
1128 /* Disable the ingress interrupt. */
1129 disable_percpu_irq(priv->intr_id);
1131 /* Do nothing else if not registered. */
1132 if (info == NULL || !info->registered)
1135 /* Unregister ourselves with LIPP/LEPP. */
1136 ret = hv_dev_pwrite(priv->hv_devhdl, 0, (HV_VirtAddr)&dummy,
1137 sizeof(dummy), NETIO_IPP_INPUT_UNREGISTER_OFF);
1139 panic("Failed to unregister with LIPP/LEPP!\n");
1141 /* Discard all packets still in our NetIO queue. */
1142 tile_net_discard_packets(dev);
1145 info->num_needed_small_buffers = 0;
1146 info->num_needed_large_buffers = 0;
1148 /* Cancel egress timer. */
1149 del_timer(&info->egress_timer);
1150 info->egress_timer_scheduled = false;
1155 * Helper function for "tile_net_stop()".
1157 * Also used to handle registration failure in "tile_net_open_inner()",
1158 * when the various extra steps in "tile_net_stop()" are not necessary.
1160 static void tile_net_stop_aux(struct net_device *dev)
1162 struct tile_net_priv *priv = netdev_priv(dev);
1168 * Unregister all tiles, so LIPP will stop delivering packets.
1169 * Also, delete all the "napi" objects (sequentially, to protect
1170 * "dev->napi_list").
1172 on_each_cpu(tile_net_unregister, (void *)dev, 1);
1173 for_each_online_cpu(i) {
1174 struct tile_net_cpu *info = priv->cpu[i];
1175 if (info != NULL && info->registered) {
1176 netif_napi_del(&info->napi);
1177 info->registered = false;
1181 /* Stop LIPP/LEPP. */
1182 if (hv_dev_pwrite(priv->hv_devhdl, 0, (HV_VirtAddr)&dummy,
1183 sizeof(dummy), NETIO_IPP_STOP_SHIM_OFF) < 0)
1184 panic("Failed to stop LIPP/LEPP!\n");
1186 priv->partly_opened = false;
1191 * Disable NAPI for the given device on the current cpu.
1193 static void tile_net_stop_disable(void *dev_ptr)
1195 struct net_device *dev = (struct net_device *)dev_ptr;
1196 struct tile_net_priv *priv = netdev_priv(dev);
1197 int my_cpu = smp_processor_id();
1198 struct tile_net_cpu *info = priv->cpu[my_cpu];
1200 /* Disable NAPI if needed. */
1201 if (info != NULL && info->napi_enabled) {
1202 napi_disable(&info->napi);
1203 info->napi_enabled = false;
1209 * Enable NAPI and the ingress interrupt for the given device
1210 * on the current cpu.
1212 * ISSUE: Only do this for "network cpus"?
1214 static void tile_net_open_enable(void *dev_ptr)
1216 struct net_device *dev = (struct net_device *)dev_ptr;
1217 struct tile_net_priv *priv = netdev_priv(dev);
1218 int my_cpu = smp_processor_id();
1219 struct tile_net_cpu *info = priv->cpu[my_cpu];
1222 napi_enable(&info->napi);
1223 info->napi_enabled = true;
1225 /* Enable the ingress interrupt. */
1226 enable_percpu_irq(priv->intr_id, 0);
1231 * tile_net_open_inner does most of the work of bringing up the interface.
1232 * It's called from tile_net_open(), and also from tile_net_retry_open().
1233 * The return value is 0 if the interface was brought up, < 0 if
1234 * tile_net_open() should return the return value as an error, and > 0 if
1235 * tile_net_open() should return success and schedule a work item to
1236 * periodically retry the bringup.
1238 static int tile_net_open_inner(struct net_device *dev)
1240 struct tile_net_priv *priv = netdev_priv(dev);
1241 int my_cpu = smp_processor_id();
1242 struct tile_net_cpu *info;
1243 struct tile_netio_queue *queue;
1249 * First try to register just on the local CPU, and handle any
1250 * semi-expected "link down" failure specially. Note that we
1251 * do NOT call "tile_net_stop_aux()", unlike below.
1253 tile_net_register(dev);
1254 info = priv->cpu[my_cpu];
1255 if (!info->registered) {
1256 if (info->link_down)
1262 * Now register everywhere else. If any registration fails,
1263 * even for "link down" (which might not be possible), we
1264 * clean up using "tile_net_stop_aux()". Also, add all the
1265 * "napi" objects (sequentially, to protect "dev->napi_list").
1266 * ISSUE: Only use "netif_napi_add()" for "network cpus"?
1268 smp_call_function(tile_net_register, (void *)dev, 1);
1269 for_each_online_cpu(i) {
1270 struct tile_net_cpu *info = priv->cpu[i];
1271 if (info->registered)
1272 netif_napi_add(dev, &info->napi, tile_net_poll, 64);
1277 tile_net_stop_aux(dev);
1281 queue = &info->queue;
1283 if (priv->intr_id == 0) {
1287 * Acquire the irq allocated by the hypervisor. Every
1288 * queue gets the same irq. The "__intr_id" field is
1289 * "1 << irq", so we use "__ffs()" to extract "irq".
1291 priv->intr_id = queue->__system_part->__intr_id;
1292 BUG_ON(priv->intr_id == 0);
1293 irq = __ffs(priv->intr_id);
1296 * Register the ingress interrupt handler for this
1297 * device, permanently.
1299 * We used to call "free_irq()" in "tile_net_stop()",
1300 * and then re-register the handler here every time,
1301 * but that caused DNP errors in "handle_IRQ_event()"
1302 * because "desc->action" was NULL. See bug 9143.
1304 tile_irq_activate(irq, TILE_IRQ_PERCPU);
1305 BUG_ON(request_irq(irq, tile_net_handle_ingress_interrupt,
1306 0, dev->name, (void *)dev) != 0);
1310 /* Allocate initial buffers. */
1313 priv->network_cpus_count * priv->network_cpus_credits;
1315 info->num_needed_small_buffers =
1316 min(LIPP_SMALL_BUFFERS, max_buffers);
1318 info->num_needed_large_buffers =
1319 min(LIPP_LARGE_BUFFERS, max_buffers);
1321 tile_net_provide_needed_buffers(info);
1323 if (info->num_needed_small_buffers != 0 ||
1324 info->num_needed_large_buffers != 0)
1325 panic("Insufficient memory for buffer stack!");
1328 /* We are about to be active. */
1329 priv->active = true;
1331 /* Make sure "active" is visible to all tiles. */
1334 /* On each tile, enable NAPI and the ingress interrupt. */
1335 on_each_cpu(tile_net_open_enable, (void *)dev, 1);
1337 /* Start LIPP/LEPP and activate "ingress" at the shim. */
1338 if (hv_dev_pwrite(priv->hv_devhdl, 0, (HV_VirtAddr)&dummy,
1339 sizeof(dummy), NETIO_IPP_INPUT_INIT_OFF) < 0)
1340 panic("Failed to activate the LIPP Shim!\n");
1342 /* Start our transmit queue. */
1343 netif_start_queue(dev);
1350 * Called periodically to retry bringing up the NetIO interface,
1351 * if it doesn't come up cleanly during tile_net_open().
1353 static void tile_net_open_retry(struct work_struct *w)
1355 struct delayed_work *dw =
1356 container_of(w, struct delayed_work, work);
1358 struct tile_net_priv *priv =
1359 container_of(dw, struct tile_net_priv, retry_work);
1362 * Try to bring the NetIO interface up. If it fails, reschedule
1363 * ourselves to try again later; otherwise, tell Linux we now have
1364 * a working link. ISSUE: What if the return value is negative?
1366 if (tile_net_open_inner(priv->dev) != 0)
1367 schedule_delayed_work(&priv->retry_work,
1368 TILE_NET_RETRY_INTERVAL);
1370 netif_carrier_on(priv->dev);
1375 * Called when a network interface is made active.
1377 * Returns 0 on success, negative value on failure.
1379 * The open entry point is called when a network interface is made
1380 * active by the system (IFF_UP). At this point all resources needed
1381 * for transmit and receive operations are allocated, the interrupt
1382 * handler is registered with the OS (if needed), the watchdog timer
1383 * is started, and the stack is notified that the interface is ready.
1385 * If the actual link is not available yet, then we tell Linux that
1386 * we have no carrier, and we keep checking until the link comes up.
1388 static int tile_net_open(struct net_device *dev)
1391 struct tile_net_priv *priv = netdev_priv(dev);
1394 * We rely on priv->partly_opened to tell us if this is the
1395 * first time this interface is being brought up. If it is
1396 * set, the IPP was already initialized and should not be
1397 * initialized again.
1399 if (!priv->partly_opened) {
1404 /* Initialize LIPP/LEPP, and start the Shim. */
1405 ret = tile_net_open_aux(dev);
1407 pr_err("tile_net_open_aux failed: %d\n", ret);
1411 /* Analyze the network cpus. */
1413 if (network_cpus_used)
1414 cpumask_copy(&priv->network_cpus_map,
1417 cpumask_copy(&priv->network_cpus_map, cpu_online_mask);
1420 count = cpumask_weight(&priv->network_cpus_map);
1422 /* Limit credits to available buffers, and apply min. */
1423 credits = max(16, (LIPP_LARGE_BUFFERS / count) & ~1);
1425 /* Apply "GBE" max limit. */
1426 /* ISSUE: Use higher limit for XGBE? */
1427 credits = min(NETIO_MAX_RECEIVE_PKTS, credits);
1429 priv->network_cpus_count = count;
1430 priv->network_cpus_credits = credits;
1432 #ifdef TILE_NET_DEBUG
1433 pr_info("Using %d network cpus, with %d credits each\n",
1434 priv->network_cpus_count, priv->network_cpus_credits);
1437 priv->partly_opened = true;
1440 /* FIXME: Is this possible? */
1441 /* printk("Already partly opened.\n"); */
1445 * Attempt to bring up the link.
1447 ret = tile_net_open_inner(dev);
1450 netif_carrier_on(dev);
1455 * We were unable to bring up the NetIO interface, but we want to
1456 * try again in a little bit. Tell Linux that we have no carrier
1457 * so it doesn't try to use the interface before the link comes up
1458 * and then remember to try again later.
1460 netif_carrier_off(dev);
1461 schedule_delayed_work(&priv->retry_work, TILE_NET_RETRY_INTERVAL);
1467 static int tile_net_drain_lipp_buffers(struct tile_net_priv *priv)
1471 /* Drain all the LIPP buffers. */
1473 unsigned int buffer;
1475 /* NOTE: This should never fail. */
1476 if (hv_dev_pread(priv->hv_devhdl, 0, (HV_VirtAddr)&buffer,
1477 sizeof(buffer), NETIO_IPP_DRAIN_OFF) < 0)
1480 /* Stop when done. */
1485 /* Convert "linux_buffer_t" to "va". */
1486 void *va = __va((phys_addr_t)(buffer >> 1) << 7);
1488 /* Acquire the associated "skb". */
1489 struct sk_buff **skb_ptr = va - sizeof(*skb_ptr);
1490 struct sk_buff *skb = *skb_ptr;
1503 * Disables a network interface.
1505 * Returns 0, this is not allowed to fail.
1507 * The close entry point is called when an interface is de-activated
1508 * by the OS. The hardware is still under the drivers control, but
1509 * needs to be disabled. A global MAC reset is issued to stop the
1510 * hardware, and all transmit and receive resources are freed.
1512 * ISSUE: How closely does "netif_running(dev)" mirror "priv->active"?
1514 * Before we are called by "__dev_close()", "netif_running()" will
1515 * have been cleared, so no NEW calls to "tile_net_poll()" will be
1516 * made by "netpoll_poll_dev()".
1518 * Often, this can cause some tiles to still have packets in their
1519 * queues, so we must call "tile_net_discard_packets()" later.
1521 * Note that some other tile may still be INSIDE "tile_net_poll()",
1522 * and in fact, many will be, if there is heavy network load.
1524 * Calling "on_each_cpu(tile_net_stop_disable, (void *)dev, 1)" when
1525 * any tile is still "napi_schedule()"'d will induce a horrible crash
1526 * when "msleep()" is called. This includes tiles which are inside
1527 * "tile_net_poll()" which have not yet called "napi_complete()".
1529 * So, we must first try to wait long enough for other tiles to finish
1530 * with any current "tile_net_poll()" call, and, hopefully, to clear
1531 * the "scheduled" flag. ISSUE: It is unclear what happens to tiles
1532 * which have called "napi_schedule()" but which had not yet tried to
1533 * call "tile_net_poll()", or which exhausted their budget inside
1534 * "tile_net_poll()" just before this function was called.
1536 static int tile_net_stop(struct net_device *dev)
1538 struct tile_net_priv *priv = netdev_priv(dev);
1540 PDEBUG("tile_net_stop()\n");
1542 /* Start discarding packets. */
1543 priv->active = false;
1545 /* Make sure "active" is visible to all tiles. */
1549 * On each tile, make sure no NEW packets get delivered, and
1550 * disable the ingress interrupt.
1552 * Note that the ingress interrupt can fire AFTER this,
1553 * presumably due to packets which were recently delivered,
1554 * but it will have no effect.
1556 on_each_cpu(tile_net_deregister, (void *)dev, 1);
1558 /* Optimistically drain LIPP buffers. */
1559 (void)tile_net_drain_lipp_buffers(priv);
1561 /* ISSUE: Only needed if not yet fully open. */
1562 cancel_delayed_work_sync(&priv->retry_work);
1564 /* Can't transmit any more. */
1565 netif_stop_queue(dev);
1567 /* Disable NAPI on each tile. */
1568 on_each_cpu(tile_net_stop_disable, (void *)dev, 1);
1571 * Drain any remaining LIPP buffers. NOTE: This "printk()"
1572 * has never been observed, but in theory it could happen.
1574 if (tile_net_drain_lipp_buffers(priv) != 0)
1575 printk("Had to drain some extra LIPP buffers!\n");
1577 /* Stop LIPP/LEPP. */
1578 tile_net_stop_aux(dev);
1581 * ISSUE: It appears that, in practice anyway, by the time we
1582 * get here, there are no pending completions, but just in case,
1583 * we free (all of) them anyway.
1585 while (tile_net_lepp_free_comps(dev, true))
1588 /* Wipe the EPP queue, and wait till the stores hit the EPP. */
1589 memset(priv->eq, 0, sizeof(lepp_queue_t));
1597 * Prepare the "frags" info for the resulting LEPP command.
1599 * If needed, flush the memory used by the frags.
1601 static unsigned int tile_net_tx_frags(lepp_frag_t *frags,
1602 struct sk_buff *skb,
1603 void *b_data, unsigned int b_len)
1605 unsigned int i, n = 0;
1607 struct skb_shared_info *sh = skb_shinfo(skb);
1614 finv_buffer_remote(b_data, b_len, 0);
1617 frags[n].cpa_lo = cpa;
1618 frags[n].cpa_hi = cpa >> 32;
1619 frags[n].length = b_len;
1620 frags[n].hash_for_home = hash_default;
1624 for (i = 0; i < sh->nr_frags; i++) {
1626 skb_frag_t *f = &sh->frags[i];
1627 unsigned long pfn = page_to_pfn(skb_frag_page(f));
1629 /* FIXME: Compute "hash_for_home" properly. */
1630 /* ISSUE: The hypervisor checks CHIP_HAS_REV1_DMA_PACKETS(). */
1631 int hash_for_home = hash_default;
1634 if (!hash_default) {
1635 void *va = pfn_to_kaddr(pfn) + f->page_offset;
1636 BUG_ON(PageHighMem(skb_frag_page(f)));
1637 finv_buffer_remote(va, skb_frag_size(f), 0);
1640 cpa = ((phys_addr_t)pfn << PAGE_SHIFT) + f->page_offset;
1641 frags[n].cpa_lo = cpa;
1642 frags[n].cpa_hi = cpa >> 32;
1643 frags[n].length = skb_frag_size(f);
1644 frags[n].hash_for_home = hash_for_home;
1653 * This function takes "skb", consisting of a header template and a
1654 * payload, and hands it to LEPP, to emit as one or more segments,
1655 * each consisting of a possibly modified header, plus a piece of the
1656 * payload, via a process known as "tcp segmentation offload".
1658 * Usually, "data" will contain the header template, of size "sh_len",
1659 * and "sh->frags" will contain "skb->data_len" bytes of payload, and
1660 * there will be "sh->gso_segs" segments.
1662 * Sometimes, if "sendfile()" requires copying, we will be called with
1663 * "data" containing the header and payload, with "frags" being empty.
1665 * Sometimes, for example when using NFS over TCP, a single segment can
1666 * span 3 fragments, which must be handled carefully in LEPP.
1668 * See "emulate_large_send_offload()" for some reference code, which
1669 * does not handle checksumming.
1671 * ISSUE: How do we make sure that high memory DMA does not migrate?
1673 static int tile_net_tx_tso(struct sk_buff *skb, struct net_device *dev)
1675 struct tile_net_priv *priv = netdev_priv(dev);
1676 int my_cpu = smp_processor_id();
1677 struct tile_net_cpu *info = priv->cpu[my_cpu];
1678 struct tile_net_stats_t *stats = &info->stats;
1680 struct skb_shared_info *sh = skb_shinfo(skb);
1682 unsigned char *data = skb->data;
1684 /* The ip header follows the ethernet header. */
1685 struct iphdr *ih = ip_hdr(skb);
1686 unsigned int ih_len = ih->ihl * 4;
1688 /* Note that "nh == ih", by definition. */
1689 unsigned char *nh = skb_network_header(skb);
1690 unsigned int eh_len = nh - data;
1692 /* The tcp header follows the ip header. */
1693 struct tcphdr *th = (struct tcphdr *)(nh + ih_len);
1694 unsigned int th_len = th->doff * 4;
1696 /* The total number of header bytes. */
1697 /* NOTE: This may be less than skb_headlen(skb). */
1698 unsigned int sh_len = eh_len + ih_len + th_len;
1700 /* The number of payload bytes at "skb->data + sh_len". */
1701 /* This is non-zero for sendfile() without HIGHDMA. */
1702 unsigned int b_len = skb_headlen(skb) - sh_len;
1704 /* The total number of payload bytes. */
1705 unsigned int d_len = b_len + skb->data_len;
1707 /* The maximum payload size. */
1708 unsigned int p_len = sh->gso_size;
1710 /* The total number of segments. */
1711 unsigned int num_segs = sh->gso_segs;
1713 /* The temporary copy of the command. */
1714 u32 cmd_body[(LEPP_MAX_CMD_SIZE + 3) / 4];
1715 lepp_tso_cmd_t *cmd = (lepp_tso_cmd_t *)cmd_body;
1717 /* Analyze the "frags". */
1718 unsigned int num_frags =
1719 tile_net_tx_frags(cmd->frags, skb, data + sh_len, b_len);
1721 /* The size of the command, including frags and header. */
1722 size_t cmd_size = LEPP_TSO_CMD_SIZE(num_frags, sh_len);
1724 /* The command header. */
1725 lepp_tso_cmd_t cmd_init = {
1727 .header_size = sh_len,
1728 .ip_offset = eh_len,
1729 .tcp_offset = eh_len + ih_len,
1730 .payload_size = p_len,
1731 .num_frags = num_frags,
1734 unsigned long irqflags;
1736 lepp_queue_t *eq = priv->eq;
1738 struct sk_buff *olds[8];
1739 unsigned int wanted = 8;
1740 unsigned int i, nolds = 0;
1742 unsigned int cmd_head, cmd_tail, cmd_next;
1743 unsigned int comp_tail;
1747 BUG_ON(skb->protocol != htons(ETH_P_IP));
1748 BUG_ON(ih->protocol != IPPROTO_TCP);
1749 BUG_ON(skb->ip_summed != CHECKSUM_PARTIAL);
1750 BUG_ON(num_frags > LEPP_MAX_FRAGS);
1751 /*--BUG_ON(num_segs != (d_len + (p_len - 1)) / p_len); */
1752 BUG_ON(num_segs <= 1);
1755 /* Finish preparing the command. */
1757 /* Copy the command header. */
1760 /* Copy the "header". */
1761 memcpy(&cmd->frags[num_frags], data, sh_len);
1764 /* Prefetch and wait, to minimize time spent holding the spinlock. */
1765 prefetch_L1(&eq->comp_tail);
1766 prefetch_L1(&eq->cmd_tail);
1770 /* Enqueue the command. */
1772 spin_lock_irqsave(&priv->eq_lock, irqflags);
1774 /* Handle completions if needed to make room. */
1775 /* NOTE: Return NETDEV_TX_BUSY if there is still no room. */
1776 if (lepp_num_free_comp_slots(eq) == 0) {
1777 nolds = tile_net_lepp_grab_comps(eq, olds, wanted, 0);
1780 spin_unlock_irqrestore(&priv->eq_lock, irqflags);
1781 return NETDEV_TX_BUSY;
1785 cmd_head = eq->cmd_head;
1786 cmd_tail = eq->cmd_tail;
1788 /* Prepare to advance, detecting full queue. */
1789 /* NOTE: Return NETDEV_TX_BUSY if the queue is full. */
1790 cmd_next = cmd_tail + cmd_size;
1791 if (cmd_tail < cmd_head && cmd_next >= cmd_head)
1793 if (cmd_next > LEPP_CMD_LIMIT) {
1795 if (cmd_next == cmd_head)
1799 /* Copy the command. */
1800 memcpy(&eq->cmds[cmd_tail], cmd, cmd_size);
1803 cmd_tail = cmd_next;
1805 /* Record "skb" for eventual freeing. */
1806 comp_tail = eq->comp_tail;
1807 eq->comps[comp_tail] = skb;
1808 LEPP_QINC(comp_tail);
1809 eq->comp_tail = comp_tail;
1811 /* Flush before allowing LEPP to handle the command. */
1812 /* ISSUE: Is this the optimal location for the flush? */
1815 eq->cmd_tail = cmd_tail;
1817 /* NOTE: Using "4" here is more efficient than "0" or "2", */
1818 /* and, strangely, more efficient than pre-checking the number */
1819 /* of available completions, and comparing it to 4. */
1821 nolds = tile_net_lepp_grab_comps(eq, olds, wanted, 4);
1823 spin_unlock_irqrestore(&priv->eq_lock, irqflags);
1825 /* Handle completions. */
1826 for (i = 0; i < nolds; i++)
1827 dev_consume_skb_any(olds[i]);
1830 u64_stats_update_begin(&stats->syncp);
1831 stats->tx_packets += num_segs;
1832 stats->tx_bytes += (num_segs * sh_len) + d_len;
1833 u64_stats_update_end(&stats->syncp);
1835 /* Make sure the egress timer is scheduled. */
1836 tile_net_schedule_egress_timer(info);
1838 return NETDEV_TX_OK;
1843 * Transmit a packet (called by the kernel via "hard_start_xmit" hook).
1845 static int tile_net_tx(struct sk_buff *skb, struct net_device *dev)
1847 struct tile_net_priv *priv = netdev_priv(dev);
1848 int my_cpu = smp_processor_id();
1849 struct tile_net_cpu *info = priv->cpu[my_cpu];
1850 struct tile_net_stats_t *stats = &info->stats;
1852 unsigned long irqflags;
1854 struct skb_shared_info *sh = skb_shinfo(skb);
1856 unsigned int len = skb->len;
1857 unsigned char *data = skb->data;
1859 unsigned int csum_start = skb_checksum_start_offset(skb);
1861 lepp_frag_t frags[1 + MAX_SKB_FRAGS];
1863 unsigned int num_frags;
1865 lepp_queue_t *eq = priv->eq;
1867 struct sk_buff *olds[8];
1868 unsigned int wanted = 8;
1869 unsigned int i, nolds = 0;
1871 unsigned int cmd_size = sizeof(lepp_cmd_t);
1873 unsigned int cmd_head, cmd_tail, cmd_next;
1874 unsigned int comp_tail;
1876 lepp_cmd_t cmds[1 + MAX_SKB_FRAGS];
1880 * This is paranoia, since we think that if the link doesn't come
1881 * up, telling Linux we have no carrier will keep it from trying
1882 * to transmit. If it does, though, we can't execute this routine,
1883 * since data structures we depend on aren't set up yet.
1885 if (!info->registered)
1886 return NETDEV_TX_BUSY;
1889 /* Save the timestamp. */
1890 dev->trans_start = jiffies;
1893 #ifdef TILE_NET_PARANOIA
1894 #if CHIP_HAS_CBOX_HOME_MAP()
1896 HV_PTE pte = *virt_to_pte(current->mm, (unsigned long)data);
1897 if (hv_pte_get_mode(pte) != HV_PTE_MODE_CACHE_HASH_L3)
1898 panic("Non-HFH egress buffer! VA=%p Mode=%d PTE=%llx",
1899 data, hv_pte_get_mode(pte), hv_pte_val(pte));
1905 #ifdef TILE_NET_DUMP_PACKETS
1906 /* ISSUE: Does not dump the "frags". */
1907 dump_packet(data, skb_headlen(skb), "tx");
1908 #endif /* TILE_NET_DUMP_PACKETS */
1911 if (sh->gso_size != 0)
1912 return tile_net_tx_tso(skb, dev);
1915 /* Prepare the commands. */
1917 num_frags = tile_net_tx_frags(frags, skb, data, skb_headlen(skb));
1919 for (i = 0; i < num_frags; i++) {
1921 bool final = (i == num_frags - 1);
1924 .cpa_lo = frags[i].cpa_lo,
1925 .cpa_hi = frags[i].cpa_hi,
1926 .length = frags[i].length,
1927 .hash_for_home = frags[i].hash_for_home,
1928 .send_completion = final,
1929 .end_of_packet = final
1932 if (i == 0 && skb->ip_summed == CHECKSUM_PARTIAL) {
1933 cmd.compute_checksum = 1;
1934 cmd.checksum_data.bits.start_byte = csum_start;
1935 cmd.checksum_data.bits.count = len - csum_start;
1936 cmd.checksum_data.bits.destination_byte =
1937 csum_start + skb->csum_offset;
1944 /* Prefetch and wait, to minimize time spent holding the spinlock. */
1945 prefetch_L1(&eq->comp_tail);
1946 prefetch_L1(&eq->cmd_tail);
1950 /* Enqueue the commands. */
1952 spin_lock_irqsave(&priv->eq_lock, irqflags);
1954 /* Handle completions if needed to make room. */
1955 /* NOTE: Return NETDEV_TX_BUSY if there is still no room. */
1956 if (lepp_num_free_comp_slots(eq) == 0) {
1957 nolds = tile_net_lepp_grab_comps(eq, olds, wanted, 0);
1960 spin_unlock_irqrestore(&priv->eq_lock, irqflags);
1961 return NETDEV_TX_BUSY;
1965 cmd_head = eq->cmd_head;
1966 cmd_tail = eq->cmd_tail;
1968 /* Copy the commands, or fail. */
1969 /* NOTE: Return NETDEV_TX_BUSY if the queue is full. */
1970 for (i = 0; i < num_frags; i++) {
1972 /* Prepare to advance, detecting full queue. */
1973 cmd_next = cmd_tail + cmd_size;
1974 if (cmd_tail < cmd_head && cmd_next >= cmd_head)
1976 if (cmd_next > LEPP_CMD_LIMIT) {
1978 if (cmd_next == cmd_head)
1982 /* Copy the command. */
1983 *(lepp_cmd_t *)&eq->cmds[cmd_tail] = cmds[i];
1986 cmd_tail = cmd_next;
1989 /* Record "skb" for eventual freeing. */
1990 comp_tail = eq->comp_tail;
1991 eq->comps[comp_tail] = skb;
1992 LEPP_QINC(comp_tail);
1993 eq->comp_tail = comp_tail;
1995 /* Flush before allowing LEPP to handle the command. */
1996 /* ISSUE: Is this the optimal location for the flush? */
1999 eq->cmd_tail = cmd_tail;
2001 /* NOTE: Using "4" here is more efficient than "0" or "2", */
2002 /* and, strangely, more efficient than pre-checking the number */
2003 /* of available completions, and comparing it to 4. */
2005 nolds = tile_net_lepp_grab_comps(eq, olds, wanted, 4);
2007 spin_unlock_irqrestore(&priv->eq_lock, irqflags);
2009 /* Handle completions. */
2010 for (i = 0; i < nolds; i++)
2011 dev_consume_skb_any(olds[i]);
2013 /* HACK: Track "expanded" size for short packets (e.g. 42 < 60). */
2014 u64_stats_update_begin(&stats->syncp);
2015 stats->tx_packets++;
2016 stats->tx_bytes += ((len >= ETH_ZLEN) ? len : ETH_ZLEN);
2017 u64_stats_update_end(&stats->syncp);
2019 /* Make sure the egress timer is scheduled. */
2020 tile_net_schedule_egress_timer(info);
2022 return NETDEV_TX_OK;
2027 * Deal with a transmit timeout.
2029 static void tile_net_tx_timeout(struct net_device *dev)
2031 PDEBUG("tile_net_tx_timeout()\n");
2032 PDEBUG("Transmit timeout at %ld, latency %ld\n", jiffies,
2033 jiffies - dev->trans_start);
2035 /* XXX: ISSUE: This doesn't seem useful for us. */
2036 netif_wake_queue(dev);
2043 static int tile_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2050 * Get System Network Statistics.
2052 * Returns the address of the device statistics structure.
2054 static struct rtnl_link_stats64 *tile_net_get_stats64(struct net_device *dev,
2055 struct rtnl_link_stats64 *stats)
2057 struct tile_net_priv *priv = netdev_priv(dev);
2058 u64 rx_packets = 0, tx_packets = 0;
2059 u64 rx_bytes = 0, tx_bytes = 0;
2060 u64 rx_errors = 0, rx_dropped = 0;
2063 for_each_online_cpu(i) {
2064 struct tile_net_stats_t *cpu_stats;
2065 u64 trx_packets, ttx_packets, trx_bytes, ttx_bytes;
2066 u64 trx_errors, trx_dropped;
2069 if (priv->cpu[i] == NULL)
2071 cpu_stats = &priv->cpu[i]->stats;
2074 start = u64_stats_fetch_begin_irq(&cpu_stats->syncp);
2075 trx_packets = cpu_stats->rx_packets;
2076 ttx_packets = cpu_stats->tx_packets;
2077 trx_bytes = cpu_stats->rx_bytes;
2078 ttx_bytes = cpu_stats->tx_bytes;
2079 trx_errors = cpu_stats->rx_errors;
2080 trx_dropped = cpu_stats->rx_dropped;
2081 } while (u64_stats_fetch_retry_irq(&cpu_stats->syncp, start));
2083 rx_packets += trx_packets;
2084 tx_packets += ttx_packets;
2085 rx_bytes += trx_bytes;
2086 tx_bytes += ttx_bytes;
2087 rx_errors += trx_errors;
2088 rx_dropped += trx_dropped;
2091 stats->rx_packets = rx_packets;
2092 stats->tx_packets = tx_packets;
2093 stats->rx_bytes = rx_bytes;
2094 stats->tx_bytes = tx_bytes;
2095 stats->rx_errors = rx_errors;
2096 stats->rx_dropped = rx_dropped;
2105 * The "change_mtu" method is usually not needed.
2106 * If you need it, it must be like this.
2108 static int tile_net_change_mtu(struct net_device *dev, int new_mtu)
2110 PDEBUG("tile_net_change_mtu()\n");
2113 if ((new_mtu < 68) || (new_mtu > 1500))
2116 /* Accept the value. */
2124 * Change the Ethernet Address of the NIC.
2126 * The hypervisor driver does not support changing MAC address. However,
2127 * the IPP does not do anything with the MAC address, so the address which
2128 * gets used on outgoing packets, and which is accepted on incoming packets,
2129 * is completely up to the NetIO program or kernel driver which is actually
2132 * Returns 0 on success, negative on failure.
2134 static int tile_net_set_mac_address(struct net_device *dev, void *p)
2136 struct sockaddr *addr = p;
2138 if (!is_valid_ether_addr(addr->sa_data))
2139 return -EADDRNOTAVAIL;
2141 /* ISSUE: Note that "dev_addr" is now a pointer. */
2142 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
2149 * Obtain the MAC address from the hypervisor.
2150 * This must be done before opening the device.
2152 static int tile_net_get_mac(struct net_device *dev)
2154 struct tile_net_priv *priv = netdev_priv(dev);
2156 char hv_dev_name[32];
2159 __netio_getset_offset_t offset = { .word = NETIO_IPP_PARAM_OFF };
2163 /* For example, "xgbe0". */
2164 strcpy(hv_dev_name, dev->name);
2165 len = strlen(hv_dev_name);
2167 /* For example, "xgbe/0". */
2168 hv_dev_name[len] = hv_dev_name[len - 1];
2169 hv_dev_name[len - 1] = '/';
2172 /* For example, "xgbe/0/native_hash". */
2173 strcpy(hv_dev_name + len, hash_default ? "/native_hash" : "/native");
2175 /* Get the hypervisor handle for this device. */
2176 priv->hv_devhdl = hv_dev_open((HV_VirtAddr)hv_dev_name, 0);
2177 PDEBUG("hv_dev_open(%s) returned %d %p\n",
2178 hv_dev_name, priv->hv_devhdl, &priv->hv_devhdl);
2179 if (priv->hv_devhdl < 0) {
2180 if (priv->hv_devhdl == HV_ENODEV)
2181 printk(KERN_DEBUG "Ignoring unconfigured device %s\n",
2184 printk(KERN_DEBUG "hv_dev_open(%s) returned %d\n",
2185 hv_dev_name, priv->hv_devhdl);
2190 * Read the hardware address from the hypervisor.
2191 * ISSUE: Note that "dev_addr" is now a pointer.
2193 offset.bits.class = NETIO_PARAM;
2194 offset.bits.addr = NETIO_PARAM_MAC;
2195 ret = hv_dev_pread(priv->hv_devhdl, 0,
2196 (HV_VirtAddr)dev->dev_addr, dev->addr_len,
2198 PDEBUG("hv_dev_pread(NETIO_PARAM_MAC) returned %d\n", ret);
2200 printk(KERN_DEBUG "hv_dev_pread(NETIO_PARAM_MAC) %s failed\n",
2203 * Since the device is configured by the hypervisor but we
2204 * can't get its MAC address, we are most likely running
2205 * the simulator, so let's generate a random MAC address.
2207 eth_hw_addr_random(dev);
2214 #ifdef CONFIG_NET_POLL_CONTROLLER
2216 * Polling 'interrupt' - used by things like netconsole to send skbs
2217 * without having to re-enable interrupts. It's not called while
2218 * the interrupt routine is executing.
2220 static void tile_net_netpoll(struct net_device *dev)
2222 struct tile_net_priv *priv = netdev_priv(dev);
2223 disable_percpu_irq(priv->intr_id);
2224 tile_net_handle_ingress_interrupt(priv->intr_id, dev);
2225 enable_percpu_irq(priv->intr_id, 0);
2230 static const struct net_device_ops tile_net_ops = {
2231 .ndo_open = tile_net_open,
2232 .ndo_stop = tile_net_stop,
2233 .ndo_start_xmit = tile_net_tx,
2234 .ndo_do_ioctl = tile_net_ioctl,
2235 .ndo_get_stats64 = tile_net_get_stats64,
2236 .ndo_change_mtu = tile_net_change_mtu,
2237 .ndo_tx_timeout = tile_net_tx_timeout,
2238 .ndo_set_mac_address = tile_net_set_mac_address,
2239 #ifdef CONFIG_NET_POLL_CONTROLLER
2240 .ndo_poll_controller = tile_net_netpoll,
2246 * The setup function.
2248 * This uses ether_setup() to assign various fields in dev, including
2249 * setting IFF_BROADCAST and IFF_MULTICAST, then sets some extra fields.
2251 static void tile_net_setup(struct net_device *dev)
2253 netdev_features_t features = 0;
2256 dev->netdev_ops = &tile_net_ops;
2257 dev->watchdog_timeo = TILE_NET_TIMEOUT;
2258 dev->tx_queue_len = TILE_NET_TX_QUEUE_LEN;
2259 dev->mtu = TILE_NET_MTU;
2261 features |= NETIF_F_HW_CSUM;
2262 features |= NETIF_F_SG;
2264 /* We support TSO iff the HV supports sufficient frags. */
2265 if (LEPP_MAX_FRAGS >= 1 + MAX_SKB_FRAGS)
2266 features |= NETIF_F_TSO;
2268 /* We can't support HIGHDMA without hash_default, since we need
2269 * to be able to finv() with a VA if we don't have hash_default.
2272 features |= NETIF_F_HIGHDMA;
2274 dev->hw_features |= features;
2275 dev->vlan_features |= features;
2276 dev->features |= features;
2281 * Allocate the device structure, register the device, and obtain the
2282 * MAC address from the hypervisor.
2284 static struct net_device *tile_net_dev_init(const char *name)
2287 struct net_device *dev;
2288 struct tile_net_priv *priv;
2291 * Allocate the device structure. This allocates "priv", calls
2292 * tile_net_setup(), and saves "name". Normally, "name" is a
2293 * template, instantiated by register_netdev(), but not for us.
2295 dev = alloc_netdev(sizeof(*priv), name, NET_NAME_UNKNOWN,
2298 pr_err("alloc_netdev(%s) failed\n", name);
2302 priv = netdev_priv(dev);
2304 /* Initialize "priv". */
2306 memset(priv, 0, sizeof(*priv));
2308 /* Save "dev" for "tile_net_open_retry()". */
2311 INIT_DELAYED_WORK(&priv->retry_work, tile_net_open_retry);
2313 spin_lock_init(&priv->eq_lock);
2315 /* Allocate "eq". */
2316 priv->eq_pages = alloc_pages(GFP_KERNEL | __GFP_ZERO, EQ_ORDER);
2317 if (!priv->eq_pages) {
2321 priv->eq = page_address(priv->eq_pages);
2323 /* Register the network device. */
2324 ret = register_netdev(dev);
2326 pr_err("register_netdev %s failed %d\n", dev->name, ret);
2327 __free_pages(priv->eq_pages, EQ_ORDER);
2332 /* Get the MAC address. */
2333 ret = tile_net_get_mac(dev);
2335 unregister_netdev(dev);
2336 __free_pages(priv->eq_pages, EQ_ORDER);
2348 * FIXME: If compiled as a module, this module cannot be "unloaded",
2349 * because the "ingress interrupt handler" is registered permanently.
2351 static void tile_net_cleanup(void)
2355 for (i = 0; i < TILE_NET_DEVS; i++) {
2356 if (tile_net_devs[i]) {
2357 struct net_device *dev = tile_net_devs[i];
2358 struct tile_net_priv *priv = netdev_priv(dev);
2359 unregister_netdev(dev);
2360 finv_buffer_remote(priv->eq, EQ_SIZE, 0);
2361 __free_pages(priv->eq_pages, EQ_ORDER);
2369 * Module initialization.
2371 static int tile_net_init_module(void)
2373 pr_info("Tilera Network Driver\n");
2375 tile_net_devs[0] = tile_net_dev_init("xgbe0");
2376 tile_net_devs[1] = tile_net_dev_init("xgbe1");
2377 tile_net_devs[2] = tile_net_dev_init("gbe0");
2378 tile_net_devs[3] = tile_net_dev_init("gbe1");
2384 module_init(tile_net_init_module);
2385 module_exit(tile_net_cleanup);
2391 * The "network_cpus" boot argument specifies the cpus that are dedicated
2392 * to handle ingress packets.
2394 * The parameter should be in the form "network_cpus=m-n[,x-y]", where
2395 * m, n, x, y are integer numbers that represent the cpus that can be
2396 * neither a dedicated cpu nor a dataplane cpu.
2398 static int __init network_cpus_setup(char *str)
2400 int rc = cpulist_parse_crop(str, &network_cpus_map);
2402 pr_warning("network_cpus=%s: malformed cpu list\n",
2406 /* Remove dedicated cpus. */
2407 cpumask_and(&network_cpus_map, &network_cpus_map,
2411 if (cpumask_empty(&network_cpus_map)) {
2412 pr_warning("Ignoring network_cpus='%s'.\n",
2416 cpulist_scnprintf(buf, sizeof(buf), &network_cpus_map);
2417 pr_info("Linux network CPUs: %s\n", buf);
2418 network_cpus_used = true;
2424 __setup("network_cpus=", network_cpus_setup);