aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile/gxio/mpipe.c
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@tilera.com>2013-08-01 11:36:42 -0400
committerDavid S. Miller <davem@davemloft.net>2013-08-01 17:35:50 -0400
commitf3286a3af89d6db7a488f3e8f02b98d67d50f00c (patch)
treeebe37457c3676eb8cb06ba17597134975958845d /arch/tile/gxio/mpipe.c
parent6ab4ae9aadef65e2f7aca44fd963c302dcb5849e (diff)
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>
Diffstat (limited to 'arch/tile/gxio/mpipe.c')
-rw-r--r--arch/tile/gxio/mpipe.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/arch/tile/gxio/mpipe.c b/arch/tile/gxio/mpipe.c
index 0567cf0cd29e..5301a9ffbae1 100644
--- a/arch/tile/gxio/mpipe.c
+++ b/arch/tile/gxio/mpipe.c
@@ -36,8 +36,14 @@ int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index)
36 int fd; 36 int fd;
37 int i; 37 int i;
38 38
39 if (mpipe_index >= GXIO_MPIPE_INSTANCE_MAX)
40 return -EINVAL;
41
39 snprintf(file, sizeof(file), "mpipe/%d/iorpc", mpipe_index); 42 snprintf(file, sizeof(file), "mpipe/%d/iorpc", mpipe_index);
40 fd = hv_dev_open((HV_VirtAddr) file, 0); 43 fd = hv_dev_open((HV_VirtAddr) file, 0);
44
45 context->fd = fd;
46
41 if (fd < 0) { 47 if (fd < 0) {
42 if (fd >= GXIO_ERR_MIN && fd <= GXIO_ERR_MAX) 48 if (fd >= GXIO_ERR_MIN && fd <= GXIO_ERR_MAX)
43 return fd; 49 return fd;
@@ -45,8 +51,6 @@ int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index)
45 return -ENODEV; 51 return -ENODEV;
46 } 52 }
47 53
48 context->fd = fd;
49
50 /* Map in the MMIO space. */ 54 /* Map in the MMIO space. */
51 context->mmio_cfg_base = (void __force *) 55 context->mmio_cfg_base = (void __force *)
52 iorpc_ioremap(fd, HV_MPIPE_CONFIG_MMIO_OFFSET, 56 iorpc_ioremap(fd, HV_MPIPE_CONFIG_MMIO_OFFSET,
@@ -64,12 +68,15 @@ int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index)
64 for (i = 0; i < 8; i++) 68 for (i = 0; i < 8; i++)
65 context->__stacks.stacks[i] = 255; 69 context->__stacks.stacks[i] = 255;
66 70
71 context->instance = mpipe_index;
72
67 return 0; 73 return 0;
68 74
69 fast_failed: 75 fast_failed:
70 iounmap((void __force __iomem *)(context->mmio_cfg_base)); 76 iounmap((void __force __iomem *)(context->mmio_cfg_base));
71 cfg_failed: 77 cfg_failed:
72 hv_dev_close(context->fd); 78 hv_dev_close(context->fd);
79 context->fd = -1;
73 return -ENODEV; 80 return -ENODEV;
74} 81}
75 82
@@ -496,6 +503,20 @@ static gxio_mpipe_context_t *_gxio_get_link_context(void)
496 return contextp; 503 return contextp;
497} 504}
498 505
506int gxio_mpipe_link_instance(const char *link_name)
507{
508 _gxio_mpipe_link_name_t name;
509 gxio_mpipe_context_t *context = _gxio_get_link_context();
510
511 if (!context)
512 return GXIO_ERR_NO_DEVICE;
513
514 strncpy(name.name, link_name, sizeof(name.name));
515 name.name[GXIO_MPIPE_LINK_NAME_LEN - 1] = '\0';
516
517 return gxio_mpipe_info_instance_aux(context, name);
518}
519
499int gxio_mpipe_link_enumerate_mac(int idx, char *link_name, uint8_t *link_mac) 520int gxio_mpipe_link_enumerate_mac(int idx, char *link_name, uint8_t *link_mac)
500{ 521{
501 int rv; 522 int rv;