]> xenbits.xensource.com Git - unikraft/libs/lwip.git/commitdiff
lib/lwip: Fetch features supported on the netdev
authorSharan Santhanam <sharan.santhanam@neclab.eu>
Tue, 21 Jul 2020 15:32:45 +0000 (17:32 +0200)
committerSimon Kuenzer <simon.kuenzer@neclab.eu>
Wed, 5 Aug 2020 19:47:03 +0000 (21:47 +0200)
Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
Reviewed-by: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
uknetdev.c

index 704735248be8d05edd40950fe2f160326842266d..7f731826aa40c42a48ef1c74ff2b97f010ee7cbd 100644 (file)
 #define UKNETDEV_NETIF_NAME0 'e'
 #define UKNETDEV_NETIF_NAME1 'n'
 
+struct lwip_netdev_data {
+       uint32_t features;
+};
+
 /*
  * Global headroom settings for buffer allocations used on receive
  * and transmit. We are taking the maximum of all uknetdev devices as
@@ -364,6 +368,21 @@ static void uknetdev_updown(struct netif *nf)
 }
 #endif /* CONFIG_LWIP_NOTHREADS */
 
+#if CONFIG_UK_NETDEV_SCRATCH_SIZE < CONFIG_LWIP_UKNETDEV_SCRATCH
+/**
+ * CONFIG_UK_NETDEV_SCRATCH_SIZE is configured as the max of all scratch pad
+ * requirements by the Makefile.uk macro uknetdev_scratch_mem. This value
+ * should atleast be greater CONFIG_LWIP_UKNETDEV_SCRATCH
+ */
+#error "Insufficient Scratch memory"
+#endif
+
+/**
+ * Make sure the CONFIG_LWIP_UKNETDEV_SCRATCH is still sufficient to
+ * store lwip_data.
+ */
+UK_CTASSERT(sizeof(struct lwip_netdev_data) <= CONFIG_LWIP_UKNETDEV_SCRATCH);
+
 err_t uknetdev_init(struct netif *nf)
 {
        struct uk_alloc *a = NULL;
@@ -372,6 +391,7 @@ err_t uknetdev_init(struct netif *nf)
        struct uk_netdev_rxqueue_conf rxq_conf;
        struct uk_netdev_txqueue_conf txq_conf;
        struct uk_netdev_info info;
+       struct lwip_netdev_data *lwip_data;
        const struct uk_hwaddr *hwaddr;
        unsigned int i;
        int ret;
@@ -380,6 +400,8 @@ err_t uknetdev_init(struct netif *nf)
        dev = netif_to_uknetdev(nf);
        UK_ASSERT(dev);
 
+       lwip_data = (struct lwip_netdev_data *)dev->scratch_pad;
+
        LWIP_ASSERT("uknetdev needs an input callback (netif_input or tcpip_input)",
                    nf->input != NULL);
 
@@ -411,6 +433,7 @@ err_t uknetdev_init(struct netif *nf)
        uk_netdev_info_get(dev, &info);
        if (!info.max_rx_queues || !info.max_tx_queues)
                return ERR_IF;
+       lwip_data->features = info.features;
 
        /*
         * Update our global (rx|tx)_headroom setting that we use for