Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/liquidio/lio_ioctl.c
| Show All 40 Lines | |||||
| #include "lio_network.h" | #include "lio_network.h" | ||||
| #include "lio_ctrl.h" | #include "lio_ctrl.h" | ||||
| #include "cn23xx_pf_device.h" | #include "cn23xx_pf_device.h" | ||||
| #include "lio_image.h" | #include "lio_image.h" | ||||
| #include "lio_ioctl.h" | #include "lio_ioctl.h" | ||||
| #include "lio_main.h" | #include "lio_main.h" | ||||
| #include "lio_rxtx.h" | #include "lio_rxtx.h" | ||||
| static int lio_set_rx_csum(struct ifnet *ifp, uint32_t data); | static int lio_set_rx_csum(if_t ifp, uint32_t data); | ||||
| static int lio_set_tso4(struct ifnet *ifp); | static int lio_set_tso4(if_t ifp); | ||||
| static int lio_set_tso6(struct ifnet *ifp); | static int lio_set_tso6(if_t ifp); | ||||
| static int lio_set_lro(struct ifnet *ifp); | static int lio_set_lro(if_t ifp); | ||||
| static int lio_change_mtu(struct ifnet *ifp, int new_mtu); | static int lio_change_mtu(if_t ifp, int new_mtu); | ||||
| static int lio_set_mcast_list(struct ifnet *ifp); | static int lio_set_mcast_list(if_t ifp); | ||||
| static inline enum lio_ifflags lio_get_new_flags(struct ifnet *ifp); | static inline enum lio_ifflags lio_get_new_flags(if_t ifp); | ||||
| static inline bool | static inline bool | ||||
| lio_is_valid_ether_addr(const uint8_t *addr) | lio_is_valid_ether_addr(const uint8_t *addr) | ||||
| { | { | ||||
| return (!(0x01 & addr[0]) && !((addr[0] + addr[1] + addr[2] + addr[3] + | return (!(0x01 & addr[0]) && !((addr[0] + addr[1] + addr[2] + addr[3] + | ||||
| addr[4] + addr[5]) == 0x00)); | addr[4] + addr[5]) == 0x00)); | ||||
| } | } | ||||
| static int | static int | ||||
| lio_change_dev_flags(struct ifnet *ifp) | lio_change_dev_flags(if_t ifp) | ||||
| { | { | ||||
| struct lio_ctrl_pkt nctrl; | struct lio_ctrl_pkt nctrl; | ||||
| struct lio *lio = if_getsoftc(ifp); | struct lio *lio = if_getsoftc(ifp); | ||||
| struct octeon_device *oct = lio->oct_dev; | struct octeon_device *oct = lio->oct_dev; | ||||
| int ret = 0; | int ret = 0; | ||||
| bzero(&nctrl, sizeof(struct lio_ctrl_pkt)); | bzero(&nctrl, sizeof(struct lio_ctrl_pkt)); | ||||
| Show All 14 Lines | |||||
| /* | /* | ||||
| * lio_ioctl : User calls this routine for configuring | * lio_ioctl : User calls this routine for configuring | ||||
| * the interface. | * the interface. | ||||
| * | * | ||||
| * return 0 on success, positive on failure | * return 0 on success, positive on failure | ||||
| */ | */ | ||||
| int | int | ||||
| lio_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) | lio_ioctl(if_t ifp, u_long cmd, caddr_t data) | ||||
| { | { | ||||
| struct lio *lio = if_getsoftc(ifp); | struct lio *lio = if_getsoftc(ifp); | ||||
| struct ifreq *ifrequest = (struct ifreq *)data; | struct ifreq *ifrequest = (struct ifreq *)data; | ||||
| int error = 0; | int error = 0; | ||||
| switch (cmd) { | switch (cmd) { | ||||
| case SIOCSIFADDR: | case SIOCSIFADDR: | ||||
| lio_dev_dbg(lio->oct_dev, "ioctl: SIOCSIFADDR\n"); | lio_dev_dbg(lio->oct_dev, "ioctl: SIOCSIFADDR\n"); | ||||
| ▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | default: | ||||
| error = ether_ioctl(ifp, cmd, data); | error = ether_ioctl(ifp, cmd, data); | ||||
| break; | break; | ||||
| } | } | ||||
| return (error); | return (error); | ||||
| } | } | ||||
| static int | static int | ||||
| lio_set_tso4(struct ifnet *ifp) | lio_set_tso4(if_t ifp) | ||||
| { | { | ||||
| struct lio *lio = if_getsoftc(ifp); | struct lio *lio = if_getsoftc(ifp); | ||||
| if (if_getcapabilities(ifp) & IFCAP_TSO4) { | if (if_getcapabilities(ifp) & IFCAP_TSO4) { | ||||
| if_togglecapenable(ifp, IFCAP_TSO4); | if_togglecapenable(ifp, IFCAP_TSO4); | ||||
| if (if_getcapenable(ifp) & IFCAP_TSO4) | if (if_getcapenable(ifp) & IFCAP_TSO4) | ||||
| if_sethwassistbits(ifp, CSUM_IP_TSO, 0); | if_sethwassistbits(ifp, CSUM_IP_TSO, 0); | ||||
| else | else | ||||
| if_sethwassistbits(ifp, 0, CSUM_IP_TSO); | if_sethwassistbits(ifp, 0, CSUM_IP_TSO); | ||||
| } else { | } else { | ||||
| lio_dev_info(lio->oct_dev, "TSO4 capability not supported\n"); | lio_dev_info(lio->oct_dev, "TSO4 capability not supported\n"); | ||||
| return (EINVAL); | return (EINVAL); | ||||
| } | } | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| static int | static int | ||||
| lio_set_tso6(struct ifnet *ifp) | lio_set_tso6(if_t ifp) | ||||
| { | { | ||||
| struct lio *lio = if_getsoftc(ifp); | struct lio *lio = if_getsoftc(ifp); | ||||
| if (if_getcapabilities(ifp) & IFCAP_TSO6) { | if (if_getcapabilities(ifp) & IFCAP_TSO6) { | ||||
| if_togglecapenable(ifp, IFCAP_TSO6); | if_togglecapenable(ifp, IFCAP_TSO6); | ||||
| if (if_getcapenable(ifp) & IFCAP_TSO6) | if (if_getcapenable(ifp) & IFCAP_TSO6) | ||||
| if_sethwassistbits(ifp, CSUM_IP6_TSO, 0); | if_sethwassistbits(ifp, CSUM_IP6_TSO, 0); | ||||
| else | else | ||||
| if_sethwassistbits(ifp, 0, CSUM_IP6_TSO); | if_sethwassistbits(ifp, 0, CSUM_IP6_TSO); | ||||
| } else { | } else { | ||||
| lio_dev_info(lio->oct_dev, "TSO6 capability not supported\n"); | lio_dev_info(lio->oct_dev, "TSO6 capability not supported\n"); | ||||
| return (EINVAL); | return (EINVAL); | ||||
| } | } | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| static int | static int | ||||
| lio_set_rx_csum(struct ifnet *ifp, uint32_t data) | lio_set_rx_csum(if_t ifp, uint32_t data) | ||||
| { | { | ||||
| struct lio *lio = if_getsoftc(ifp); | struct lio *lio = if_getsoftc(ifp); | ||||
| int ret = 0; | int ret = 0; | ||||
| if (if_getcapabilities(ifp) & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) { | if (if_getcapabilities(ifp) & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) { | ||||
| if_togglecapenable(ifp, (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)); | if_togglecapenable(ifp, (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)); | ||||
| if (data) { | if (data) { | ||||
| Show All 10 Lines | if (if_getcapabilities(ifp) & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) { | ||||
| lio_dev_info(lio->oct_dev, "Rx checksum offload capability not supported\n"); | lio_dev_info(lio->oct_dev, "Rx checksum offload capability not supported\n"); | ||||
| return (ENODEV); | return (ENODEV); | ||||
| } | } | ||||
| return ((ret) ? EINVAL : 0); | return ((ret) ? EINVAL : 0); | ||||
| } | } | ||||
| static int | static int | ||||
| lio_set_lro(struct ifnet *ifp) | lio_set_lro(if_t ifp) | ||||
| { | { | ||||
| struct lio *lio = if_getsoftc(ifp); | struct lio *lio = if_getsoftc(ifp); | ||||
| int ret = 0; | int ret = 0; | ||||
| if (!(if_getcapabilities(ifp) & IFCAP_LRO)) { | if (!(if_getcapabilities(ifp) & IFCAP_LRO)) { | ||||
| lio_dev_info(lio->oct_dev, "LRO capability not supported\n"); | lio_dev_info(lio->oct_dev, "LRO capability not supported\n"); | ||||
| return (ENODEV); | return (ENODEV); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | lio_mtu_ctl_callback(struct octeon_device *oct, uint32_t status, void *buf) | ||||
| * This barrier is required to be sure that the response has been | * This barrier is required to be sure that the response has been | ||||
| * written fully. | * written fully. | ||||
| */ | */ | ||||
| wmb(); | wmb(); | ||||
| } | } | ||||
| /* @param ifp is network device */ | /* @param ifp is network device */ | ||||
| static int | static int | ||||
| lio_change_mtu(struct ifnet *ifp, int new_mtu) | lio_change_mtu(if_t ifp, int new_mtu) | ||||
| { | { | ||||
| struct lio *lio = if_getsoftc(ifp); | struct lio *lio = if_getsoftc(ifp); | ||||
| struct octeon_device *oct = lio->oct_dev; | struct octeon_device *oct = lio->oct_dev; | ||||
| struct lio_soft_command *sc; | struct lio_soft_command *sc; | ||||
| union octeon_cmd *ncmd; | union octeon_cmd *ncmd; | ||||
| volatile int *mtu_sc_ctx; | volatile int *mtu_sc_ctx; | ||||
| int retval = 0; | int retval = 0; | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
| mtu_updation_failed: | mtu_updation_failed: | ||||
| lio_free_soft_command(oct, sc); | lio_free_soft_command(oct, sc); | ||||
| return (retval); | return (retval); | ||||
| } | } | ||||
| /* @param ifp network device */ | /* @param ifp network device */ | ||||
| int | int | ||||
| lio_set_mac(struct ifnet *ifp, uint8_t *p) | lio_set_mac(if_t ifp, uint8_t *p) | ||||
| { | { | ||||
| struct lio_ctrl_pkt nctrl; | struct lio_ctrl_pkt nctrl; | ||||
| struct lio *lio = if_getsoftc(ifp); | struct lio *lio = if_getsoftc(ifp); | ||||
| struct octeon_device *oct = lio->oct_dev; | struct octeon_device *oct = lio->oct_dev; | ||||
| int ret = 0; | int ret = 0; | ||||
| if (!lio_is_valid_ether_addr(p)) | if (!lio_is_valid_ether_addr(p)) | ||||
| return (EADDRNOTAVAIL); | return (EADDRNOTAVAIL); | ||||
| Show All 27 Lines | |||||
| /* | /* | ||||
| * \brief Converts a mask based on ifp flags | * \brief Converts a mask based on ifp flags | ||||
| * @param ifp network device | * @param ifp network device | ||||
| * | * | ||||
| * This routine generates a lio_ifflags mask from the ifp flags | * This routine generates a lio_ifflags mask from the ifp flags | ||||
| * received from the OS. | * received from the OS. | ||||
| */ | */ | ||||
| static inline enum lio_ifflags | static inline enum lio_ifflags | ||||
| lio_get_new_flags(struct ifnet *ifp) | lio_get_new_flags(if_t ifp) | ||||
| { | { | ||||
| enum lio_ifflags f = LIO_IFFLAG_UNICAST; | enum lio_ifflags f = LIO_IFFLAG_UNICAST; | ||||
| if (if_getflags(ifp) & IFF_PROMISC) | if (if_getflags(ifp) & IFF_PROMISC) | ||||
| f |= LIO_IFFLAG_PROMISC; | f |= LIO_IFFLAG_PROMISC; | ||||
| if (if_getflags(ifp) & IFF_ALLMULTI) | if (if_getflags(ifp) & IFF_ALLMULTI) | ||||
| f |= LIO_IFFLAG_ALLMULTI; | f |= LIO_IFFLAG_ALLMULTI; | ||||
| Show All 27 Lines | lio_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) | ||||
| memcpy(((uint8_t *)mc) + 2, LLADDR(sdl), ETHER_ADDR_LEN); | memcpy(((uint8_t *)mc) + 2, LLADDR(sdl), ETHER_ADDR_LEN); | ||||
| /* no need to swap bytes */ | /* no need to swap bytes */ | ||||
| return (1); | return (1); | ||||
| } | } | ||||
| /* @param ifp network device */ | /* @param ifp network device */ | ||||
| static int | static int | ||||
| lio_set_mcast_list(struct ifnet *ifp) | lio_set_mcast_list(if_t ifp) | ||||
| { | { | ||||
| struct lio *lio = if_getsoftc(ifp); | struct lio *lio = if_getsoftc(ifp); | ||||
| struct octeon_device *oct = lio->oct_dev; | struct octeon_device *oct = lio->oct_dev; | ||||
| struct lio_ctrl_pkt nctrl; | struct lio_ctrl_pkt nctrl; | ||||
| int mc_count; | int mc_count; | ||||
| int ret; | int ret; | ||||
| bzero(&nctrl, sizeof(struct lio_ctrl_pkt)); | bzero(&nctrl, sizeof(struct lio_ctrl_pkt)); | ||||
| Show All 28 Lines | |||||