From dc216e76385fa3edbf82d92b94735a411c77ade7 Mon Sep 17 00:00:00 2001 From: Vikram Narayanan Date: Tue, 25 Apr 2017 06:05:58 -0600 Subject: [PATCH] lcd/ixgbe: Assign/deassign device during probe/remove Using iommu apis, assign/deassign the pci device during probe and remove inside the LCD. Also map appropriate number of pages during xmit. Signed-off-by: Vikram Narayanan --- lcd-domains/test_mods/ixgbe/ixgbe_common.h | 5 +++ .../ixgbe/ixgbe_lcd/glue/ixgbe_caller.c | 41 ++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/lcd-domains/test_mods/ixgbe/ixgbe_common.h b/lcd-domains/test_mods/ixgbe/ixgbe_common.h index a2a3526cf4ee..e01c8f8c344f 100644 --- a/lcd-domains/test_mods/ixgbe/ixgbe_common.h +++ b/lcd-domains/test_mods/ixgbe/ixgbe_common.h @@ -18,6 +18,7 @@ #include "ixgbe_glue_helper.h" #define PCI_REGIONS +#define IOMMU_ASSIGN enum dispatch_t { __PCI_REGISTER_DRIVER, @@ -99,6 +100,10 @@ typedef enum { #define ASYNC_RPC_BUFFER_ORDER 12 +struct pcidev_info { + unsigned int domain, bus, slot, fn; +}; + /* CSPACES ------------------------------------------------------------ */ int glue_cap_init(void); diff --git a/lcd-domains/test_mods/ixgbe/ixgbe_lcd/glue/ixgbe_caller.c b/lcd-domains/test_mods/ixgbe/ixgbe_lcd/glue/ixgbe_caller.c index 9c05b027ed48..33ab09e9f590 100644 --- a/lcd-domains/test_mods/ixgbe/ixgbe_lcd/glue/ixgbe_caller.c +++ b/lcd-domains/test_mods/ixgbe/ixgbe_lcd/glue/ixgbe_caller.c @@ -20,6 +20,11 @@ extern cptr_t ixgbe_register_channel; static struct net_device *g_net_device; +#ifdef IOMMU_ASSIGN +/* device for IOMMU assignment */ +struct pcidev_info dev_assign = { 0x0000, 0x04, 0x00, 0x1 }; +#endif + int glue_ixgbe_init(void) { int ret; @@ -531,6 +536,9 @@ int probe_callee(struct fipc_message *_request, int func_ret; int ret = 0; cptr_t other_ref; +#ifdef IOMMU_ASSIGN + unsigned int devfn; +#endif #ifdef PCI_REGIONS cptr_t res0_cptr; @@ -539,6 +547,17 @@ int probe_callee(struct fipc_message *_request, void *dev_resource_0; #endif +#ifdef IOMMU_ASSIGN + devfn = PCI_DEVFN(dev_assign.slot, dev_assign.fn); + + ret = lcd_syscall_assign_device(dev_assign.domain, + dev_assign.bus, + devfn); + if (ret) + LIBLCD_ERR("Could not assign pci device to LCD: ret %d", + ret); +#endif + LIBLCD_MSG("%s called", __func__); request_cookie = thc_get_request_cookie(_request); dma_mask = fipc_get_reg2(_request); @@ -676,6 +695,17 @@ int remove_callee(struct fipc_message *_request, fipc_recv_msg_end(thc_channel_to_fipc(_channel), _request); +#ifdef IOMMU_ASSIGN + devfn = PCI_DEVFN(dev_assign.slot, dev_assign.fn); + + ret = lcd_syscall_deassign_device(dev_assign.domain, + dev_assign.bus, + devfn); + if (ret) + LIBLCD_ERR("Could not deassign pci device to LCD: ret %d", + ret); +#endif + /* XXX: refer the comments under probe_callee */ ixgbe_driver_container.pci_driver.remove(NULL); @@ -2220,7 +2250,16 @@ int ndo_start_xmit_callee(struct fipc_message *_request, skb->head = (void*)(gva_val(skbd_gva) + skbd_off); skb->data = skb->head + data_off; - LIBLCD_MSG("data %x %x", skb->data[12], skb->data[13]); +#ifdef IOMMU_ASSIGN + ret = lcd_syscall_iommu_map_page(lcd_gva2gpa(skbd_gva), + skbd_ord, true); + LIBLCD_MSG("%s, order %d | gva %p | gpa %p", __func__, + skbd_ord, gva_val(skbd_gva), + gpa_val(lcd_gva2gpa(skbd_gva))); + if (ret) + LIBLCD_ERR("Mapping failed for packet %p", + __pa(skb->data)); +#endif func_ret = dev_container->net_device.netdev_ops->ndo_start_xmit(skb, ( &dev_container->net_device )); -- GitLab