Skip to content

Commit f3286a3

Browse files
cmetcalf-tileradavem330
authored andcommitted
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>
1 parent 6ab4ae9 commit f3286a3

6 files changed

Lines changed: 417 additions & 212 deletions

File tree

‎arch/tile/gxio/iorpc_mpipe_info.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,24 @@
1616
#include "gxio/iorpc_mpipe_info.h"
1717

1818

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+
1937
struct enumerate_aux_param {
2038
_gxio_mpipe_link_name_t name;
2139
_gxio_mpipe_link_mac_t mac;

‎arch/tile/gxio/mpipe.c‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,21 @@ int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index)
3636
int fd;
3737
int i;
3838

39+
if (mpipe_index >= GXIO_MPIPE_INSTANCE_MAX)
40+
return -EINVAL;
41+
3942
snprintf(file, sizeof(file), "mpipe/%d/iorpc", mpipe_index);
4043
fd = hv_dev_open((HV_VirtAddr) file, 0);
44+
45+
context->fd = fd;
46+
4147
if (fd < 0) {
4248
if (fd >= GXIO_ERR_MIN && fd <= GXIO_ERR_MAX)
4349
return fd;
4450
else
4551
return -ENODEV;
4652
}
4753

48-
context->fd = fd;
49-
5054
/* Map in the MMIO space. */
5155
context->mmio_cfg_base = (void __force *)
5256
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)
6468
for (i = 0; i < 8; i++)
6569
context->__stacks.stacks[i] = 255;
6670

71+
context->instance = mpipe_index;
72+
6773
return 0;
6874

6975
fast_failed:
7076
iounmap((void __force __iomem *)(context->mmio_cfg_base));
7177
cfg_failed:
7278
hv_dev_close(context->fd);
79+
context->fd = -1;
7380
return -ENODEV;
7481
}
7582

@@ -496,6 +503,20 @@ static gxio_mpipe_context_t *_gxio_get_link_context(void)
496503
return contextp;
497504
}
498505

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+
499520
int gxio_mpipe_link_enumerate_mac(int idx, char *link_name, uint8_t *link_mac)
500521
{
501522
int rv;

‎arch/tile/include/gxio/iorpc_mpipe_info.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@
2727
#include <asm/pgtable.h>
2828

2929

30+
#define GXIO_MPIPE_INFO_OP_INSTANCE_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1250)
3031
#define GXIO_MPIPE_INFO_OP_ENUMERATE_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1251)
3132
#define GXIO_MPIPE_INFO_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000)
3233
#define GXIO_MPIPE_INFO_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001)
3334

3435

36+
int gxio_mpipe_info_instance_aux(gxio_mpipe_info_context_t * context,
37+
_gxio_mpipe_link_name_t name);
38+
3539
int gxio_mpipe_info_enumerate_aux(gxio_mpipe_info_context_t * context,
3640
unsigned int idx,
3741
_gxio_mpipe_link_name_t * name,

‎arch/tile/include/gxio/mpipe.h‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ typedef MPIPE_PDESC_t gxio_mpipe_idesc_t;
220220
*/
221221
typedef MPIPE_EDMA_DESC_t gxio_mpipe_edesc_t;
222222

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+
223230
/* Get the "va" field from an "idesc".
224231
*
225232
* This is the address at which the ingress hardware copied the first
@@ -311,6 +318,9 @@ typedef struct {
311318
/* File descriptor for calling up to Linux (and thus the HV). */
312319
int fd;
313320

321+
/* Corresponding mpipe instance #. */
322+
int instance;
323+
314324
/* The VA at which configuration registers are mapped. */
315325
char *mmio_cfg_base;
316326

@@ -1716,6 +1726,24 @@ typedef struct {
17161726
uint8_t mac;
17171727
} gxio_mpipe_link_t;
17181728

1729+
/* Translate a link name to the instance number of the mPIPE shim which is
1730+
* connected to that link. This call does not verify whether the link is
1731+
* currently available, and does not reserve any link resources;
1732+
* gxio_mpipe_link_open() must be called to perform those functions.
1733+
*
1734+
* Typically applications will call this function to translate a link name
1735+
* to an mPIPE instance number; call gxio_mpipe_init(), passing it that
1736+
* instance number, to initialize the mPIPE shim; and then call
1737+
* gxio_mpipe_link_open(), passing it the same link name plus the mPIPE
1738+
* context, to configure the link.
1739+
*
1740+
* @param link_name Name of the link; see @ref gxio_mpipe_link_names.
1741+
* @return The mPIPE instance number which is associated with the named
1742+
* link, or a negative error code (::GXIO_ERR_NO_DEVICE) if the link does
1743+
* not exist.
1744+
*/
1745+
extern int gxio_mpipe_link_instance(const char *link_name);
1746+
17191747
/* Retrieve one of this system's legal link names, and its MAC address.
17201748
*
17211749
* @param index Link name index. If a system supports N legal link names,

‎arch/tile/include/hv/drv_mpipe_intf.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#include <arch/mpipe_constants.h>
2424

2525

26+
/** Number of mPIPE instances supported */
27+
#define HV_MPIPE_INSTANCE_MAX (2)
28+
2629
/** Number of buffer stacks (32). */
2730
#define HV_MPIPE_NUM_BUFFER_STACKS \
2831
(MPIPE_MMIO_INIT_DAT_GX36_1__BUFFER_STACK_MASK_WIDTH)

0 commit comments

Comments
 (0)