Commit 215b2524 authored by Vikram Narayanan's avatar Vikram Narayanan

lcd/ixgbe: Refactor glue helpers

Signed-off-by: Vikram Narayanan's avatarVikram Narayanan <vikram186@gmail.com>
parent 06f14653
...@@ -16,22 +16,33 @@ struct type_ops_id { ...@@ -16,22 +16,33 @@ struct type_ops_id {
cap_type_t libcap_type; cap_type_t libcap_type;
}; };
static int dummy_func(struct cspace *cspace, struct cnode *cnode,
void *object)
{
return 0;
}
enum glue_type { enum glue_type {
GLUE_TYPE_DEVICE_CONTAINER,
GLUE_TYPE_MODULE_CONTAINER, GLUE_TYPE_MODULE_CONTAINER,
GLUE_TYPE_NET_DEVICE_CONTAINER, GLUE_TYPE_NET_DEVICE_CONTAINER,
GLUE_TYPE_PCI_BUS_CONTAINER,
GLUE_TYPE_PCI_DEV_CONTAINER, GLUE_TYPE_PCI_DEV_CONTAINER,
GLUE_TYPE_PCI_DEVICE_ID_CONTAINER, GLUE_TYPE_PCI_DEVICE_ID_CONTAINER,
GLUE_TYPE_PCI_DRIVER_CONTAINER, GLUE_TYPE_PCI_DRIVER_CONTAINER,
GLUE_TYPE_SK_BUFF_CONTAINER,
GLUE_NR_TYPES, GLUE_NR_TYPES,
};
static int dummy_func(struct cspace *cspace, struct cnode *cnode, };
void *object)
{
return 0;
}
static struct type_ops_id glue_libcap_type_ops[GLUE_NR_TYPES] = { static struct type_ops_id glue_libcap_type_ops[GLUE_NR_TYPES] = {
{
{
.name = "struct device",
.delete = dummy_func,
.revoke = dummy_func,
}
},
{ {
{ {
.name = "struct module", .name = "struct module",
...@@ -46,6 +57,13 @@ static struct type_ops_id glue_libcap_type_ops[GLUE_NR_TYPES] = { ...@@ -46,6 +57,13 @@ static struct type_ops_id glue_libcap_type_ops[GLUE_NR_TYPES] = {
.revoke = dummy_func, .revoke = dummy_func,
} }
}, },
{
{
.name = "struct pci_bus",
.delete = dummy_func,
.revoke = dummy_func,
}
},
{ {
{ {
.name = "struct pci_dev", .name = "struct pci_dev",
...@@ -67,6 +85,13 @@ static struct type_ops_id glue_libcap_type_ops[GLUE_NR_TYPES] = { ...@@ -67,6 +85,13 @@ static struct type_ops_id glue_libcap_type_ops[GLUE_NR_TYPES] = {
.revoke = dummy_func, .revoke = dummy_func,
} }
}, },
{
{
.name = "struct sk_buff",
.delete = dummy_func,
.revoke = dummy_func,
}
},
}; };
int glue_cap_init(void) int glue_cap_init(void)
...@@ -145,114 +170,4 @@ void glue_cap_exit(void) ...@@ -145,114 +170,4 @@ void glue_cap_exit(void)
} }
} }
int glue_cap_insert_module_type(struct glue_cspace *cspace, #include "ixgbe_glue_helper.c"
struct module_container *module_container,
struct cptr *c_out)
{
return glue_cspace_insert(cspace,
module_container,
glue_libcap_type_ops[ GLUE_TYPE_MODULE_CONTAINER ].libcap_type,
c_out);
}
int glue_cap_lookup_module_type(struct glue_cspace *cspace,
struct cptr c,
struct module_container **module_container)
{
return glue_cspace_lookup(cspace,
c,
glue_libcap_type_ops[ GLUE_TYPE_MODULE_CONTAINER ].libcap_type,
( void ** )module_container);
}
int glue_cap_insert_pci_dev_type(struct glue_cspace *cspace,
struct pci_dev_container *pci_dev_container,
struct cptr *c_out)
{
return glue_cspace_insert(cspace,
pci_dev_container,
glue_libcap_type_ops[ GLUE_TYPE_PCI_DEV_CONTAINER ].libcap_type,
c_out);
}
int glue_cap_lookup_pci_dev_type(struct glue_cspace *cspace,
struct cptr c,
struct pci_dev_container **pci_dev_container)
{
return glue_cspace_lookup(cspace,
c,
glue_libcap_type_ops[ GLUE_TYPE_PCI_DEV_CONTAINER ].libcap_type,
( void ** )pci_dev_container);
}
int glue_cap_insert_pci_device_id_type(struct glue_cspace *cspace,
struct pci_device_id_container *pci_device_id_container,
struct cptr *c_out)
{
return glue_cspace_insert(cspace,
pci_device_id_container,
glue_libcap_type_ops[ GLUE_TYPE_PCI_DEVICE_ID_CONTAINER ].libcap_type,
c_out);
}
int glue_cap_lookup_pci_device_id_type(struct glue_cspace *cspace,
struct cptr c,
struct pci_device_id_container **pci_device_id_container)
{
return glue_cspace_lookup(cspace,
c,
glue_libcap_type_ops[ GLUE_TYPE_PCI_DEVICE_ID_CONTAINER ].libcap_type,
( void ** )pci_device_id_container);
}
int glue_cap_insert_pci_driver_type(struct glue_cspace *cspace,
struct pci_driver_container *pci_driver_container,
struct cptr *c_out)
{
return glue_cspace_insert(cspace,
pci_driver_container,
glue_libcap_type_ops[ GLUE_TYPE_PCI_DRIVER_CONTAINER ].libcap_type,
c_out);
}
int glue_cap_lookup_pci_driver_type(struct glue_cspace *cspace,
struct cptr c,
struct pci_driver_container **pci_driver_container)
{
return glue_cspace_lookup(cspace,
c,
glue_libcap_type_ops[ GLUE_TYPE_PCI_DRIVER_CONTAINER ].libcap_type,
( void ** )pci_driver_container);
}
int glue_cap_insert_net_device_type(struct glue_cspace *cspace,
struct net_device_container *net_device_container,
struct cptr *c_out)
{
return glue_cspace_insert(cspace,
net_device_container,
glue_libcap_type_ops[ GLUE_TYPE_NET_DEVICE_CONTAINER ].libcap_type,
c_out);
}
int glue_cap_lookup_net_device_type(struct glue_cspace *cspace,
struct cptr c,
struct net_device_container **net_device_container)
{
return glue_cspace_lookup(cspace,
c,
glue_libcap_type_ops[ GLUE_TYPE_NET_DEVICE_CONTAINER ].libcap_type,
( void ** )net_device_container);
}
...@@ -14,49 +14,50 @@ ...@@ -14,49 +14,50 @@
#include <liblcd/liblcd.h> #include <liblcd/liblcd.h>
#include <liblcd/sync_ipc_poll.h> #include <liblcd/sync_ipc_poll.h>
#define PCI_REGIONS #include "ixgbe_glue_helper.h"
#define PCI_REGIONS
enum dispatch_t { enum dispatch_t {
__PCI_REGISTER_DRIVER, __PCI_REGISTER_DRIVER,
PROBE,
REMOVE,
PCI_UNREGISTER_DRIVER, PCI_UNREGISTER_DRIVER,
ALLOC_ETHERDEV_MQS, ALLOC_ETHERDEV_MQS,
}; REGISTER_NETDEVICE,
ETHER_SETUP,
struct module_container { ETH_MAC_ADDR,
struct module module; ETH_VALIDATE_ADDR,
struct cptr other_ref; FREE_NETDEV,
struct cptr my_ref; NETIF_CARRIER_OFF,
}; NETIF_CARRIER_ON,
NETIF_DEVICE_ATTACH,
struct net_device_container { NETIF_DEVICE_DETACH,
struct net_device net_device; NETIF_SET_REAL_NUM_RX_QUEUES,
struct cptr other_ref; NETIF_SET_REAL_NUM_TX_QUEUES,
struct cptr my_ref; CONSUME_SKB,
}; UNREGISTER_NETDEV,
ETH_PLATFORM_GET_MAC_ADDRESS,
struct pci_dev_container { DEV_ADDR_DEL,
struct pci_dev pci_dev; DEVICE_SET_WAKEUP_ENABLE,
struct cptr other_ref; ETH_GET_HEADLEN,
struct cptr my_ref; NETIF_TX_STOP_ALL_QUEUES,
}; PCI_DISABLE_PCIE_ERROR_REPORTING,
struct pci_device_id_container { PCI_BUS_READ_CONFIG_WORD,
struct pci_device_id pci_device_id; PCI_BUS_WRITE_CONFIG_WORD,
struct cptr other_ref; PCI_CLEANUP_AER_UNCORRECT_ERROR_STATUS,
struct cptr my_ref; PCI_DISABLE_DEVICE,
}; PCI_ENABLE_PCIE_ERROR_REPORTING,
struct pci_driver_container { PCIE_CAPABILITY_READ_WORD,
struct pci_driver pci_driver; PCIE_GET_MINIMUM_LINK,
struct cptr other_ref; PCI_ENABLE_DEVICE_MEM,
struct cptr my_ref; PCI_REQUEST_SELECTED_REGIONS,
}; PCI_REQUEST_SELECTED_REGIONS_EXCLUSIVE,
struct trampoline_hidden_args { PCI_SET_MASTER,
void *struct_container; PCI_SAVE_STATE,
struct glue_cspace *cspace; PCI_RELEASE_SELECTED_REGIONS,
struct lcd_trampoline_handle *t_handle; PCI_SELECT_BARS,
struct thc_channel *async_chnl; PCI_WAKE_FROM_D3,
struct cptr sync_ep; PROBE,
REMOVE,
TRIGGER_EXIT,
}; };
#define ASYNC_RPC_BUFFER_ORDER 12 #define ASYNC_RPC_BUFFER_ORDER 12
...@@ -74,38 +75,6 @@ void glue_cap_remove( ...@@ -74,38 +75,6 @@ void glue_cap_remove(
struct glue_cspace *cspace, struct glue_cspace *cspace,
cptr_t c); cptr_t c);
int glue_cap_insert_module_type(struct glue_cspace *cspace,
struct module_container *module_container,
struct cptr *c_out);
int glue_cap_insert_pci_dev_type(struct glue_cspace *cspace,
struct pci_dev_container *pci_dev_container,
struct cptr *c_out);
int glue_cap_insert_pci_device_id_type(struct glue_cspace *cspace,
struct pci_device_id_container *pci_device_id_container,
struct cptr *c_out);
int glue_cap_insert_pci_driver_type(struct glue_cspace *cspace,
struct pci_driver_container *pci_driver_container,
struct cptr *c_out);
int glue_cap_insert_net_device_type(struct glue_cspace *cspace,
struct net_device_container *net_device_container,
struct cptr *c_out);
int glue_cap_lookup_module_type(struct glue_cspace *cspace,
struct cptr c,
struct module_container **module_container);
int glue_cap_lookup_pci_dev_type(struct glue_cspace *cspace,
struct cptr c,
struct pci_dev_container **pci_dev_container);
int glue_cap_lookup_pci_device_id_type(struct glue_cspace *cspace,
struct cptr c,
struct pci_device_id_container **pci_device_id_container);
int glue_cap_lookup_pci_driver_type(struct glue_cspace *cspace,
struct cptr c,
struct pci_driver_container **pci_driver_container);
int glue_cap_lookup_net_device_type(struct glue_cspace *cspace,
struct cptr c,
struct net_device_container **net_device_container);
/* ASYNC HELPERS -------------------------------------------------- */ /* ASYNC HELPERS -------------------------------------------------- */
static inline static inline
......
int glue_cap_insert_device_type(struct glue_cspace *cspace,
struct device_container *device_container,
struct cptr *c_out)
{
return glue_cspace_insert(cspace,
device_container,
glue_libcap_type_ops[ GLUE_TYPE_DEVICE_CONTAINER ].libcap_type,
c_out);
}
int glue_cap_lookup_device_type(struct glue_cspace *cspace,
struct cptr c,
struct device_container **device_container)
{
return glue_cspace_lookup(cspace,
c,
glue_libcap_type_ops[ GLUE_TYPE_DEVICE_CONTAINER ].libcap_type,
( void ** )device_container);
}
int glue_cap_insert_module_type(struct glue_cspace *cspace,
struct module_container *module_container,
struct cptr *c_out)
{
return glue_cspace_insert(cspace,
module_container,
glue_libcap_type_ops[ GLUE_TYPE_MODULE_CONTAINER ].libcap_type,
c_out);
}
int glue_cap_lookup_module_type(struct glue_cspace *cspace,
struct cptr c,
struct module_container **module_container)
{
return glue_cspace_lookup(cspace,
c,
glue_libcap_type_ops[ GLUE_TYPE_MODULE_CONTAINER ].libcap_type,
( void ** )module_container);
}
int glue_cap_insert_net_device_type(struct glue_cspace *cspace,
struct net_device_container *net_device_container,
struct cptr *c_out)
{
return glue_cspace_insert(cspace,
net_device_container,
glue_libcap_type_ops[ GLUE_TYPE_NET_DEVICE_CONTAINER ].libcap_type,
c_out);
}
int glue_cap_lookup_net_device_type(struct glue_cspace *cspace,
struct cptr c,
struct net_device_container **net_device_container)
{
return glue_cspace_lookup(cspace,
c,
glue_libcap_type_ops[ GLUE_TYPE_NET_DEVICE_CONTAINER ].libcap_type,
( void ** )net_device_container);
}
int glue_cap_insert_pci_bus_type(struct glue_cspace *cspace,
struct pci_bus_container *pci_bus_container,
struct cptr *c_out)
{
return glue_cspace_insert(cspace,
pci_bus_container,
glue_libcap_type_ops[ GLUE_TYPE_PCI_BUS_CONTAINER ].libcap_type,
c_out);
}
int glue_cap_lookup_pci_bus_type(struct glue_cspace *cspace,
struct cptr c,
struct pci_bus_container **pci_bus_container)
{
return glue_cspace_lookup(cspace,
c,
glue_libcap_type_ops[ GLUE_TYPE_PCI_BUS_CONTAINER ].libcap_type,
( void ** )pci_bus_container);
}
int glue_cap_insert_pci_dev_type(struct glue_cspace *cspace,
struct pci_dev_container *pci_dev_container,
struct cptr *c_out)
{
return glue_cspace_insert(cspace,
pci_dev_container,
glue_libcap_type_ops[ GLUE_TYPE_PCI_DEV_CONTAINER ].libcap_type,
c_out);
}
int glue_cap_lookup_pci_dev_type(struct glue_cspace *cspace,
struct cptr c,
struct pci_dev_container **pci_dev_container)
{
return glue_cspace_lookup(cspace,
c,
glue_libcap_type_ops[ GLUE_TYPE_PCI_DEV_CONTAINER ].libcap_type,
( void ** )pci_dev_container);
}
int glue_cap_insert_pci_device_id_type(struct glue_cspace *cspace,
struct pci_device_id_container *pci_device_id_container,
struct cptr *c_out)
{
return glue_cspace_insert(cspace,
pci_device_id_container,
glue_libcap_type_ops[ GLUE_TYPE_PCI_DEVICE_ID_CONTAINER ].libcap_type,
c_out);
}
int glue_cap_lookup_pci_device_id_type(struct glue_cspace *cspace,
struct cptr c,
struct pci_device_id_container **pci_device_id_container)
{
return glue_cspace_lookup(cspace,
c,
glue_libcap_type_ops[ GLUE_TYPE_PCI_DEVICE_ID_CONTAINER ].libcap_type,
( void ** )pci_device_id_container);
}
int glue_cap_insert_pci_driver_type(struct glue_cspace *cspace,
struct pci_driver_container *pci_driver_container,
struct cptr *c_out)
{
return glue_cspace_insert(cspace,
pci_driver_container,
glue_libcap_type_ops[ GLUE_TYPE_PCI_DRIVER_CONTAINER ].libcap_type,
c_out);
}
int glue_cap_lookup_pci_driver_type(struct glue_cspace *cspace,
struct cptr c,
struct pci_driver_container **pci_driver_container)
{
return glue_cspace_lookup(cspace,
c,
glue_libcap_type_ops[ GLUE_TYPE_PCI_DRIVER_CONTAINER ].libcap_type,
( void ** )pci_driver_container);
}
int glue_cap_insert_sk_buff_type(struct glue_cspace *cspace,
struct sk_buff_container *sk_buff_container,
struct cptr *c_out)
{
return glue_cspace_insert(cspace,
sk_buff_container,
glue_libcap_type_ops[ GLUE_TYPE_SK_BUFF_CONTAINER ].libcap_type,
c_out);
}
int glue_cap_lookup_sk_buff_type(struct glue_cspace *cspace,
struct cptr c,
struct sk_buff_container **sk_buff_container)
{
return glue_cspace_lookup(cspace,
c,
glue_libcap_type_ops[ GLUE_TYPE_SK_BUFF_CONTAINER ].libcap_type,
( void ** )sk_buff_container);
}
#ifndef __IXGBE_GLUE_HELPER_H__
#define __IXGBE_GLUE_HELPER_H__
struct device_container {
struct device device;
struct cptr other_ref;
struct cptr my_ref;
};
struct module_container {
struct module module;
struct cptr other_ref;
struct cptr my_ref;
};
struct net_device_container {
struct net_device net_device;
struct cptr other_ref;
struct cptr my_ref;
};
struct pci_bus_container {
struct pci_bus pci_bus;
struct cptr other_ref;
struct cptr my_ref;
};
struct pci_dev_container {
struct pci_dev pci_dev;
struct cptr other_ref;
struct cptr my_ref;
};
struct pci_device_id_container {
struct pci_device_id pci_device_id;
struct cptr other_ref;
struct cptr my_ref;
};
struct pci_driver_container {
struct pci_driver pci_driver;
struct cptr other_ref;
struct cptr my_ref;
};
struct sk_buff_container {
struct sk_buff sk_buff;
struct cptr other_ref;
struct cptr my_ref;
};
struct trampoline_hidden_args {
void *struct_container;
struct glue_cspace *cspace;
struct lcd_trampoline_handle *t_handle;
struct thc_channel *async_chnl;
struct cptr sync_ep;
};
int glue_cap_insert_device_type(struct glue_cspace *cspace,
struct device_container *device_container,
struct cptr *c_out);
int glue_cap_insert_module_type(struct glue_cspace *cspace,
struct module_container *module_container,
struct cptr *c_out);
int glue_cap_insert_net_device_type(struct glue_cspace *cspace,
struct net_device_container *net_device_container,
struct cptr *c_out);
int glue_cap_insert_pci_bus_type(struct glue_cspace *cspace,
struct pci_bus_container *pci_bus_container,
struct cptr *c_out);
int glue_cap_insert_pci_dev_type(struct glue_cspace *cspace,
struct pci_dev_container *pci_dev_container,
struct cptr *c_out);
int glue_cap_insert_pci_device_id_type(struct glue_cspace *cspace,
struct pci_device_id_container *pci_device_id_container,
struct cptr *c_out);
int glue_cap_insert_pci_driver_type(struct glue_cspace *cspace,
struct pci_driver_container *pci_driver_container,
struct cptr *c_out);
int glue_cap_insert_sk_buff_type(struct glue_cspace *cspace,
struct sk_buff_container *sk_buff_container,
struct cptr *c_out);
int glue_cap_lookup_device_type(struct glue_cspace *cspace,
struct cptr c,
struct device_container **device_container);
int glue_cap_lookup_module_type(struct glue_cspace *cspace,
struct cptr c,
struct module_container **module_container);
int glue_cap_lookup_net_device_type(struct glue_cspace *cspace,
struct cptr c,
struct net_device_container **net_device_container);
int glue_cap_lookup_pci_bus_type(struct glue_cspace *cspace,
struct cptr c,
struct pci_bus_container **pci_bus_container);
int glue_cap_lookup_pci_dev_type(struct glue_cspace *cspace,
struct cptr c,
struct pci_dev_container **pci_dev_container);
int glue_cap_lookup_pci_device_id_type(struct glue_cspace *cspace,
struct cptr c,
struct pci_device_id_container **pci_device_id_container);
int glue_cap_lookup_pci_driver_type(struct glue_cspace *cspace,
struct cptr c,
struct pci_driver_container **pci_driver_container);
int glue_cap_lookup_sk_buff_type(struct glue_cspace *cspace,
struct cptr c,
struct sk_buff_container **sk_buff_container);
#endif /* __IXGBE_GLUE_HELPER_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment