| 995 | } |
| 996 | |
| 997 | void * |
| 998 | ff_veth_attach(struct ff_port_cfg *cfg) |
| 999 | { |
| 1000 | struct ff_veth_softc *sc = NULL; |
| 1001 | int error; |
| 1002 | |
| 1003 | sc = malloc(sizeof(struct ff_veth_softc), M_DEVBUF, M_WAITOK); |
| 1004 | if (NULL == sc) { |
| 1005 | printf("ff_veth_softc allocation failed\n"); |
| 1006 | goto fail; |
| 1007 | } |
| 1008 | memset(sc, 0, sizeof(struct ff_veth_softc)); |
| 1009 | |
| 1010 | if(cfg->ifname){ |
| 1011 | snprintf(sc->host_ifname, sizeof(sc->host_ifname), "%s", cfg->ifname); |
| 1012 | } else { |
| 1013 | snprintf(sc->host_ifname, sizeof(sc->host_ifname), ff_IF_NAME, cfg->port_id); |
| 1014 | } |
| 1015 | |
| 1016 | error = ff_veth_config(sc, cfg); |
| 1017 | if (0 != error) { |
| 1018 | goto fail; |
| 1019 | } |
| 1020 | |
| 1021 | if (0 != ff_veth_setup_interface(sc, cfg)) { |
| 1022 | goto fail; |
| 1023 | } |
| 1024 | |
| 1025 | return sc->host_ctx; |
| 1026 | |
| 1027 | fail: |
| 1028 | if (sc) { |
| 1029 | if (sc->host_ctx) |
| 1030 | ff_dpdk_deregister_if(sc->host_ctx); |
| 1031 | |
| 1032 | free(sc, M_DEVBUF); |
| 1033 | } |
| 1034 | |
| 1035 | return NULL; |
| 1036 | } |
| 1037 | |
| 1038 | int |
| 1039 | ff_veth_detach(void *arg) |
no test coverage detected