diff options
Diffstat (limited to 'arch/tile/gxio/mpipe.c')
-rw-r--r-- | arch/tile/gxio/mpipe.c | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/arch/tile/gxio/mpipe.c b/arch/tile/gxio/mpipe.c index e71c63390acc..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 | ||
@@ -383,7 +390,7 @@ EXPORT_SYMBOL_GPL(gxio_mpipe_iqueue_init); | |||
383 | 390 | ||
384 | int gxio_mpipe_equeue_init(gxio_mpipe_equeue_t *equeue, | 391 | int gxio_mpipe_equeue_init(gxio_mpipe_equeue_t *equeue, |
385 | gxio_mpipe_context_t *context, | 392 | gxio_mpipe_context_t *context, |
386 | unsigned int edma_ring_id, | 393 | unsigned int ering, |
387 | unsigned int channel, | 394 | unsigned int channel, |
388 | void *mem, unsigned int mem_size, | 395 | void *mem, unsigned int mem_size, |
389 | unsigned int mem_flags) | 396 | unsigned int mem_flags) |
@@ -394,7 +401,7 @@ int gxio_mpipe_equeue_init(gxio_mpipe_equeue_t *equeue, | |||
394 | /* Offset used to read number of completed commands. */ | 401 | /* Offset used to read number of completed commands. */ |
395 | MPIPE_EDMA_POST_REGION_ADDR_t offset; | 402 | MPIPE_EDMA_POST_REGION_ADDR_t offset; |
396 | 403 | ||
397 | int result = gxio_mpipe_init_edma_ring(context, edma_ring_id, channel, | 404 | int result = gxio_mpipe_init_edma_ring(context, ering, channel, |
398 | mem, mem_size, mem_flags); | 405 | mem, mem_size, mem_flags); |
399 | if (result < 0) | 406 | if (result < 0) |
400 | return result; | 407 | return result; |
@@ -405,7 +412,7 @@ int gxio_mpipe_equeue_init(gxio_mpipe_equeue_t *equeue, | |||
405 | offset.region = | 412 | offset.region = |
406 | MPIPE_MMIO_ADDR__REGION_VAL_EDMA - | 413 | MPIPE_MMIO_ADDR__REGION_VAL_EDMA - |
407 | MPIPE_MMIO_ADDR__REGION_VAL_IDMA; | 414 | MPIPE_MMIO_ADDR__REGION_VAL_IDMA; |
408 | offset.ring = edma_ring_id; | 415 | offset.ring = ering; |
409 | 416 | ||
410 | __gxio_dma_queue_init(&equeue->dma_queue, | 417 | __gxio_dma_queue_init(&equeue->dma_queue, |
411 | context->mmio_fast_base + offset.word, | 418 | context->mmio_fast_base + offset.word, |
@@ -413,6 +420,9 @@ int gxio_mpipe_equeue_init(gxio_mpipe_equeue_t *equeue, | |||
413 | equeue->edescs = mem; | 420 | equeue->edescs = mem; |
414 | equeue->mask_num_entries = num_entries - 1; | 421 | equeue->mask_num_entries = num_entries - 1; |
415 | equeue->log2_num_entries = __builtin_ctz(num_entries); | 422 | equeue->log2_num_entries = __builtin_ctz(num_entries); |
423 | equeue->context = context; | ||
424 | equeue->ering = ering; | ||
425 | equeue->channel = channel; | ||
416 | 426 | ||
417 | return 0; | 427 | return 0; |
418 | } | 428 | } |
@@ -493,6 +503,20 @@ static gxio_mpipe_context_t *_gxio_get_link_context(void) | |||
493 | return contextp; | 503 | return contextp; |
494 | } | 504 | } |
495 | 505 | ||
506 | int 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 | |||
496 | int gxio_mpipe_link_enumerate_mac(int idx, char *link_name, uint8_t *link_mac) | 520 | int gxio_mpipe_link_enumerate_mac(int idx, char *link_name, uint8_t *link_mac) |
497 | { | 521 | { |
498 | int rv; | 522 | int rv; |
@@ -543,3 +567,12 @@ int gxio_mpipe_link_close(gxio_mpipe_link_t *link) | |||
543 | } | 567 | } |
544 | 568 | ||
545 | EXPORT_SYMBOL_GPL(gxio_mpipe_link_close); | 569 | EXPORT_SYMBOL_GPL(gxio_mpipe_link_close); |
570 | |||
571 | int gxio_mpipe_link_set_attr(gxio_mpipe_link_t *link, uint32_t attr, | ||
572 | int64_t val) | ||
573 | { | ||
574 | return gxio_mpipe_link_set_attr_aux(link->context, link->mac, attr, | ||
575 | val); | ||
576 | } | ||
577 | |||
578 | EXPORT_SYMBOL_GPL(gxio_mpipe_link_set_attr); | ||