Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tile: support multiple mPIPE shims in tilegx network driver

The initial driver support was for a single mPIPE shim on the chip
(as is the case for the Gx36 hardware). The Gx72 chip has two mPIPE
shims, so we extend the driver to handle that case.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Chris Metcalf and committed by
David S. Miller
f3286a3a 6ab4ae9a

+416 -211
+18
arch/tile/gxio/iorpc_mpipe_info.c
··· 16 16 #include "gxio/iorpc_mpipe_info.h" 17 17 18 18 19 + struct instance_aux_param { 20 + _gxio_mpipe_link_name_t name; 21 + }; 22 + 23 + int gxio_mpipe_info_instance_aux(gxio_mpipe_info_context_t * context, 24 + _gxio_mpipe_link_name_t name) 25 + { 26 + struct instance_aux_param temp; 27 + struct instance_aux_param *params = &temp; 28 + 29 + params->name = name; 30 + 31 + return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params, 32 + sizeof(*params), GXIO_MPIPE_INFO_OP_INSTANCE_AUX); 33 + } 34 + 35 + EXPORT_SYMBOL(gxio_mpipe_info_instance_aux); 36 + 19 37 struct enumerate_aux_param { 20 38 _gxio_mpipe_link_name_t name; 21 39 _gxio_mpipe_link_mac_t mac;
+23 -2
arch/tile/gxio/mpipe.c
··· 36 36 int fd; 37 37 int i; 38 38 39 + if (mpipe_index >= GXIO_MPIPE_INSTANCE_MAX) 40 + return -EINVAL; 41 + 39 42 snprintf(file, sizeof(file), "mpipe/%d/iorpc", mpipe_index); 40 43 fd = hv_dev_open((HV_VirtAddr) file, 0); 44 + 45 + context->fd = fd; 46 + 41 47 if (fd < 0) { 42 48 if (fd >= GXIO_ERR_MIN && fd <= GXIO_ERR_MAX) 43 49 return fd; 44 50 else 45 51 return -ENODEV; 46 52 } 47 - 48 - context->fd = fd; 49 53 50 54 /* Map in the MMIO space. */ 51 55 context->mmio_cfg_base = (void __force *) ··· 68 64 for (i = 0; i < 8; i++) 69 65 context->__stacks.stacks[i] = 255; 70 66 67 + context->instance = mpipe_index; 68 + 71 69 return 0; 72 70 73 71 fast_failed: 74 72 iounmap((void __force __iomem *)(context->mmio_cfg_base)); 75 73 cfg_failed: 76 74 hv_dev_close(context->fd); 75 + context->fd = -1; 77 76 return -ENODEV; 78 77 } 79 78 ··· 501 494 mutex_unlock(&mutex); 502 495 503 496 return contextp; 497 + } 498 + 499 + int gxio_mpipe_link_instance(const char *link_name) 500 + { 501 + _gxio_mpipe_link_name_t name; 502 + gxio_mpipe_context_t *context = _gxio_get_link_context(); 503 + 504 + if (!context) 505 + return GXIO_ERR_NO_DEVICE; 506 + 507 + strncpy(name.name, link_name, sizeof(name.name)); 508 + name.name[GXIO_MPIPE_LINK_NAME_LEN - 1] = '\0'; 509 + 510 + return gxio_mpipe_info_instance_aux(context, name); 504 511 } 505 512 506 513 int gxio_mpipe_link_enumerate_mac(int idx, char *link_name, uint8_t *link_mac)
+4
arch/tile/include/gxio/iorpc_mpipe_info.h
··· 27 27 #include <asm/pgtable.h> 28 28 29 29 30 + #define GXIO_MPIPE_INFO_OP_INSTANCE_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1250) 30 31 #define GXIO_MPIPE_INFO_OP_ENUMERATE_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1251) 31 32 #define GXIO_MPIPE_INFO_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000) 32 33 #define GXIO_MPIPE_INFO_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001) 33 34 35 + 36 + int gxio_mpipe_info_instance_aux(gxio_mpipe_info_context_t * context, 37 + _gxio_mpipe_link_name_t name); 34 38 35 39 int gxio_mpipe_info_enumerate_aux(gxio_mpipe_info_context_t * context, 36 40 unsigned int idx,
+28
arch/tile/include/gxio/mpipe.h
··· 220 220 */ 221 221 typedef MPIPE_EDMA_DESC_t gxio_mpipe_edesc_t; 222 222 223 + /* 224 + * Max # of mpipe instances. 2 currently. 225 + */ 226 + #define GXIO_MPIPE_INSTANCE_MAX HV_MPIPE_INSTANCE_MAX 227 + 228 + #define NR_MPIPE_MAX GXIO_MPIPE_INSTANCE_MAX 229 + 223 230 /* Get the "va" field from an "idesc". 224 231 * 225 232 * This is the address at which the ingress hardware copied the first ··· 317 310 318 311 /* File descriptor for calling up to Linux (and thus the HV). */ 319 312 int fd; 313 + 314 + /* Corresponding mpipe instance #. */ 315 + int instance; 320 316 321 317 /* The VA at which configuration registers are mapped. */ 322 318 char *mmio_cfg_base; ··· 1725 1715 /* The MAC index used by this link. */ 1726 1716 uint8_t mac; 1727 1717 } gxio_mpipe_link_t; 1718 + 1719 + /* Translate a link name to the instance number of the mPIPE shim which is 1720 + * connected to that link. This call does not verify whether the link is 1721 + * currently available, and does not reserve any link resources; 1722 + * gxio_mpipe_link_open() must be called to perform those functions. 1723 + * 1724 + * Typically applications will call this function to translate a link name 1725 + * to an mPIPE instance number; call gxio_mpipe_init(), passing it that 1726 + * instance number, to initialize the mPIPE shim; and then call 1727 + * gxio_mpipe_link_open(), passing it the same link name plus the mPIPE 1728 + * context, to configure the link. 1729 + * 1730 + * @param link_name Name of the link; see @ref gxio_mpipe_link_names. 1731 + * @return The mPIPE instance number which is associated with the named 1732 + * link, or a negative error code (::GXIO_ERR_NO_DEVICE) if the link does 1733 + * not exist. 1734 + */ 1735 + extern int gxio_mpipe_link_instance(const char *link_name); 1728 1736 1729 1737 /* Retrieve one of this system's legal link names, and its MAC address. 1730 1738 *
+3
arch/tile/include/hv/drv_mpipe_intf.h
··· 23 23 #include <arch/mpipe_constants.h> 24 24 25 25 26 + /** Number of mPIPE instances supported */ 27 + #define HV_MPIPE_INSTANCE_MAX (2) 28 + 26 29 /** Number of buffer stacks (32). */ 27 30 #define HV_MPIPE_NUM_BUFFER_STACKS \ 28 31 (MPIPE_MMIO_INIT_DAT_GX36_1__BUFFER_STACK_MASK_WIDTH)
+340 -209
drivers/net/ethernet/tile/tilegx.c
··· 133 133 134 134 /* Info for a specific cpu. */ 135 135 struct tile_net_info { 136 - /* The NAPI struct. */ 137 - struct napi_struct napi; 138 - /* Packet queue. */ 139 - gxio_mpipe_iqueue_t iqueue; 140 136 /* Our cpu. */ 141 137 int my_cpu; 142 - /* True if iqueue is valid. */ 143 - bool has_iqueue; 144 - /* NAPI flags. */ 145 - bool napi_added; 146 - bool napi_enabled; 147 - /* Number of buffers (by kind) which must still be provided. */ 148 - unsigned int num_needed_buffers[MAX_KINDS]; 149 138 /* A timer for handling egress completions. */ 150 139 struct hrtimer egress_timer; 151 140 /* True if "egress_timer" is scheduled. */ 152 141 bool egress_timer_scheduled; 153 - /* Comps for each egress channel. */ 154 - struct tile_net_comps *comps_for_echannel[TILE_NET_CHANNELS]; 155 - /* Transmit wake timer for each egress channel. */ 156 - struct tile_net_tx_wake tx_wake[TILE_NET_CHANNELS]; 142 + struct info_mpipe { 143 + /* Packet queue. */ 144 + gxio_mpipe_iqueue_t iqueue; 145 + /* The NAPI struct. */ 146 + struct napi_struct napi; 147 + /* Number of buffers (by kind) which must still be provided. */ 148 + unsigned int num_needed_buffers[MAX_KINDS]; 149 + /* instance id. */ 150 + int instance; 151 + /* True if iqueue is valid. */ 152 + bool has_iqueue; 153 + /* NAPI flags. */ 154 + bool napi_added; 155 + bool napi_enabled; 156 + /* Comps for each egress channel. */ 157 + struct tile_net_comps *comps_for_echannel[TILE_NET_CHANNELS]; 158 + /* Transmit wake timer for each egress channel. */ 159 + struct tile_net_tx_wake tx_wake[TILE_NET_CHANNELS]; 160 + } mpipe[NR_MPIPE_MAX]; 157 161 }; 158 162 159 163 /* Info for egress on a particular egress channel. */ ··· 182 178 int loopify_channel; 183 179 /* The egress channel (channel or loopify_channel). */ 184 180 int echannel; 181 + /* mPIPE instance, 0 or 1. */ 182 + int instance; 185 183 }; 186 184 187 - /* Egress info, indexed by "priv->echannel" (lazily created as needed). */ 188 - static struct tile_net_egress egress_for_echannel[TILE_NET_CHANNELS]; 185 + static struct mpipe_data { 186 + /* The ingress irq. */ 187 + int ingress_irq; 189 188 190 - /* Devices currently associated with each channel. 191 - * NOTE: The array entry can become NULL after ifconfig down, but 192 - * we do not free the underlying net_device structures, so it is 193 - * safe to use a pointer after reading it from this array. 194 - */ 195 - static struct net_device *tile_net_devs_for_channel[TILE_NET_CHANNELS]; 189 + /* The "context" for all devices. */ 190 + gxio_mpipe_context_t context; 191 + 192 + /* Egress info, indexed by "priv->echannel" 193 + * (lazily created as needed). 194 + */ 195 + struct tile_net_egress 196 + egress_for_echannel[TILE_NET_CHANNELS]; 197 + 198 + /* Devices currently associated with each channel. 199 + * NOTE: The array entry can become NULL after ifconfig down, but 200 + * we do not free the underlying net_device structures, so it is 201 + * safe to use a pointer after reading it from this array. 202 + */ 203 + struct net_device 204 + *tile_net_devs_for_channel[TILE_NET_CHANNELS]; 205 + 206 + /* The actual memory allocated for the buffer stacks. */ 207 + void *buffer_stack_vas[MAX_KINDS]; 208 + 209 + /* The amount of memory allocated for each buffer stack. */ 210 + size_t buffer_stack_bytes[MAX_KINDS]; 211 + 212 + /* The first buffer stack index 213 + * (small = +0, large = +1, jumbo = +2). 214 + */ 215 + int first_buffer_stack; 216 + 217 + /* The buckets. */ 218 + int first_bucket; 219 + int num_buckets; 220 + 221 + } mpipe_data[NR_MPIPE_MAX] = { 222 + [0 ... (NR_MPIPE_MAX - 1)] { 223 + .ingress_irq = -1, 224 + .first_buffer_stack = -1, 225 + .first_bucket = -1, 226 + .num_buckets = 1 227 + } 228 + }; 196 229 197 230 /* A mutex for "tile_net_devs_for_channel". */ 198 231 static DEFINE_MUTEX(tile_net_devs_for_channel_mutex); ··· 237 196 /* The per-cpu info. */ 238 197 static DEFINE_PER_CPU(struct tile_net_info, per_cpu_info); 239 198 240 - /* The "context" for all devices. */ 241 - static gxio_mpipe_context_t context; 242 199 243 200 /* The buffer size enums for each buffer stack. 244 201 * See arch/tile/include/gxio/mpipe.h for the set of possible values. ··· 248 209 GXIO_MPIPE_BUFFER_SIZE_1664, 249 210 GXIO_MPIPE_BUFFER_SIZE_16384 250 211 }; 251 - 252 - /* The actual memory allocated for the buffer stacks. */ 253 - static void *buffer_stack_vas[MAX_KINDS]; 254 - 255 - /* The amount of memory allocated for each buffer stack. */ 256 - static size_t buffer_stack_bytes[MAX_KINDS]; 257 - 258 - /* The first buffer stack index (small = +0, large = +1, jumbo = +2). */ 259 - static int first_buffer_stack = -1; 260 - 261 - /* The buckets. */ 262 - static int first_bucket = -1; 263 - static int num_buckets = 1; 264 - 265 - /* The ingress irq. */ 266 - static int ingress_irq = -1; 267 212 268 213 /* Text value of tile_net.cpus if passed as a module parameter. */ 269 214 static char *network_cpus_string; ··· 263 240 264 241 /* If "tile_net.jumbo=NUM" was specified, this is "NUM". */ 265 242 static uint jumbo_num; 243 + 244 + /* Obtain mpipe instance from struct tile_net_priv given struct net_device. */ 245 + static inline int mpipe_instance(struct net_device *dev) 246 + { 247 + struct tile_net_priv *priv = netdev_priv(dev); 248 + return priv->instance; 249 + } 266 250 267 251 /* The "tile_net.cpus" argument specifies the cpus that are dedicated 268 252 * to handle ingress packets. ··· 344 314 } 345 315 346 316 /* Allocate and push a buffer. */ 347 - static bool tile_net_provide_buffer(int kind) 317 + static bool tile_net_provide_buffer(int instance, int kind) 348 318 { 319 + struct mpipe_data *md = &mpipe_data[instance]; 349 320 gxio_mpipe_buffer_size_enum_t bse = buffer_size_enums[kind]; 350 321 size_t bs = gxio_mpipe_buffer_size_enum_to_buffer_size(bse); 351 322 const unsigned long buffer_alignment = 128; ··· 368 337 /* Make sure "skb" and the back-pointer have been flushed. */ 369 338 wmb(); 370 339 371 - gxio_mpipe_push_buffer(&context, first_buffer_stack + kind, 340 + gxio_mpipe_push_buffer(&md->context, md->first_buffer_stack + kind, 372 341 (void *)va_to_tile_io_addr(skb->data)); 373 342 374 343 return true; ··· 394 363 return skb; 395 364 } 396 365 397 - static void tile_net_pop_all_buffers(int stack) 366 + static void tile_net_pop_all_buffers(int instance, int stack) 398 367 { 368 + struct mpipe_data *md = &mpipe_data[instance]; 369 + 399 370 for (;;) { 400 371 tile_io_addr_t addr = 401 - (tile_io_addr_t)gxio_mpipe_pop_buffer(&context, stack); 372 + (tile_io_addr_t)gxio_mpipe_pop_buffer(&md->context, 373 + stack); 402 374 if (addr == 0) 403 375 break; 404 376 dev_kfree_skb_irq(mpipe_buf_to_skb(tile_io_addr_to_va(addr))); ··· 412 378 static void tile_net_provide_needed_buffers(void) 413 379 { 414 380 struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 415 - int kind; 416 - 417 - for (kind = 0; kind < MAX_KINDS; kind++) { 418 - while (info->num_needed_buffers[kind] != 0) { 419 - if (!tile_net_provide_buffer(kind)) { 420 - /* Add info to the allocation failure dump. */ 421 - pr_notice("Tile %d still needs some buffers\n", 422 - info->my_cpu); 423 - return; 381 + int instance, kind; 382 + for (instance = 0; instance < NR_MPIPE_MAX && 383 + info->mpipe[instance].has_iqueue; instance++) { 384 + for (kind = 0; kind < MAX_KINDS; kind++) { 385 + while (info->mpipe[instance].num_needed_buffers[kind] 386 + != 0) { 387 + if (!tile_net_provide_buffer(instance, kind)) { 388 + pr_notice("Tile %d still needs" 389 + " some buffers\n", 390 + info->my_cpu); 391 + return; 392 + } 393 + info->mpipe[instance]. 394 + num_needed_buffers[kind]--; 424 395 } 425 - info->num_needed_buffers[kind]--; 426 396 } 427 397 } 428 398 } ··· 450 412 gxio_mpipe_idesc_t *idesc, unsigned long len) 451 413 { 452 414 struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 415 + int instance = mpipe_instance(dev); 453 416 454 417 /* Encode the actual packet length. */ 455 418 skb_put(skb, len); ··· 461 422 if (idesc->cs && idesc->csum_seed_val == 0xFFFF) 462 423 skb->ip_summed = CHECKSUM_UNNECESSARY; 463 424 464 - napi_gro_receive(&info->napi, skb); 425 + napi_gro_receive(&info->mpipe[instance].napi, skb); 465 426 466 427 /* Update stats. */ 467 428 tile_net_stats_add(1, &dev->stats.rx_packets); ··· 469 430 470 431 /* Need a new buffer. */ 471 432 if (idesc->size == buffer_size_enums[0]) 472 - info->num_needed_buffers[0]++; 433 + info->mpipe[instance].num_needed_buffers[0]++; 473 434 else if (idesc->size == buffer_size_enums[1]) 474 - info->num_needed_buffers[1]++; 435 + info->mpipe[instance].num_needed_buffers[1]++; 475 436 else 476 - info->num_needed_buffers[2]++; 437 + info->mpipe[instance].num_needed_buffers[2]++; 477 438 } 478 439 479 440 /* Handle a packet. Return true if "processed", false if "filtered". */ 480 - static bool tile_net_handle_packet(gxio_mpipe_idesc_t *idesc) 441 + static bool tile_net_handle_packet(int instance, gxio_mpipe_idesc_t *idesc) 481 442 { 482 443 struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 483 - struct net_device *dev = tile_net_devs_for_channel[idesc->channel]; 444 + struct mpipe_data *md = &mpipe_data[instance]; 445 + struct net_device *dev = md->tile_net_devs_for_channel[idesc->channel]; 484 446 uint8_t l2_offset; 485 447 void *va; 486 448 void *buf; ··· 517 477 if (dev) 518 478 tile_net_stats_add(1, &dev->stats.rx_dropped); 519 479 drop: 520 - gxio_mpipe_iqueue_drop(&info->iqueue, idesc); 480 + gxio_mpipe_iqueue_drop(&info->mpipe[instance].iqueue, idesc); 521 481 } else { 522 482 struct sk_buff *skb = mpipe_buf_to_skb(va); 523 483 ··· 527 487 tile_net_receive_skb(dev, skb, idesc, len); 528 488 } 529 489 530 - gxio_mpipe_iqueue_consume(&info->iqueue, idesc); 490 + gxio_mpipe_iqueue_consume(&info->mpipe[instance].iqueue, idesc); 531 491 return !filter; 532 492 } 533 493 ··· 548 508 struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 549 509 unsigned int work = 0; 550 510 gxio_mpipe_idesc_t *idesc; 551 - int i, n; 511 + int instance, i, n; 512 + struct mpipe_data *md; 513 + struct info_mpipe *info_mpipe = 514 + container_of(napi, struct info_mpipe, napi); 552 515 553 - /* Process packets. */ 554 - while ((n = gxio_mpipe_iqueue_try_peek(&info->iqueue, &idesc)) > 0) { 516 + instance = info_mpipe->instance; 517 + while ((n = gxio_mpipe_iqueue_try_peek( 518 + &info_mpipe->iqueue, 519 + &idesc)) > 0) { 555 520 for (i = 0; i < n; i++) { 556 521 if (i == TILE_NET_BATCH) 557 522 goto done; 558 - if (tile_net_handle_packet(idesc + i)) { 523 + if (tile_net_handle_packet(instance, 524 + idesc + i)) { 559 525 if (++work >= budget) 560 526 goto done; 561 527 } ··· 569 523 } 570 524 571 525 /* There are no packets left. */ 572 - napi_complete(&info->napi); 526 + napi_complete(&info_mpipe->napi); 573 527 528 + md = &mpipe_data[instance]; 574 529 /* Re-enable hypervisor interrupts. */ 575 - gxio_mpipe_enable_notif_ring_interrupt(&context, info->iqueue.ring); 530 + gxio_mpipe_enable_notif_ring_interrupt( 531 + &md->context, info->mpipe[instance].iqueue.ring); 576 532 577 533 /* HACK: Avoid the "rotting packet" problem. */ 578 - if (gxio_mpipe_iqueue_try_peek(&info->iqueue, &idesc) > 0) 579 - napi_schedule(&info->napi); 534 + if (gxio_mpipe_iqueue_try_peek(&info_mpipe->iqueue, &idesc) > 0) 535 + napi_schedule(&info_mpipe->napi); 580 536 581 537 /* ISSUE: Handle completions? */ 582 538 ··· 588 540 return work; 589 541 } 590 542 591 - /* Handle an ingress interrupt on the current cpu. */ 592 - static irqreturn_t tile_net_handle_ingress_irq(int irq, void *unused) 543 + /* Handle an ingress interrupt from an instance on the current cpu. */ 544 + static irqreturn_t tile_net_handle_ingress_irq(int irq, void *id) 593 545 { 594 546 struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 595 - napi_schedule(&info->napi); 547 + napi_schedule(&info->mpipe[(uint64_t)id].napi); 596 548 return IRQ_HANDLED; 597 549 } 598 550 ··· 634 586 { 635 587 struct tile_net_info *info = &per_cpu(per_cpu_info, tx_queue_idx); 636 588 struct tile_net_priv *priv = netdev_priv(dev); 637 - struct tile_net_tx_wake *tx_wake = &info->tx_wake[priv->echannel]; 589 + int instance = priv->instance; 590 + struct tile_net_tx_wake *tx_wake = 591 + &info->mpipe[instance].tx_wake[priv->echannel]; 638 592 639 593 hrtimer_start(&tx_wake->timer, 640 594 ktime_set(0, TX_TIMER_DELAY_USEC * 1000UL), ··· 674 624 struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 675 625 unsigned long irqflags; 676 626 bool pending = false; 677 - int i; 627 + int i, instance; 678 628 679 629 local_irq_save(irqflags); 680 630 ··· 682 632 info->egress_timer_scheduled = false; 683 633 684 634 /* Free all possible comps for this tile. */ 685 - for (i = 0; i < TILE_NET_CHANNELS; i++) { 686 - struct tile_net_egress *egress = &egress_for_echannel[i]; 687 - struct tile_net_comps *comps = info->comps_for_echannel[i]; 688 - if (comps->comp_last >= comps->comp_next) 689 - continue; 690 - tile_net_free_comps(egress->equeue, comps, -1, true); 691 - pending = pending || (comps->comp_last < comps->comp_next); 635 + for (instance = 0; instance < NR_MPIPE_MAX && 636 + info->mpipe[instance].has_iqueue; instance++) { 637 + for (i = 0; i < TILE_NET_CHANNELS; i++) { 638 + struct tile_net_egress *egress = 639 + &mpipe_data[instance].egress_for_echannel[i]; 640 + struct tile_net_comps *comps = 641 + info->mpipe[instance].comps_for_echannel[i]; 642 + if (!egress || comps->comp_last >= comps->comp_next) 643 + continue; 644 + tile_net_free_comps(egress->equeue, comps, -1, true); 645 + pending = pending || 646 + (comps->comp_last < comps->comp_next); 647 + } 692 648 } 693 649 694 650 /* Reschedule timer if needed. */ ··· 706 650 return HRTIMER_NORESTART; 707 651 } 708 652 709 - /* Helper function for "tile_net_update()". */ 710 - static void manage_ingress_irq(void *enable) 653 + /* Helper functions for "tile_net_update()". */ 654 + static void enable_ingress_irq(void *irq) 711 655 { 712 - if (enable) 713 - enable_percpu_irq(ingress_irq, 0); 714 - else 715 - disable_percpu_irq(ingress_irq); 656 + enable_percpu_irq((long)irq, 0); 657 + } 658 + 659 + static void disable_ingress_irq(void *irq) 660 + { 661 + disable_percpu_irq((long)irq); 716 662 } 717 663 718 664 /* Helper function for tile_net_open() and tile_net_stop(). ··· 724 666 { 725 667 static gxio_mpipe_rules_t rules; /* too big to fit on the stack */ 726 668 bool saw_channel = false; 669 + int instance = mpipe_instance(dev); 670 + struct mpipe_data *md = &mpipe_data[instance]; 727 671 int channel; 728 672 int rc; 729 673 int cpu; 730 674 731 - gxio_mpipe_rules_init(&rules, &context); 675 + saw_channel = false; 676 + gxio_mpipe_rules_init(&rules, &md->context); 732 677 733 678 for (channel = 0; channel < TILE_NET_CHANNELS; channel++) { 734 - if (tile_net_devs_for_channel[channel] == NULL) 679 + if (md->tile_net_devs_for_channel[channel] == NULL) 735 680 continue; 736 681 if (!saw_channel) { 737 682 saw_channel = true; 738 - gxio_mpipe_rules_begin(&rules, first_bucket, 739 - num_buckets, NULL); 683 + gxio_mpipe_rules_begin(&rules, md->first_bucket, 684 + md->num_buckets, NULL); 740 685 gxio_mpipe_rules_set_headroom(&rules, NET_IP_ALIGN); 741 686 } 742 687 gxio_mpipe_rules_add_channel(&rules, channel); ··· 750 689 */ 751 690 rc = gxio_mpipe_rules_commit(&rules); 752 691 if (rc != 0) { 753 - netdev_warn(dev, "gxio_mpipe_rules_commit failed: %d\n", rc); 692 + netdev_warn(dev, "gxio_mpipe_rules_commit: mpipe[%d] %d\n", 693 + instance, rc); 754 694 return -EIO; 755 695 } 756 696 ··· 759 697 * We use on_each_cpu to handle the IPI mask or unmask. 760 698 */ 761 699 if (!saw_channel) 762 - on_each_cpu(manage_ingress_irq, (void *)0, 1); 700 + on_each_cpu(disable_ingress_irq, 701 + (void *)(long)(md->ingress_irq), 1); 763 702 for_each_online_cpu(cpu) { 764 703 struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); 765 - if (!info->has_iqueue) 704 + 705 + if (!info->mpipe[instance].has_iqueue) 766 706 continue; 767 707 if (saw_channel) { 768 - if (!info->napi_added) { 769 - netif_napi_add(dev, &info->napi, 708 + if (!info->mpipe[instance].napi_added) { 709 + netif_napi_add(dev, &info->mpipe[instance].napi, 770 710 tile_net_poll, TILE_NET_WEIGHT); 771 - info->napi_added = true; 711 + info->mpipe[instance].napi_added = true; 772 712 } 773 - if (!info->napi_enabled) { 774 - napi_enable(&info->napi); 775 - info->napi_enabled = true; 713 + if (!info->mpipe[instance].napi_enabled) { 714 + napi_enable(&info->mpipe[instance].napi); 715 + info->mpipe[instance].napi_enabled = true; 776 716 } 777 717 } else { 778 - if (info->napi_enabled) { 779 - napi_disable(&info->napi); 780 - info->napi_enabled = false; 718 + if (info->mpipe[instance].napi_enabled) { 719 + napi_disable(&info->mpipe[instance].napi); 720 + info->mpipe[instance].napi_enabled = false; 781 721 } 782 722 /* FIXME: Drain the iqueue. */ 783 723 } 784 724 } 785 725 if (saw_channel) 786 - on_each_cpu(manage_ingress_irq, (void *)1, 1); 726 + on_each_cpu(enable_ingress_irq, 727 + (void *)(long)(md->ingress_irq), 1); 787 728 788 729 /* HACK: Allow packets to flow in the simulator. */ 789 730 if (saw_channel) 790 - sim_enable_mpipe_links(0, -1); 731 + sim_enable_mpipe_links(instance, -1); 791 732 792 733 return 0; 793 734 } ··· 800 735 int kind, size_t num_buffers) 801 736 { 802 737 pte_t hash_pte = pte_set_home((pte_t) { 0 }, PAGE_HOME_HASH); 738 + int instance = mpipe_instance(dev); 739 + struct mpipe_data *md = &mpipe_data[instance]; 803 740 size_t needed = gxio_mpipe_calc_buffer_stack_bytes(num_buffers); 804 - int stack_idx = first_buffer_stack + kind; 741 + int stack_idx = md->first_buffer_stack + kind; 805 742 void *va; 806 743 int i, rc; 807 744 808 745 /* Round up to 64KB and then use alloc_pages() so we get the 809 746 * required 64KB alignment. 810 747 */ 811 - buffer_stack_bytes[kind] = ALIGN(needed, 64 * 1024); 748 + md->buffer_stack_bytes[kind] = 749 + ALIGN(needed, 64 * 1024); 812 750 813 - va = alloc_pages_exact(buffer_stack_bytes[kind], GFP_KERNEL); 751 + va = alloc_pages_exact(md->buffer_stack_bytes[kind], GFP_KERNEL); 814 752 if (va == NULL) { 815 753 netdev_err(dev, 816 754 "Could not alloc %zd bytes for buffer stack %d\n", 817 - buffer_stack_bytes[kind], kind); 755 + md->buffer_stack_bytes[kind], kind); 818 756 return -ENOMEM; 819 757 } 820 758 821 759 /* Initialize the buffer stack. */ 822 - rc = gxio_mpipe_init_buffer_stack(&context, stack_idx, 823 - buffer_size_enums[kind], 824 - va, buffer_stack_bytes[kind], 0); 760 + rc = gxio_mpipe_init_buffer_stack(&md->context, stack_idx, 761 + buffer_size_enums[kind], va, 762 + md->buffer_stack_bytes[kind], 0); 825 763 if (rc != 0) { 826 - netdev_err(dev, "gxio_mpipe_init_buffer_stack: %d\n", rc); 827 - free_pages_exact(va, buffer_stack_bytes[kind]); 764 + netdev_err(dev, "gxio_mpipe_init_buffer_stack: mpipe[%d] %d\n", 765 + instance, rc); 766 + free_pages_exact(va, md->buffer_stack_bytes[kind]); 828 767 return rc; 829 768 } 830 769 831 - buffer_stack_vas[kind] = va; 770 + md->buffer_stack_vas[kind] = va; 832 771 833 - rc = gxio_mpipe_register_client_memory(&context, stack_idx, 772 + rc = gxio_mpipe_register_client_memory(&md->context, stack_idx, 834 773 hash_pte, 0); 835 774 if (rc != 0) { 836 - netdev_err(dev, "gxio_mpipe_register_client_memory: %d\n", rc); 775 + netdev_err(dev, 776 + "gxio_mpipe_register_client_memory: mpipe[%d] %d\n", 777 + instance, rc); 837 778 return rc; 838 779 } 839 780 840 781 /* Provide initial buffers. */ 841 782 for (i = 0; i < num_buffers; i++) { 842 - if (!tile_net_provide_buffer(kind)) { 783 + if (!tile_net_provide_buffer(instance, kind)) { 843 784 netdev_err(dev, "Cannot allocate initial sk_bufs!\n"); 844 785 return -ENOMEM; 845 786 } ··· 864 793 int num_kinds = MAX_KINDS - (jumbo_num == 0); 865 794 size_t num_buffers; 866 795 int rc; 796 + int instance = mpipe_instance(dev); 797 + struct mpipe_data *md = &mpipe_data[instance]; 867 798 868 799 /* Allocate the buffer stacks. */ 869 - rc = gxio_mpipe_alloc_buffer_stacks(&context, num_kinds, 0, 0); 800 + rc = gxio_mpipe_alloc_buffer_stacks(&md->context, num_kinds, 0, 0); 870 801 if (rc < 0) { 871 - netdev_err(dev, "gxio_mpipe_alloc_buffer_stacks: %d\n", rc); 802 + netdev_err(dev, 803 + "gxio_mpipe_alloc_buffer_stacks: mpipe[%d] %d\n", 804 + instance, rc); 872 805 return rc; 873 806 } 874 - first_buffer_stack = rc; 807 + md->first_buffer_stack = rc; 875 808 876 809 /* Enough small/large buffers to (normally) avoid buffer errors. */ 877 810 num_buffers = ··· 904 829 { 905 830 struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); 906 831 int order, i, rc; 832 + int instance = mpipe_instance(dev); 833 + struct mpipe_data *md = &mpipe_data[instance]; 907 834 struct page *page; 908 835 void *addr; 909 836 ··· 920 843 addr = pfn_to_kaddr(page_to_pfn(page)); 921 844 memset(addr, 0, COMPS_SIZE); 922 845 for (i = 0; i < TILE_NET_CHANNELS; i++) 923 - info->comps_for_echannel[i] = 846 + info->mpipe[instance].comps_for_echannel[i] = 924 847 addr + i * sizeof(struct tile_net_comps); 925 848 926 849 /* If this is a network cpu, create an iqueue. */ ··· 934 857 return -ENOMEM; 935 858 } 936 859 addr = pfn_to_kaddr(page_to_pfn(page)); 937 - rc = gxio_mpipe_iqueue_init(&info->iqueue, &context, ring++, 938 - addr, NOTIF_RING_SIZE, 0); 860 + rc = gxio_mpipe_iqueue_init(&info->mpipe[instance].iqueue, 861 + &md->context, ring++, addr, 862 + NOTIF_RING_SIZE, 0); 939 863 if (rc < 0) { 940 864 netdev_err(dev, 941 865 "gxio_mpipe_iqueue_init failed: %d\n", rc); 942 866 return rc; 943 867 } 944 - info->has_iqueue = true; 868 + info->mpipe[instance].has_iqueue = true; 945 869 } 946 870 947 871 return ring; ··· 955 877 int ring, int network_cpus_count) 956 878 { 957 879 int group, rc; 880 + int instance = mpipe_instance(dev); 881 + struct mpipe_data *md = &mpipe_data[instance]; 958 882 959 883 /* Allocate one NotifGroup. */ 960 - rc = gxio_mpipe_alloc_notif_groups(&context, 1, 0, 0); 884 + rc = gxio_mpipe_alloc_notif_groups(&md->context, 1, 0, 0); 961 885 if (rc < 0) { 962 - netdev_err(dev, "gxio_mpipe_alloc_notif_groups failed: %d\n", 963 - rc); 886 + netdev_err(dev, "gxio_mpipe_alloc_notif_groups: mpipe[%d] %d\n", 887 + instance, rc); 964 888 return rc; 965 889 } 966 890 group = rc; 967 891 968 892 /* Initialize global num_buckets value. */ 969 893 if (network_cpus_count > 4) 970 - num_buckets = 256; 894 + md->num_buckets = 256; 971 895 else if (network_cpus_count > 1) 972 - num_buckets = 16; 896 + md->num_buckets = 16; 973 897 974 898 /* Allocate some buckets, and set global first_bucket value. */ 975 - rc = gxio_mpipe_alloc_buckets(&context, num_buckets, 0, 0); 899 + rc = gxio_mpipe_alloc_buckets(&md->context, md->num_buckets, 0, 0); 976 900 if (rc < 0) { 977 - netdev_err(dev, "gxio_mpipe_alloc_buckets failed: %d\n", rc); 901 + netdev_err(dev, "gxio_mpipe_alloc_buckets: mpipe[%d] %d\n", 902 + instance, rc); 978 903 return rc; 979 904 } 980 - first_bucket = rc; 905 + md->first_bucket = rc; 981 906 982 907 /* Init group and buckets. */ 983 908 rc = gxio_mpipe_init_notif_group_and_buckets( 984 - &context, group, ring, network_cpus_count, 985 - first_bucket, num_buckets, 909 + &md->context, group, ring, network_cpus_count, 910 + md->first_bucket, md->num_buckets, 986 911 GXIO_MPIPE_BUCKET_STICKY_FLOW_LOCALITY); 987 912 if (rc != 0) { 988 - netdev_err( 989 - dev, 990 - "gxio_mpipe_init_notif_group_and_buckets failed: %d\n", 991 - rc); 913 + netdev_err(dev, "gxio_mpipe_init_notif_group_and_buckets: " 914 + "mpipe[%d] %d\n", instance, rc); 992 915 return rc; 993 916 } 994 917 ··· 1003 924 */ 1004 925 static int tile_net_setup_interrupts(struct net_device *dev) 1005 926 { 1006 - int cpu, rc; 927 + int cpu, rc, irq; 928 + int instance = mpipe_instance(dev); 929 + struct mpipe_data *md = &mpipe_data[instance]; 1007 930 1008 - rc = create_irq(); 1009 - if (rc < 0) { 1010 - netdev_err(dev, "create_irq failed: %d\n", rc); 1011 - return rc; 1012 - } 1013 - ingress_irq = rc; 1014 - tile_irq_activate(ingress_irq, TILE_IRQ_PERCPU); 1015 - rc = request_irq(ingress_irq, tile_net_handle_ingress_irq, 1016 - 0, "tile_net", NULL); 1017 - if (rc != 0) { 1018 - netdev_err(dev, "request_irq failed: %d\n", rc); 1019 - destroy_irq(ingress_irq); 1020 - ingress_irq = -1; 1021 - return rc; 931 + irq = md->ingress_irq; 932 + if (irq < 0) { 933 + irq = create_irq(); 934 + if (irq < 0) { 935 + netdev_err(dev, 936 + "create_irq failed: mpipe[%d] %d\n", 937 + instance, irq); 938 + return irq; 939 + } 940 + tile_irq_activate(irq, TILE_IRQ_PERCPU); 941 + 942 + rc = request_irq(irq, tile_net_handle_ingress_irq, 943 + 0, "tile_net", (void *)((uint64_t)instance)); 944 + 945 + if (rc != 0) { 946 + netdev_err(dev, "request_irq failed: mpipe[%d] %d\n", 947 + instance, rc); 948 + destroy_irq(irq); 949 + return rc; 950 + } 951 + md->ingress_irq = irq; 1022 952 } 1023 953 1024 954 for_each_online_cpu(cpu) { 1025 955 struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); 1026 - if (info->has_iqueue) { 1027 - gxio_mpipe_request_notif_ring_interrupt( 1028 - &context, cpu_x(cpu), cpu_y(cpu), 1029 - KERNEL_PL, ingress_irq, info->iqueue.ring); 956 + if (info->mpipe[instance].has_iqueue) { 957 + gxio_mpipe_request_notif_ring_interrupt(&md->context, 958 + cpu_x(cpu), cpu_y(cpu), KERNEL_PL, irq, 959 + info->mpipe[instance].iqueue.ring); 1030 960 } 1031 961 } 1032 962 ··· 1043 955 } 1044 956 1045 957 /* Undo any state set up partially by a failed call to tile_net_init_mpipe. */ 1046 - static void tile_net_init_mpipe_fail(void) 958 + static void tile_net_init_mpipe_fail(int instance) 1047 959 { 1048 960 int kind, cpu; 961 + struct mpipe_data *md = &mpipe_data[instance]; 1049 962 1050 963 /* Do cleanups that require the mpipe context first. */ 1051 964 for (kind = 0; kind < MAX_KINDS; kind++) { 1052 - if (buffer_stack_vas[kind] != NULL) { 1053 - tile_net_pop_all_buffers(first_buffer_stack + kind); 965 + if (md->buffer_stack_vas[kind] != NULL) { 966 + tile_net_pop_all_buffers(instance, 967 + md->first_buffer_stack + 968 + kind); 1054 969 } 1055 970 } 1056 971 1057 972 /* Destroy mpipe context so the hardware no longer owns any memory. */ 1058 - gxio_mpipe_destroy(&context); 973 + gxio_mpipe_destroy(&md->context); 1059 974 1060 975 for_each_online_cpu(cpu) { 1061 976 struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); 1062 - free_pages((unsigned long)(info->comps_for_echannel[0]), 1063 - get_order(COMPS_SIZE)); 1064 - info->comps_for_echannel[0] = NULL; 1065 - free_pages((unsigned long)(info->iqueue.idescs), 977 + free_pages( 978 + (unsigned long)( 979 + info->mpipe[instance].comps_for_echannel[0]), 980 + get_order(COMPS_SIZE)); 981 + info->mpipe[instance].comps_for_echannel[0] = NULL; 982 + free_pages((unsigned long)(info->mpipe[instance].iqueue.idescs), 1066 983 get_order(NOTIF_RING_SIZE)); 1067 - info->iqueue.idescs = NULL; 984 + info->mpipe[instance].iqueue.idescs = NULL; 1068 985 } 1069 986 1070 987 for (kind = 0; kind < MAX_KINDS; kind++) { 1071 - if (buffer_stack_vas[kind] != NULL) { 1072 - free_pages_exact(buffer_stack_vas[kind], 1073 - buffer_stack_bytes[kind]); 1074 - buffer_stack_vas[kind] = NULL; 988 + if (md->buffer_stack_vas[kind] != NULL) { 989 + free_pages_exact(md->buffer_stack_vas[kind], 990 + md->buffer_stack_bytes[kind]); 991 + md->buffer_stack_vas[kind] = NULL; 1075 992 } 1076 993 } 1077 994 1078 - first_buffer_stack = -1; 1079 - first_bucket = -1; 995 + md->first_buffer_stack = -1; 996 + md->first_bucket = -1; 1080 997 } 1081 998 1082 999 /* The first time any tilegx network device is opened, we initialize ··· 1098 1005 int rc; 1099 1006 int cpu; 1100 1007 int first_ring, ring; 1008 + int instance = mpipe_instance(dev); 1009 + struct mpipe_data *md = &mpipe_data[instance]; 1101 1010 int network_cpus_count = cpus_weight(network_cpus_map); 1102 1011 1103 1012 if (!hash_default) { ··· 1107 1012 return -EIO; 1108 1013 } 1109 1014 1110 - rc = gxio_mpipe_init(&context, 0); 1015 + rc = gxio_mpipe_init(&md->context, instance); 1111 1016 if (rc != 0) { 1112 - netdev_err(dev, "gxio_mpipe_init failed: %d\n", rc); 1017 + netdev_err(dev, "gxio_mpipe_init: mpipe[%d] %d\n", 1018 + instance, rc); 1113 1019 return -EIO; 1114 1020 } 1115 1021 ··· 1120 1024 goto fail; 1121 1025 1122 1026 /* Allocate one NotifRing for each network cpu. */ 1123 - rc = gxio_mpipe_alloc_notif_rings(&context, network_cpus_count, 0, 0); 1027 + rc = gxio_mpipe_alloc_notif_rings(&md->context, 1028 + network_cpus_count, 0, 0); 1124 1029 if (rc < 0) { 1125 1030 netdev_err(dev, "gxio_mpipe_alloc_notif_rings failed %d\n", 1126 1031 rc); ··· 1151 1054 return 0; 1152 1055 1153 1056 fail: 1154 - tile_net_init_mpipe_fail(); 1057 + tile_net_init_mpipe_fail(instance); 1155 1058 return rc; 1156 1059 } 1157 1060 ··· 1169 1072 int headers_order, edescs_order, equeue_order; 1170 1073 size_t edescs_size; 1171 1074 int rc = -ENOMEM; 1075 + int instance = mpipe_instance(dev); 1076 + struct mpipe_data *md = &mpipe_data[instance]; 1172 1077 1173 1078 /* Only initialize once. */ 1174 - if (egress_for_echannel[echannel].equeue != NULL) 1079 + if (md->egress_for_echannel[echannel].equeue != NULL) 1175 1080 return 0; 1176 1081 1177 1082 /* Allocate memory for the "headers". */ ··· 1212 1113 1213 1114 /* Allocate an edma ring (using a one entry "free list"). */ 1214 1115 if (ering < 0) { 1215 - rc = gxio_mpipe_alloc_edma_rings(&context, 1, 0, 0); 1116 + rc = gxio_mpipe_alloc_edma_rings(&md->context, 1, 0, 0); 1216 1117 if (rc < 0) { 1217 - netdev_warn(dev, "gxio_mpipe_alloc_edma_rings: %d\n", 1218 - rc); 1118 + netdev_warn(dev, "gxio_mpipe_alloc_edma_rings: " 1119 + "mpipe[%d] %d\n", instance, rc); 1219 1120 goto fail_equeue; 1220 1121 } 1221 1122 ering = rc; 1222 1123 } 1223 1124 1224 1125 /* Initialize the equeue. */ 1225 - rc = gxio_mpipe_equeue_init(equeue, &context, ering, echannel, 1126 + rc = gxio_mpipe_equeue_init(equeue, &md->context, ering, echannel, 1226 1127 edescs, edescs_size, 0); 1227 1128 if (rc != 0) { 1228 - netdev_err(dev, "gxio_mpipe_equeue_init failed: %d\n", rc); 1129 + netdev_err(dev, "gxio_mpipe_equeue_init: mpipe[%d] %d\n", 1130 + instance, rc); 1229 1131 goto fail_equeue; 1230 1132 } 1231 1133 ··· 1243 1143 } 1244 1144 1245 1145 /* Done. */ 1246 - egress_for_echannel[echannel].equeue = equeue; 1247 - egress_for_echannel[echannel].headers = headers; 1146 + md->egress_for_echannel[echannel].equeue = equeue; 1147 + md->egress_for_echannel[echannel].headers = headers; 1248 1148 return 0; 1249 1149 1250 1150 fail_equeue: ··· 1264 1164 static int tile_net_link_open(struct net_device *dev, gxio_mpipe_link_t *link, 1265 1165 const char *link_name) 1266 1166 { 1267 - int rc = gxio_mpipe_link_open(link, &context, link_name, 0); 1167 + int instance = mpipe_instance(dev); 1168 + struct mpipe_data *md = &mpipe_data[instance]; 1169 + int rc = gxio_mpipe_link_open(link, &md->context, link_name, 0); 1268 1170 if (rc < 0) { 1269 - netdev_err(dev, "Failed to open '%s'\n", link_name); 1171 + netdev_err(dev, "Failed to open '%s', mpipe[%d], %d\n", 1172 + link_name, instance, rc); 1270 1173 return rc; 1271 1174 } 1272 1175 if (jumbo_num != 0) { ··· 1296 1193 static int tile_net_open(struct net_device *dev) 1297 1194 { 1298 1195 struct tile_net_priv *priv = netdev_priv(dev); 1299 - int cpu, rc; 1196 + int cpu, rc, instance; 1300 1197 1301 1198 mutex_lock(&tile_net_devs_for_channel_mutex); 1302 1199 1303 - /* Do one-time initialization the first time any device is opened. */ 1304 - if (ingress_irq < 0) { 1200 + /* Get the instance info. */ 1201 + rc = gxio_mpipe_link_instance(dev->name); 1202 + if (rc < 0 || rc >= NR_MPIPE_MAX) 1203 + return -EIO; 1204 + 1205 + priv->instance = rc; 1206 + instance = rc; 1207 + if (!mpipe_data[rc].context.mmio_fast_base) { 1208 + /* Do one-time initialization per instance the first time 1209 + * any device is opened. 1210 + */ 1305 1211 rc = tile_net_init_mpipe(dev); 1306 1212 if (rc != 0) 1307 1213 goto fail; ··· 1341 1229 if (rc != 0) 1342 1230 goto fail; 1343 1231 1344 - tile_net_devs_for_channel[priv->channel] = dev; 1232 + mpipe_data[instance].tile_net_devs_for_channel[priv->channel] = dev; 1345 1233 1346 1234 rc = tile_net_update(dev); 1347 1235 if (rc != 0) ··· 1353 1241 for_each_online_cpu(cpu) { 1354 1242 struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); 1355 1243 struct tile_net_tx_wake *tx_wake = 1356 - &info->tx_wake[priv->echannel]; 1244 + &info->mpipe[instance].tx_wake[priv->echannel]; 1357 1245 1358 1246 hrtimer_init(&tx_wake->timer, CLOCK_MONOTONIC, 1359 1247 HRTIMER_MODE_REL); ··· 1379 1267 priv->channel = -1; 1380 1268 } 1381 1269 priv->echannel = -1; 1382 - tile_net_devs_for_channel[priv->channel] = NULL; 1270 + mpipe_data[instance].tile_net_devs_for_channel[priv->channel] = NULL; 1383 1271 mutex_unlock(&tile_net_devs_for_channel_mutex); 1384 1272 1385 1273 /* Don't return raw gxio error codes to generic Linux. */ ··· 1391 1279 { 1392 1280 struct tile_net_priv *priv = netdev_priv(dev); 1393 1281 int cpu; 1282 + int instance = priv->instance; 1283 + struct mpipe_data *md = &mpipe_data[instance]; 1394 1284 1395 1285 for_each_online_cpu(cpu) { 1396 1286 struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); 1397 1287 struct tile_net_tx_wake *tx_wake = 1398 - &info->tx_wake[priv->echannel]; 1288 + &info->mpipe[instance].tx_wake[priv->echannel]; 1399 1289 1400 1290 hrtimer_cancel(&tx_wake->timer); 1401 1291 netif_stop_subqueue(dev, cpu); 1402 1292 } 1403 1293 1404 1294 mutex_lock(&tile_net_devs_for_channel_mutex); 1405 - tile_net_devs_for_channel[priv->channel] = NULL; 1295 + md->tile_net_devs_for_channel[priv->channel] = NULL; 1406 1296 (void)tile_net_update(dev); 1407 1297 if (priv->loopify_channel >= 0) { 1408 1298 if (gxio_mpipe_link_close(&priv->loopify_link) != 0) ··· 1614 1500 struct sk_buff *skb, unsigned char *headers, s64 slot) 1615 1501 { 1616 1502 struct skb_shared_info *sh = skb_shinfo(skb); 1503 + int instance = mpipe_instance(dev); 1504 + struct mpipe_data *md = &mpipe_data[instance]; 1617 1505 unsigned int sh_len = skb_transport_offset(skb) + tcp_hdrlen(skb); 1618 1506 unsigned int data_len = skb->len - sh_len; 1619 1507 unsigned int p_len = sh->gso_size; ··· 1638 1522 edesc_head.xfer_size = sh_len; 1639 1523 1640 1524 /* This is only used to specify the TLB. */ 1641 - edesc_head.stack_idx = first_buffer_stack; 1642 - edesc_body.stack_idx = first_buffer_stack; 1525 + edesc_head.stack_idx = md->first_buffer_stack; 1526 + edesc_body.stack_idx = md->first_buffer_stack; 1643 1527 1644 1528 /* Egress all the edescs. */ 1645 1529 for (segment = 0; segment < sh->gso_segs; segment++) { ··· 1714 1598 struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 1715 1599 struct tile_net_priv *priv = netdev_priv(dev); 1716 1600 int channel = priv->echannel; 1717 - struct tile_net_egress *egress = &egress_for_echannel[channel]; 1718 - struct tile_net_comps *comps = info->comps_for_echannel[channel]; 1601 + int instance = priv->instance; 1602 + struct mpipe_data *md = &mpipe_data[instance]; 1603 + struct tile_net_egress *egress = &md->egress_for_echannel[channel]; 1604 + struct tile_net_comps *comps = 1605 + info->mpipe[instance].comps_for_echannel[channel]; 1719 1606 gxio_mpipe_equeue_t *equeue = egress->equeue; 1720 1607 unsigned long irqflags; 1721 1608 int num_edescs; ··· 1782 1663 { 1783 1664 struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 1784 1665 struct tile_net_priv *priv = netdev_priv(dev); 1785 - struct tile_net_egress *egress = &egress_for_echannel[priv->echannel]; 1666 + int instance = priv->instance; 1667 + struct mpipe_data *md = &mpipe_data[instance]; 1668 + struct tile_net_egress *egress = 1669 + &md->egress_for_echannel[priv->echannel]; 1786 1670 gxio_mpipe_equeue_t *equeue = egress->equeue; 1787 1671 struct tile_net_comps *comps = 1788 - info->comps_for_echannel[priv->echannel]; 1672 + info->mpipe[instance].comps_for_echannel[priv->echannel]; 1789 1673 unsigned int len = skb->len; 1790 1674 unsigned char *data = skb->data; 1791 1675 unsigned int num_edescs; ··· 1805 1683 num_edescs = tile_net_tx_frags(frags, skb, data, skb_headlen(skb)); 1806 1684 1807 1685 /* This is only used to specify the TLB. */ 1808 - edesc.stack_idx = first_buffer_stack; 1686 + edesc.stack_idx = md->first_buffer_stack; 1809 1687 1810 1688 /* Prepare the edescs. */ 1811 1689 for (i = 0; i < num_edescs; i++) { ··· 1912 1790 */ 1913 1791 static void tile_net_netpoll(struct net_device *dev) 1914 1792 { 1915 - disable_percpu_irq(ingress_irq); 1916 - tile_net_handle_ingress_irq(ingress_irq, NULL); 1917 - enable_percpu_irq(ingress_irq, 0); 1793 + int instance = mpipe_instance(dev); 1794 + struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 1795 + struct mpipe_data *md = &mpipe_data[instance]; 1796 + 1797 + disable_percpu_irq(md->ingress_irq); 1798 + napi_schedule(&info->mpipe[instance].napi); 1799 + enable_percpu_irq(md->ingress_irq, 0); 1918 1800 } 1919 1801 #endif 1920 1802 ··· 2021 1895 { 2022 1896 struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 2023 1897 int my_cpu = smp_processor_id(); 1898 + int instance; 2024 1899 2025 - info->has_iqueue = false; 2026 - 1900 + for (instance = 0; instance < NR_MPIPE_MAX; instance++) { 1901 + info->mpipe[instance].has_iqueue = false; 1902 + info->mpipe[instance].instance = instance; 1903 + } 2027 1904 info->my_cpu = my_cpu; 2028 1905 2029 1906 /* Initialize the egress timer. */ ··· 2042 1913 uint8_t mac[6]; 2043 1914 2044 1915 pr_info("Tilera Network Driver\n"); 1916 + 1917 + BUILD_BUG_ON(NR_MPIPE_MAX != 2); 2045 1918 2046 1919 mutex_init(&tile_net_devs_for_channel_mutex); 2047 1920