MCPcopy Index your code
hub / github.com/F-Stack/f-stack / ff_veth_setup_interface

Function ff_veth_setup_interface

lib/ff_veth.c:823–995  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

821#endif /* INET6 */
822
823static int
824ff_veth_setup_interface(struct ff_veth_softc *sc, struct ff_port_cfg *cfg)
825{
826 struct ifnet *ifp;
827 int ret;
828 uint32_t fib_num = RT_DEFAULT_FIB;
829
830 ifp = sc->ifp = if_alloc(IFT_ETHER);
831
832 ifp->if_init = ff_veth_init;
833 ifp->if_softc = sc;
834
835 if_initname(ifp, sc->host_ifname, IF_DUNIT_NONE);
836 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
837 ifp->if_ioctl = ff_veth_ioctl;
838 ifp->if_start = ff_veth_start;
839 ifp->if_transmit = ff_veth_transmit;
840 ifp->if_qflush = ff_veth_qflush;
841 ether_ifattach(ifp, sc->mac);
842
843 if (cfg->hw_features.rx_csum) {
844 ifp->if_capabilities |= IFCAP_RXCSUM;
845 }
846 if (cfg->hw_features.tx_csum_ip) {
847 ifp->if_capabilities |= IFCAP_TXCSUM;
848 ifp->if_hwassist |= CSUM_IP;
849 }
850 if (cfg->hw_features.tx_csum_l4) {
851 ifp->if_hwassist |= CSUM_DELAY_DATA;
852 }
853 if (cfg->hw_features.tx_tso) {
854 ifp->if_capabilities |= IFCAP_TSO;
855 ifp->if_hwassist |= CSUM_TSO;
856 }
857
858 ifp->if_capenable = ifp->if_capabilities;
859
860 sc->host_ctx = ff_dpdk_register_if((void *)sc, (void *)sc->ifp, cfg);
861 if (sc->host_ctx == NULL) {
862 printf("%s: Failed to register dpdk interface\n", sc->host_ifname);
863 return -1;
864 } else {
865 printf("%s: Successed to register dpdk interface\n", sc->host_ifname);
866 }
867
868 /* if vlan_flag is true, all port's addrs/vips will not to set, just create the iface */
869 if (cfg->nb_vlan == 0) {
870 // Set IP
871 ret = ff_veth_setaddr(sc, NULL);
872 if (ret != 0) {
873 printf("%s: ff_veth_setaddr failed\n", sc->host_ifname);
874 }
875
876 fib_num = cfg->port_id;
877 ret = ff_veth_set_gateway(sc, fib_num);
878 if (ret != 0) {
879 printf("%s: ff_veth_set_gateway failed\n", sc->host_ifname);
880 }

Callers 1

ff_veth_attachFunction · 0.85

Calls 15

if_allocFunction · 0.85
if_initnameFunction · 0.85
ether_ifattachFunction · 0.85
ff_dpdk_register_ifFunction · 0.85
ff_veth_setaddrFunction · 0.85
ff_veth_set_gatewayFunction · 0.85
ff_veth_setvaddrFunction · 0.85
ff_ipfw_add_simple_v4Function · 0.85
ff_veth_setaddr6Function · 0.85
ff_veth_set_gateway6Function · 0.85
ff_veth_setvaddr6Function · 0.85
ff_veth_initFunction · 0.85

Tested by

no test coverage detected