[dpdk-dev,v2,2/5] i40e: renaming and code style fix
diff mbox

Message ID 1410706109-30448-3-git-send-email-helin.zhang@intel.com
State Superseded, archived
Headers show

Commit Message

Helin Zhang Sept. 14, 2014, 2:48 p.m. UTC
Rename some local variables in i40e_pf.c and
i40e_ethdev_vf.c, to express more accurately and briefly.
Fix several issues in i40e_pf.c reported by checkpatch.pl.
Line warpping for some source lines which has more than 80
characters, and merge lines together for those source lines
which does not need any line wrapping actually.

v2 changes:
* Put all the renaming and code style fixes into a patch.
* Add several more code style fixes for i40e_pf.c.

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
Reviewed-by: Jingjing Wu <jingjing.wu@intel.com>
Reviewed-by: Jing Chen <jing.d.chen@intel.com>
---
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 75 ++++++++++++++++++------------------
 lib/librte_pmd_i40e/i40e_pf.c        | 53 +++++++++++--------------
 2 files changed, 61 insertions(+), 67 deletions(-)

Patch
diff mbox

diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index d8552ad..113bff8 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -527,27 +527,27 @@  static int
 i40evf_configure_queues(struct rte_eth_dev *dev)
 {
 	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
-	struct i40e_virtchnl_vsi_queue_config_info *queue_info;
-	struct i40e_virtchnl_queue_pair_info *queue_cfg;
 	struct i40e_rx_queue **rxq =
 		(struct i40e_rx_queue **)dev->data->rx_queues;
 	struct i40e_tx_queue **txq =
 		(struct i40e_tx_queue **)dev->data->tx_queues;
-	int i, len, nb_qpairs, num_rxq, num_txq;
-	int err;
+	struct i40e_virtchnl_vsi_queue_config_info *vc_vqci;
+	struct i40e_virtchnl_queue_pair_info *vc_qpi;
+	int size, i, nb_qp, ret, num_rxq, num_txq;
 	struct vf_cmd_info args;
 	struct rte_pktmbuf_pool_private *mbp_priv;
 
-	nb_qpairs = vf->num_queue_pairs;
-	len = sizeof(*queue_info) + sizeof(*queue_cfg) * nb_qpairs;
-	queue_info = rte_zmalloc("queue_info", len, 0);
-	if (queue_info == NULL) {
-		PMD_INIT_LOG(ERR, "failed alloc memory for queue_info\n");
-		return -1;
+	nb_qp = vf->num_queue_pairs;
+	size = sizeof(*vc_vqci) + sizeof(*vc_qpi) * nb_qp;
+	vc_vqci = rte_zmalloc("vc_vqci", size, 0);
+	if (!vc_vqci) {
+		PMD_DRV_LOG(ERR, "Failed to allocate memory for VF "
+					"configuring queues\n");
+		return -ENOMEM;
 	}
-	queue_info->vsi_id = vf->vsi_res->vsi_id;
-	queue_info->num_queue_pairs = nb_qpairs;
-	queue_cfg = queue_info->qpair;
+	vc_vqci->vsi_id = vf->vsi_res->vsi_id;
+	vc_vqci->num_queue_pairs = nb_qp;
+	vc_qpi = vc_vqci->qpair;
 
 	num_rxq = dev->data->nb_rx_queues;
 	num_txq = dev->data->nb_tx_queues;
@@ -557,48 +557,49 @@  i40evf_configure_queues(struct rte_eth_dev *dev)
 	 * work that way. The solution is fills 0 with HW ring option in case
 	 * they are not equal.
 	 */
-	for (i = 0; i < nb_qpairs; i++) {
+	for (i = 0; i < nb_qp; i++) {
 		/*Fill TX info */
-		queue_cfg->txq.vsi_id = queue_info->vsi_id;
-		queue_cfg->txq.queue_id = i;
+		vc_qpi->txq.vsi_id = vc_vqci->vsi_id;
+		vc_qpi->txq.queue_id = i;
 		if (i < num_txq) {
-			queue_cfg->txq.ring_len = txq[i]->nb_tx_desc;
-			queue_cfg->txq.dma_ring_addr = txq[i]->tx_ring_phys_addr;
+			vc_qpi->txq.ring_len = txq[i]->nb_tx_desc;
+			vc_qpi->txq.dma_ring_addr = txq[i]->tx_ring_phys_addr;
 		} else {
-			queue_cfg->txq.ring_len = 0;
-			queue_cfg->txq.dma_ring_addr = 0;
+			vc_qpi->txq.ring_len = 0;
+			vc_qpi->txq.dma_ring_addr = 0;
 		}
 
 		/* Fill RX info */
-		queue_cfg->rxq.vsi_id = queue_info->vsi_id;
-		queue_cfg->rxq.queue_id = i;
-		queue_cfg->rxq.max_pkt_size = vf->max_pkt_len;
+		vc_qpi->rxq.vsi_id = vc_vqci->vsi_id;
+		vc_qpi->rxq.queue_id = i;
+		vc_qpi->rxq.max_pkt_size = vf->max_pkt_len;
 		if (i < num_rxq) {
 			mbp_priv = rte_mempool_get_priv(rxq[i]->mp);
-			queue_cfg->rxq.databuffer_size = mbp_priv->mbuf_data_room_size -
-						   RTE_PKTMBUF_HEADROOM;;
-			queue_cfg->rxq.ring_len = rxq[i]->nb_rx_desc;
-			queue_cfg->rxq.dma_ring_addr = rxq[i]->rx_ring_phys_addr;;
+			vc_qpi->rxq.databuffer_size =
+				mbp_priv->mbuf_data_room_size -
+					RTE_PKTMBUF_HEADROOM;
+			vc_qpi->rxq.ring_len = rxq[i]->nb_rx_desc;
+			vc_qpi->rxq.dma_ring_addr = rxq[i]->rx_ring_phys_addr;
 		} else {
-			queue_cfg->rxq.ring_len = 0;
-			queue_cfg->rxq.dma_ring_addr = 0;
-			queue_cfg->rxq.databuffer_size = 0;
+			vc_qpi->rxq.ring_len = 0;
+			vc_qpi->rxq.dma_ring_addr = 0;
+			vc_qpi->rxq.databuffer_size = 0;
 		}
-		queue_cfg++;
+		vc_qpi++;
 	}
 
 	args.ops = I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES;
-	args.in_args = (u8 *)queue_info;
-	args.in_args_size = len;
+	args.in_args = (uint8_t *)vc_vqci;
+	args.in_args_size = size;
 	args.out_buffer = cmd_result_buffer;
 	args.out_size = I40E_AQ_BUF_SZ;
-	err = i40evf_execute_vf_cmd(dev, &args);
-	if (err)
+	ret = i40evf_execute_vf_cmd(dev, &args);
+	if (ret)
 		PMD_DRV_LOG(ERR, "fail to execute command "
 				"OP_CONFIG_VSI_QUEUES\n");
-	rte_free(queue_info);
+	rte_free(vc_vqci);
 
-	return err;
+	return ret;
 }
 
 static int
diff --git a/lib/librte_pmd_i40e/i40e_pf.c b/lib/librte_pmd_i40e/i40e_pf.c
index e8b154d..1583021 100644
--- a/lib/librte_pmd_i40e/i40e_pf.c
+++ b/lib/librte_pmd_i40e/i40e_pf.c
@@ -415,29 +415,28 @@  i40e_pf_host_process_cmd_config_vsi_queues(struct i40e_pf_vf *vf,
 {
 	struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf);
 	struct i40e_vsi *vsi = vf->vsi;
-	int ret = I40E_SUCCESS;
-	struct i40e_virtchnl_vsi_queue_config_info *qconfig =
-	    (struct i40e_virtchnl_vsi_queue_config_info *)msg;
-	int i;
-	struct i40e_virtchnl_queue_pair_info *qpair;
+	struct i40e_virtchnl_vsi_queue_config_info *vc_vqci =
+		(struct i40e_virtchnl_vsi_queue_config_info *)msg;
+	struct i40e_virtchnl_queue_pair_info *vc_qpi;
+	int i, ret = I40E_SUCCESS;
 
-	if (msg == NULL || msglen <= sizeof(*qconfig) ||
-		qconfig->num_queue_pairs > vsi->nb_qps) {
+	if (msg == NULL || msglen <= sizeof(*vc_vqci) ||
+		vc_vqci->num_queue_pairs > vsi->nb_qps) {
 		PMD_DRV_LOG(ERR, "vsi_queue_config_info argument wrong\n");
 		ret = I40E_ERR_PARAM;
 		goto send_msg;
 	}
 
-	qpair = qconfig->qpair;
-	for (i = 0; i < qconfig->num_queue_pairs; i++) {
-		if (qpair[i].rxq.queue_id > vsi->nb_qps - 1 ||
-			qpair[i].txq.queue_id > vsi->nb_qps - 1) {
+	vc_qpi = vc_vqci->qpair;
+	for (i = 0; i < vc_vqci->num_queue_pairs; i++) {
+		if (vc_qpi[i].rxq.queue_id > vsi->nb_qps - 1 ||
+			vc_qpi[i].txq.queue_id > vsi->nb_qps - 1) {
 			ret = I40E_ERR_PARAM;
 			goto send_msg;
 		}
 
 		/* Apply VF RX queue setting to HMC */
-		if (i40e_pf_host_hmc_config_rxq(hw, vf, &qpair[i].rxq)
+		if (i40e_pf_host_hmc_config_rxq(hw, vf, &vc_qpi[i].rxq)
 			!= I40E_SUCCESS) {
 			PMD_DRV_LOG(ERR, "Configure RX queue HMC failed");
 			ret = I40E_ERR_PARAM;
@@ -445,8 +444,8 @@  i40e_pf_host_process_cmd_config_vsi_queues(struct i40e_pf_vf *vf,
 		}
 
 		/* Apply VF TX queue setting to HMC */
-		if (i40e_pf_host_hmc_config_txq(hw, vf, &qpair[i].txq)
-			!= I40E_SUCCESS) {
+		if (i40e_pf_host_hmc_config_txq(hw, vf,
+			&vc_qpi[i].txq) != I40E_SUCCESS) {
 			PMD_DRV_LOG(ERR, "Configure TX queue HMC failed");
 			ret = I40E_ERR_PARAM;
 			goto send_msg;
@@ -857,11 +856,11 @@  i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 	}
 
 	switch (opcode) {
-	case I40E_VIRTCHNL_OP_VERSION :
+	case I40E_VIRTCHNL_OP_VERSION:
 		PMD_DRV_LOG(INFO, "OP_VERSION received\n");
 		i40e_pf_host_process_cmd_version(vf);
 		break;
-	case I40E_VIRTCHNL_OP_RESET_VF :
+	case I40E_VIRTCHNL_OP_RESET_VF:
 		PMD_DRV_LOG(INFO, "OP_RESET_VF received\n");
 		i40e_pf_host_process_cmd_reset_vf(vf);
 		break;
@@ -871,8 +870,7 @@  i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 		break;
 	case I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES:
 		PMD_DRV_LOG(INFO, "OP_CONFIG_VSI_QUEUES received\n");
-		i40e_pf_host_process_cmd_config_vsi_queues(vf,
-						msg, msglen);
+		i40e_pf_host_process_cmd_config_vsi_queues(vf, msg, msglen);
 		break;
 	case I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP:
 		PMD_DRV_LOG(INFO, "OP_CONFIG_IRQ_MAP received\n");
@@ -880,23 +878,19 @@  i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 		break;
 	case I40E_VIRTCHNL_OP_ENABLE_QUEUES:
 		PMD_DRV_LOG(INFO, "OP_ENABLE_QUEUES received\n");
-		i40e_pf_host_process_cmd_enable_queues(vf,
-						msg, msglen);
+		i40e_pf_host_process_cmd_enable_queues(vf, msg, msglen);
 		break;
 	case I40E_VIRTCHNL_OP_DISABLE_QUEUES:
 		PMD_DRV_LOG(INFO, "OP_DISABLE_QUEUE received\n");
-		i40e_pf_host_process_cmd_disable_queues(vf,
-						msg, msglen);
+		i40e_pf_host_process_cmd_disable_queues(vf, msg, msglen);
 		break;
 	case I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS:
 		PMD_DRV_LOG(INFO, "OP_ADD_ETHER_ADDRESS received\n");
-		i40e_pf_host_process_cmd_add_ether_address(vf,
-						msg, msglen);
+		i40e_pf_host_process_cmd_add_ether_address(vf, msg, msglen);
 		break;
 	case I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS:
 		PMD_DRV_LOG(INFO, "OP_DEL_ETHER_ADDRESS received\n");
-		i40e_pf_host_process_cmd_del_ether_address(vf,
-						msg, msglen);
+		i40e_pf_host_process_cmd_del_ether_address(vf, msg, msglen);
 		break;
 	case I40E_VIRTCHNL_OP_ADD_VLAN:
 		PMD_DRV_LOG(INFO, "OP_ADD_VLAN received\n");
@@ -932,10 +926,9 @@  i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 	case I40E_VIRTCHNL_OP_FCOE:
 		PMD_DRV_LOG(ERR, "OP_FCOE received, not supported\n");
 	default:
-		PMD_DRV_LOG(ERR, "%u received, not supported\n",
-							opcode);
-		i40e_pf_host_send_msg_to_vf(vf, opcode,
-				I40E_ERR_PARAM, NULL, 0);
+		PMD_DRV_LOG(ERR, "%u received, not supported\n", opcode);
+		i40e_pf_host_send_msg_to_vf(vf, opcode, I40E_ERR_PARAM,
+								NULL, 0);
 		break;
 	}
 }