提交 f3286a3a 编写于 作者: C Chris Metcalf 提交者: David S. Miller

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: NChris Metcalf <cmetcalf@tilera.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 6ab4ae9a
...@@ -16,6 +16,24 @@ ...@@ -16,6 +16,24 @@
#include "gxio/iorpc_mpipe_info.h" #include "gxio/iorpc_mpipe_info.h"
struct instance_aux_param {
_gxio_mpipe_link_name_t name;
};
int gxio_mpipe_info_instance_aux(gxio_mpipe_info_context_t * context,
_gxio_mpipe_link_name_t name)
{
struct instance_aux_param temp;
struct instance_aux_param *params = &temp;
params->name = name;
return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
sizeof(*params), GXIO_MPIPE_INFO_OP_INSTANCE_AUX);
}
EXPORT_SYMBOL(gxio_mpipe_info_instance_aux);
struct enumerate_aux_param { struct enumerate_aux_param {
_gxio_mpipe_link_name_t name; _gxio_mpipe_link_name_t name;
_gxio_mpipe_link_mac_t mac; _gxio_mpipe_link_mac_t mac;
......
...@@ -36,8 +36,14 @@ int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index) ...@@ -36,8 +36,14 @@ int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index)
int fd; int fd;
int i; int i;
if (mpipe_index >= GXIO_MPIPE_INSTANCE_MAX)
return -EINVAL;
snprintf(file, sizeof(file), "mpipe/%d/iorpc", mpipe_index); snprintf(file, sizeof(file), "mpipe/%d/iorpc", mpipe_index);
fd = hv_dev_open((HV_VirtAddr) file, 0); fd = hv_dev_open((HV_VirtAddr) file, 0);
context->fd = fd;
if (fd < 0) { if (fd < 0) {
if (fd >= GXIO_ERR_MIN && fd <= GXIO_ERR_MAX) if (fd >= GXIO_ERR_MIN && fd <= GXIO_ERR_MAX)
return fd; return fd;
...@@ -45,8 +51,6 @@ int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index) ...@@ -45,8 +51,6 @@ int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index)
return -ENODEV; return -ENODEV;
} }
context->fd = fd;
/* Map in the MMIO space. */ /* Map in the MMIO space. */
context->mmio_cfg_base = (void __force *) context->mmio_cfg_base = (void __force *)
iorpc_ioremap(fd, HV_MPIPE_CONFIG_MMIO_OFFSET, 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,12 +68,15 @@ int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index)
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
context->__stacks.stacks[i] = 255; context->__stacks.stacks[i] = 255;
context->instance = mpipe_index;
return 0; return 0;
fast_failed: fast_failed:
iounmap((void __force __iomem *)(context->mmio_cfg_base)); iounmap((void __force __iomem *)(context->mmio_cfg_base));
cfg_failed: cfg_failed:
hv_dev_close(context->fd); hv_dev_close(context->fd);
context->fd = -1;
return -ENODEV; return -ENODEV;
} }
...@@ -496,6 +503,20 @@ static gxio_mpipe_context_t *_gxio_get_link_context(void) ...@@ -496,6 +503,20 @@ static gxio_mpipe_context_t *_gxio_get_link_context(void)
return contextp; return contextp;
} }
int gxio_mpipe_link_instance(const char *link_name)
{
_gxio_mpipe_link_name_t name;
gxio_mpipe_context_t *context = _gxio_get_link_context();
if (!context)
return GXIO_ERR_NO_DEVICE;
strncpy(name.name, link_name, sizeof(name.name));
name.name[GXIO_MPIPE_LINK_NAME_LEN - 1] = '\0';
return gxio_mpipe_info_instance_aux(context, name);
}
int gxio_mpipe_link_enumerate_mac(int idx, char *link_name, uint8_t *link_mac) int gxio_mpipe_link_enumerate_mac(int idx, char *link_name, uint8_t *link_mac)
{ {
int rv; int rv;
......
...@@ -27,11 +27,15 @@ ...@@ -27,11 +27,15 @@
#include <asm/pgtable.h> #include <asm/pgtable.h>
#define GXIO_MPIPE_INFO_OP_INSTANCE_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1250)
#define GXIO_MPIPE_INFO_OP_ENUMERATE_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1251) #define GXIO_MPIPE_INFO_OP_ENUMERATE_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1251)
#define GXIO_MPIPE_INFO_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000) #define GXIO_MPIPE_INFO_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000)
#define GXIO_MPIPE_INFO_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001) #define GXIO_MPIPE_INFO_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001)
int gxio_mpipe_info_instance_aux(gxio_mpipe_info_context_t * context,
_gxio_mpipe_link_name_t name);
int gxio_mpipe_info_enumerate_aux(gxio_mpipe_info_context_t * context, int gxio_mpipe_info_enumerate_aux(gxio_mpipe_info_context_t * context,
unsigned int idx, unsigned int idx,
_gxio_mpipe_link_name_t * name, _gxio_mpipe_link_name_t * name,
......
...@@ -220,6 +220,13 @@ typedef MPIPE_PDESC_t gxio_mpipe_idesc_t; ...@@ -220,6 +220,13 @@ typedef MPIPE_PDESC_t gxio_mpipe_idesc_t;
*/ */
typedef MPIPE_EDMA_DESC_t gxio_mpipe_edesc_t; typedef MPIPE_EDMA_DESC_t gxio_mpipe_edesc_t;
/*
* Max # of mpipe instances. 2 currently.
*/
#define GXIO_MPIPE_INSTANCE_MAX HV_MPIPE_INSTANCE_MAX
#define NR_MPIPE_MAX GXIO_MPIPE_INSTANCE_MAX
/* Get the "va" field from an "idesc". /* Get the "va" field from an "idesc".
* *
* This is the address at which the ingress hardware copied the first * This is the address at which the ingress hardware copied the first
...@@ -311,6 +318,9 @@ typedef struct { ...@@ -311,6 +318,9 @@ typedef struct {
/* File descriptor for calling up to Linux (and thus the HV). */ /* File descriptor for calling up to Linux (and thus the HV). */
int fd; int fd;
/* Corresponding mpipe instance #. */
int instance;
/* The VA at which configuration registers are mapped. */ /* The VA at which configuration registers are mapped. */
char *mmio_cfg_base; char *mmio_cfg_base;
...@@ -1716,6 +1726,24 @@ typedef struct { ...@@ -1716,6 +1726,24 @@ typedef struct {
uint8_t mac; uint8_t mac;
} gxio_mpipe_link_t; } gxio_mpipe_link_t;
/* Translate a link name to the instance number of the mPIPE shim which is
* connected to that link. This call does not verify whether the link is
* currently available, and does not reserve any link resources;
* gxio_mpipe_link_open() must be called to perform those functions.
*
* Typically applications will call this function to translate a link name
* to an mPIPE instance number; call gxio_mpipe_init(), passing it that
* instance number, to initialize the mPIPE shim; and then call
* gxio_mpipe_link_open(), passing it the same link name plus the mPIPE
* context, to configure the link.
*
* @param link_name Name of the link; see @ref gxio_mpipe_link_names.
* @return The mPIPE instance number which is associated with the named
* link, or a negative error code (::GXIO_ERR_NO_DEVICE) if the link does
* not exist.
*/
extern int gxio_mpipe_link_instance(const char *link_name);
/* Retrieve one of this system's legal link names, and its MAC address. /* Retrieve one of this system's legal link names, and its MAC address.
* *
* @param index Link name index. If a system supports N legal link names, * @param index Link name index. If a system supports N legal link names,
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
#include <arch/mpipe_constants.h> #include <arch/mpipe_constants.h>
/** Number of mPIPE instances supported */
#define HV_MPIPE_INSTANCE_MAX (2)
/** Number of buffer stacks (32). */ /** Number of buffer stacks (32). */
#define HV_MPIPE_NUM_BUFFER_STACKS \ #define HV_MPIPE_NUM_BUFFER_STACKS \
(MPIPE_MMIO_INIT_DAT_GX36_1__BUFFER_STACK_MASK_WIDTH) (MPIPE_MMIO_INIT_DAT_GX36_1__BUFFER_STACK_MASK_WIDTH)
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册