X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fark%2Fark_ethdev.c;h=646427d0c061cfd3d8adb2c91120ccbc0b5d3e96;hb=675911d0330b0802e845657c3f4edc5886cf8685;hp=86e500ecb30cb63fb7ddc13c897b0246ccff6815;hpb=e7f2fa88a71eb667788a124abbdc6d1ca1e0671e;p=dpdk.git diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c index 86e500ecb3..646427d0c0 100644 --- a/drivers/net/ark/ark_ethdev.c +++ b/drivers/net/ark/ark_ethdev.c @@ -31,15 +31,15 @@ static int eth_ark_dev_configure(struct rte_eth_dev *dev); static int eth_ark_dev_start(struct rte_eth_dev *dev); static void eth_ark_dev_stop(struct rte_eth_dev *dev); static void eth_ark_dev_close(struct rte_eth_dev *dev); -static void eth_ark_dev_info_get(struct rte_eth_dev *dev, - struct rte_eth_dev_info *dev_info); +static int eth_ark_dev_info_get(struct rte_eth_dev *dev, + struct rte_eth_dev_info *dev_info); static int eth_ark_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); static int eth_ark_dev_set_link_up(struct rte_eth_dev *dev); static int eth_ark_dev_set_link_down(struct rte_eth_dev *dev); static int eth_ark_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); -static void eth_ark_dev_stats_reset(struct rte_eth_dev *dev); +static int eth_ark_dev_stats_reset(struct rte_eth_dev *dev); static int eth_ark_set_default_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr); static int eth_ark_macaddr_add(struct rte_eth_dev *dev, @@ -164,26 +164,26 @@ check_for_ext(struct ark_adapter *ark) const char *dllpath = getenv("ARK_EXT_PATH"); if (dllpath == NULL) { - PMD_DEBUG_LOG(DEBUG, "ARK EXT NO dll path specified\n"); + ARK_PMD_LOG(DEBUG, "EXT NO dll path specified\n"); return 0; } - PMD_DRV_LOG(INFO, "ARK EXT found dll path at %s\n", dllpath); + ARK_PMD_LOG(NOTICE, "EXT found dll path at %s\n", dllpath); /* Open and load the .so */ ark->d_handle = dlopen(dllpath, RTLD_LOCAL | RTLD_LAZY); if (ark->d_handle == NULL) { - PMD_DRV_LOG(ERR, "Could not load user extension %s\n", + ARK_PMD_LOG(ERR, "Could not load user extension %s\n", dllpath); return -1; } - PMD_DRV_LOG(INFO, "SUCCESS: loaded user extension %s\n", + ARK_PMD_LOG(DEBUG, "SUCCESS: loaded user extension %s\n", dllpath); /* Get the entry points */ ark->user_ext.dev_init = (void *(*)(struct rte_eth_dev *, void *, int)) dlsym(ark->d_handle, "dev_init"); - PMD_DEBUG_LOG(DEBUG, "device ext init pointer = %p\n", + ARK_PMD_LOG(DEBUG, "device ext init pointer = %p\n", ark->user_ext.dev_init); ark->user_ext.dev_get_port_count = (int (*)(struct rte_eth_dev *, void *)) @@ -249,7 +249,7 @@ eth_ark_dev_init(struct rte_eth_dev *dev) ark->eth_dev = dev; - PMD_FUNC_LOG(DEBUG, "\n"); + ARK_PMD_LOG(DEBUG, "\n"); /* Check to see if there is an extension that we need to load */ ret = check_for_ext(ark); @@ -261,6 +261,8 @@ eth_ark_dev_init(struct rte_eth_dev *dev) /* Use dummy function until setup */ dev->rx_pkt_burst = ð_ark_recv_pkts_noop; dev->tx_pkt_burst = ð_ark_xmit_pkts_noop; + /* Let rte_eth_dev_close() release the port resources */ + dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; ark->bar0 = (uint8_t *)pci_dev->mem_resource[0].addr; ark->a_bar = (uint8_t *)pci_dev->mem_resource[2].addr; @@ -280,15 +282,15 @@ eth_ark_dev_init(struct rte_eth_dev *dev) (struct ark_rqpace_t *)(ark->bar0 + ARK_RCPACING_BASE); ark->started = 0; - PMD_DEBUG_LOG(INFO, "Sys Ctrl Const = 0x%x HW Commit_ID: %08x\n", + ARK_PMD_LOG(INFO, "Sys Ctrl Const = 0x%x HW Commit_ID: %08x\n", ark->sysctrl.t32[4], rte_be_to_cpu_32(ark->sysctrl.t32[0x20 / 4])); - PMD_DRV_LOG(INFO, "Arkville HW Commit_ID: %08x\n", + ARK_PMD_LOG(NOTICE, "Arkville HW Commit_ID: %08x\n", rte_be_to_cpu_32(ark->sysctrl.t32[0x20 / 4])); /* If HW sanity test fails, return an error */ if (ark->sysctrl.t32[4] != 0xcafef00d) { - PMD_DRV_LOG(ERR, + ARK_PMD_LOG(ERR, "HW Sanity test has failed, expected constant" " 0x%x, read 0x%x (%s)\n", 0xcafef00d, @@ -297,15 +299,15 @@ eth_ark_dev_init(struct rte_eth_dev *dev) } if (ark->sysctrl.t32[3] != 0) { if (ark_rqp_lasped(ark->rqpacing)) { - PMD_DRV_LOG(ERR, "Arkville Evaluation System - " + ARK_PMD_LOG(ERR, "Arkville Evaluation System - " "Timer has Expired\n"); return -1; } - PMD_DRV_LOG(WARNING, "Arkville Evaluation System - " + ARK_PMD_LOG(WARNING, "Arkville Evaluation System - " "Timer is Running\n"); } - PMD_DRV_LOG(INFO, + ARK_PMD_LOG(DEBUG, "HW Sanity test has PASSED, expected constant" " 0x%x, read 0x%x (%s)\n", 0xcafef00d, ark->sysctrl.t32[4], __func__); @@ -319,7 +321,7 @@ eth_ark_dev_init(struct rte_eth_dev *dev) dev->data->mac_addrs = rte_zmalloc("ark", RTE_ETHER_ADDR_LEN, 0); if (!dev->data->mac_addrs) { - PMD_DRV_LOG(ERR, + ARK_PMD_LOG(ERR, "Failed to allocated memory for storing mac address" ); } @@ -328,7 +330,7 @@ eth_ark_dev_init(struct rte_eth_dev *dev) ark->user_data[dev->data->port_id] = ark->user_ext.dev_init(dev, ark->a_bar, 0); if (!ark->user_data[dev->data->port_id]) { - PMD_DRV_LOG(INFO, + ARK_PMD_LOG(WARNING, "Failed to initialize PMD extension!" " continuing without it\n"); memset(&ark->user_ext, 0, sizeof(struct ark_user_ext)); @@ -339,7 +341,7 @@ eth_ark_dev_init(struct rte_eth_dev *dev) if (pci_dev->device.devargs) ret = eth_ark_check_args(ark, pci_dev->device.devargs->args); else - PMD_DRV_LOG(INFO, "No Device args found\n"); + ARK_PMD_LOG(INFO, "No Device args found\n"); if (ret) goto error; @@ -370,7 +372,7 @@ eth_ark_dev_init(struct rte_eth_dev *dev) /* reserve an ethdev entry */ eth_dev = rte_eth_dev_allocate(name); if (!eth_dev) { - PMD_DRV_LOG(ERR, + ARK_PMD_LOG(ERR, "Could not allocate eth_dev for port %d\n", p); goto error; @@ -387,7 +389,7 @@ eth_ark_dev_init(struct rte_eth_dev *dev) eth_dev->data->mac_addrs = rte_zmalloc(name, RTE_ETHER_ADDR_LEN, 0); if (!eth_dev->data->mac_addrs) { - PMD_DRV_LOG(ERR, + ARK_PMD_LOG(ERR, "Memory allocation for MAC failed!" " Exiting.\n"); goto error; @@ -446,7 +448,7 @@ ark_config_device(struct rte_eth_dev *dev) /* UDM */ if (ark_udm_reset(ark->udm.v)) { - PMD_DRV_LOG(ERR, "Unable to stop and reset UDM\n"); + ARK_PMD_LOG(ERR, "Unable to stop and reset UDM\n"); return -1; } /* Keep in reset until the MPU are cleared */ @@ -470,7 +472,7 @@ ark_config_device(struct rte_eth_dev *dev) /* TX -- DDM */ if (ark_ddm_stop(ark->ddm.v, 1)) - PMD_DRV_LOG(ERR, "Unable to stop DDM\n"); + ARK_PMD_LOG(ERR, "Unable to stop DDM\n"); mpu = ark->mputx.v; num_q = ark_api_num_queues(mpu); @@ -513,7 +515,6 @@ eth_ark_dev_uninit(struct rte_eth_dev *dev) static int eth_ark_dev_configure(struct rte_eth_dev *dev) { - PMD_FUNC_LOG(DEBUG, "\n"); struct ark_adapter *ark = dev->data->dev_private; eth_ark_dev_set_link_up(dev); @@ -543,8 +544,6 @@ eth_ark_dev_start(struct rte_eth_dev *dev) struct ark_adapter *ark = dev->data->dev_private; int i; - PMD_FUNC_LOG(DEBUG, "\n"); - /* RX Side */ /* start UDM */ ark_udm_start(ark->udm.v); @@ -574,7 +573,7 @@ eth_ark_dev_start(struct rte_eth_dev *dev) * This is only used for sanity checking with internal generator */ if (pthread_create(&thread, NULL, delay_pg_start, ark)) { - PMD_DRV_LOG(ERR, "Could not create pktgen " + ARK_PMD_LOG(ERR, "Could not create pktgen " "starter thread\n"); return -1; } @@ -595,8 +594,6 @@ eth_ark_dev_stop(struct rte_eth_dev *dev) struct ark_adapter *ark = dev->data->dev_private; struct ark_mpu_t *mpu; - PMD_FUNC_LOG(DEBUG, "\n"); - if (ark->started == 0) return; ark->started = 0; @@ -618,7 +615,7 @@ eth_ark_dev_stop(struct rte_eth_dev *dev) status = eth_ark_tx_queue_stop(dev, i); if (status != 0) { uint16_t port = dev->data->port_id; - PMD_DRV_LOG(ERR, + ARK_PMD_LOG(ERR, "tx_queue stop anomaly" " port %u, queue %u\n", port, i); @@ -633,7 +630,7 @@ eth_ark_dev_stop(struct rte_eth_dev *dev) break; } if (status || i != 0) { - PMD_DRV_LOG(ERR, "DDM stop anomaly. status:" + ARK_PMD_LOG(ERR, "DDM stop anomaly. status:" " %d iter: %u. (%s)\n", status, i, @@ -655,7 +652,7 @@ eth_ark_dev_stop(struct rte_eth_dev *dev) break; } if (status || i != 0) { - PMD_DRV_LOG(ERR, "UDM stop anomaly. status %d iter: %u. (%s)\n", + ARK_PMD_LOG(ERR, "UDM stop anomaly. status %d iter: %u. (%s)\n", status, i, __func__); ark_udm_dump(ark->udm.v, "Stop anomaly"); @@ -706,9 +703,12 @@ eth_ark_dev_close(struct rte_eth_dev *dev) eth_ark_dev_rx_queue_release(dev->data->rx_queues[i]); dev->data->rx_queues[i] = 0; } + + rte_free(dev->data->mac_addrs); + dev->data->mac_addrs = 0; } -static void +static int eth_ark_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { @@ -740,12 +740,14 @@ eth_ark_dev_info_get(struct rte_eth_dev *dev, ETH_LINK_SPEED_40G | ETH_LINK_SPEED_50G | ETH_LINK_SPEED_100G); + + return 0; } static int eth_ark_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) { - PMD_DEBUG_LOG(DEBUG, "link status = %d\n", + ARK_PMD_LOG(DEBUG, "link status = %d\n", dev->data->dev_link.link_status); struct ark_adapter *ark = dev->data->dev_private; @@ -804,7 +806,7 @@ eth_ark_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) return 0; } -static void +static int eth_ark_dev_stats_reset(struct rte_eth_dev *dev) { uint16_t i; @@ -817,6 +819,8 @@ eth_ark_dev_stats_reset(struct rte_eth_dev *dev) if (ark->user_ext.stats_reset) ark->user_ext.stats_reset(dev, ark->user_data[dev->data->port_id]); + + return 0; } static int @@ -878,20 +882,20 @@ static inline int process_pktdir_arg(const char *key, const char *value, void *extra_args) { - PMD_FUNC_LOG(DEBUG, "key = %s, value = %s\n", + ARK_PMD_LOG(DEBUG, "key = %s, value = %s\n", key, value); struct ark_adapter *ark = (struct ark_adapter *)extra_args; ark->pkt_dir_v = strtol(value, NULL, 16); - PMD_FUNC_LOG(DEBUG, "pkt_dir_v = 0x%x\n", ark->pkt_dir_v); + ARK_PMD_LOG(DEBUG, "pkt_dir_v = 0x%x\n", ark->pkt_dir_v); return 0; } static inline int process_file_args(const char *key, const char *value, void *extra_args) { - PMD_FUNC_LOG(DEBUG, "key = %s, value = %s\n", + ARK_PMD_LOG(DEBUG, "key = %s, value = %s\n", key, value); char *args = (char *)extra_args; @@ -902,7 +906,7 @@ process_file_args(const char *key, const char *value, void *extra_args) int first = 1; if (file == NULL) { - PMD_DRV_LOG(ERR, "Unable to open " + ARK_PMD_LOG(ERR, "Unable to open " "config file %s\n", value); return -1; } @@ -910,7 +914,7 @@ process_file_args(const char *key, const char *value, void *extra_args) while (fgets(line, sizeof(line), file)) { size += strlen(line); if (size >= ARK_MAX_ARG_LEN) { - PMD_DRV_LOG(ERR, "Unable to parse file %s args, " + ARK_PMD_LOG(ERR, "Unable to parse file %s args, " "parameter list is too long\n", value); fclose(file); return -1; @@ -922,7 +926,7 @@ process_file_args(const char *key, const char *value, void *extra_args) strncat(args, line, ARK_MAX_ARG_LEN); } } - PMD_FUNC_LOG(DEBUG, "file = %s\n", args); + ARK_PMD_LOG(DEBUG, "file = %s\n", args); fclose(file); return 0; } @@ -944,7 +948,7 @@ eth_ark_check_args(struct ark_adapter *ark, const char *params) for (k_idx = 0; k_idx < kvlist->count; k_idx++) { pair = &kvlist->pairs[k_idx]; - PMD_FUNC_LOG(DEBUG, "**** Arg passed to PMD = %s:%s\n", + ARK_PMD_LOG(DEBUG, "**** Arg passed to PMD = %s:%s\n", pair->key, pair->value); } @@ -953,7 +957,7 @@ eth_ark_check_args(struct ark_adapter *ark, const char *params) ARK_PKTDIR_ARG, &process_pktdir_arg, ark) != 0) { - PMD_DRV_LOG(ERR, "Unable to parse arg %s\n", ARK_PKTDIR_ARG); + ARK_PMD_LOG(ERR, "Unable to parse arg %s\n", ARK_PKTDIR_ARG); goto free_kvlist; } @@ -961,7 +965,7 @@ eth_ark_check_args(struct ark_adapter *ark, const char *params) ARK_PKTGEN_ARG, &process_file_args, ark->pkt_gen_args) != 0) { - PMD_DRV_LOG(ERR, "Unable to parse arg %s\n", ARK_PKTGEN_ARG); + ARK_PMD_LOG(ERR, "Unable to parse arg %s\n", ARK_PKTGEN_ARG); goto free_kvlist; } @@ -969,17 +973,17 @@ eth_ark_check_args(struct ark_adapter *ark, const char *params) ARK_PKTCHKR_ARG, &process_file_args, ark->pkt_chkr_args) != 0) { - PMD_DRV_LOG(ERR, "Unable to parse arg %s\n", ARK_PKTCHKR_ARG); + ARK_PMD_LOG(ERR, "Unable to parse arg %s\n", ARK_PKTCHKR_ARG); goto free_kvlist; } - PMD_DRV_LOG(INFO, "packet director set to 0x%x\n", ark->pkt_dir_v); + ARK_PMD_LOG(INFO, "packet director set to 0x%x\n", ark->pkt_dir_v); /* Setup the packet director */ ark_pktdir_setup(ark->pd, ark->pkt_dir_v); /* Setup the packet generator */ if (ark->pkt_gen_args[0]) { - PMD_DRV_LOG(INFO, "Setting up the packet generator\n"); + ARK_PMD_LOG(DEBUG, "Setting up the packet generator\n"); ark_pktgen_parse(ark->pkt_gen_args); ark_pktgen_reset(ark->pg); ark_pktgen_setup(ark->pg); @@ -1007,3 +1011,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_ark, ARK_PKTGEN_ARG "= " ARK_PKTCHKR_ARG "= " ARK_PKTDIR_ARG "="); +RTE_LOG_REGISTER(ark_logtype, pmd.net.ark, NOTICE);