Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/liquidio/lio_main.c
| Show First 20 Lines • Show All 1,224 Lines • ▼ Show 20 Lines | lio_setup_nic_devices(struct octeon_device *octeon_dev) | ||||
| struct lio_if_cfg_context *ctx; | struct lio_if_cfg_context *ctx; | ||||
| struct lio_if_cfg_resp *resp; | struct lio_if_cfg_resp *resp; | ||||
| struct lio_if_props *props; | struct lio_if_props *props; | ||||
| int num_iqueues, num_oqueues, retval; | int num_iqueues, num_oqueues, retval; | ||||
| unsigned int base_queue; | unsigned int base_queue; | ||||
| unsigned int gmx_port_id; | unsigned int gmx_port_id; | ||||
| uint32_t ctx_size, data_size; | uint32_t ctx_size, data_size; | ||||
| uint32_t ifidx_or_pfnum, resp_size; | uint32_t ifidx_or_pfnum, resp_size; | ||||
| uint8_t mac[ETHER_HDR_LEN], i, j; | uint8_t mac[ETHER_ADDR_LEN], i, j; | ||||
| /* This is to handle link status changes */ | /* This is to handle link status changes */ | ||||
| lio_register_dispatch_fn(octeon_dev, LIO_OPCODE_NIC, | lio_register_dispatch_fn(octeon_dev, LIO_OPCODE_NIC, | ||||
| LIO_OPCODE_NIC_INFO, | LIO_OPCODE_NIC_INFO, | ||||
| lio_link_info, octeon_dev); | lio_link_info, octeon_dev); | ||||
| for (i = 0; i < octeon_dev->ifcount; i++) { | for (i = 0; i < octeon_dev->ifcount; i++) { | ||||
| resp_size = sizeof(struct lio_if_cfg_resp); | resp_size = sizeof(struct lio_if_cfg_resp); | ||||
| ▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | for (i = 0; i < octeon_dev->ifcount; i++) { | ||||
| */ | */ | ||||
| lio->oct_dev = octeon_dev; | lio->oct_dev = octeon_dev; | ||||
| lio->ifp = ifp; | lio->ifp = ifp; | ||||
| lio_dev_dbg(octeon_dev, "if%d gmx: %d hw_addr: 0x%llx\n", i, | lio_dev_dbg(octeon_dev, "if%d gmx: %d hw_addr: 0x%llx\n", i, | ||||
| lio->linfo.gmxport, LIO_CAST64(lio->linfo.hw_addr)); | lio->linfo.gmxport, LIO_CAST64(lio->linfo.hw_addr)); | ||||
| lio_init_ifnet(lio); | lio_init_ifnet(lio); | ||||
| /* 64-bit swap required on LE machines */ | /* 64-bit swap required on LE machines */ | ||||
| lio_swap_8B_data(&lio->linfo.hw_addr, 1); | lio_swap_8B_data(&lio->linfo.hw_addr, 1); | ||||
| for (j = 0; j < 6; j++) | memcpy(mac, (uint8_t *)&lio->linfo.hw_addr + 2, ETHER_ADDR_LEN); | ||||
markj: Change 6 to ETHER_ADDR_LEN too? | |||||
Done Inline ActionsActually this loop copying can be shortened by memcpy(). I'll update for better readability. zlei: Actually this loop copying can be shortened by `memcpy()`. I'll update for better readability. | |||||
| mac[j] = *((uint8_t *)( | |||||
| ((uint8_t *)&lio->linfo.hw_addr) + 2 + j)); | |||||
| ether_ifattach(ifp, mac); | ether_ifattach(ifp, mac); | ||||
| /* | /* | ||||
| * By default all interfaces on a single Octeon uses the same | * By default all interfaces on a single Octeon uses the same | ||||
| * tx and rx queues | * tx and rx queues | ||||
| */ | */ | ||||
| lio->txq = lio->linfo.txpciq[0].s.q_no; | lio->txq = lio->linfo.txpciq[0].s.q_no; | ||||
| ▲ Show 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| void | void | ||||
| lio_open(void *arg) | lio_open(void *arg) | ||||
| { | { | ||||
| struct lio *lio = arg; | struct lio *lio = arg; | ||||
| if_t ifp = lio->ifp; | if_t ifp = lio->ifp; | ||||
| struct octeon_device *oct = lio->oct_dev; | struct octeon_device *oct = lio->oct_dev; | ||||
| uint8_t *mac_new, mac_old[ETHER_HDR_LEN]; | uint8_t *mac_new, mac_old[ETHER_ADDR_LEN]; | ||||
| int ret = 0; | int ret = 0; | ||||
| lio_ifstate_set(lio, LIO_IFSTATE_RUNNING); | lio_ifstate_set(lio, LIO_IFSTATE_RUNNING); | ||||
| /* Ready for link status updates */ | /* Ready for link status updates */ | ||||
| lio->intf_open = 1; | lio->intf_open = 1; | ||||
| lio_dev_info(oct, "Interface Open, ready for traffic\n"); | lio_dev_info(oct, "Interface Open, ready for traffic\n"); | ||||
| /* tell Octeon to start forwarding packets to host */ | /* tell Octeon to start forwarding packets to host */ | ||||
| lio_send_rx_ctrl_cmd(lio, 1); | lio_send_rx_ctrl_cmd(lio, 1); | ||||
| mac_new = if_getlladdr(ifp); | mac_new = if_getlladdr(ifp); | ||||
| memcpy(mac_old, ((uint8_t *)&lio->linfo.hw_addr) + 2, ETHER_HDR_LEN); | memcpy(mac_old, ((uint8_t *)&lio->linfo.hw_addr) + 2, ETHER_ADDR_LEN); | ||||
| if (lio_is_mac_changed(mac_new, mac_old)) { | if (lio_is_mac_changed(mac_new, mac_old)) { | ||||
| ret = lio_set_mac(ifp, mac_new); | ret = lio_set_mac(ifp, mac_new); | ||||
| if (ret) | if (ret) | ||||
| lio_dev_err(oct, "MAC change failed, error: %d\n", ret); | lio_dev_err(oct, "MAC change failed, error: %d\n", ret); | ||||
| } | } | ||||
| /* Now inform the stack we're ready */ | /* Now inform the stack we're ready */ | ||||
| ▲ Show 20 Lines • Show All 687 Lines • Show Last 20 Lines | |||||
Change 6 to ETHER_ADDR_LEN too?