qed*: Semantic changes
[cascardo/linux.git] / drivers / net / ethernet / qlogic / qed / qed_l2.c
index 401e738..b5d8445 100644 (file)
@@ -52,7 +52,7 @@ int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
        u16 rx_mode = 0;
 
        rc = qed_fw_vport(p_hwfn, p_params->vport_id, &abs_vport_id);
-       if (rc != 0)
+       if (rc)
                return rc;
 
        memset(&init_data, 0, sizeof(init_data));
@@ -80,8 +80,7 @@ int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
        p_ramrod->rx_mode.state = cpu_to_le16(rx_mode);
 
        /* TPA related fields */
-       memset(&p_ramrod->tpa_param, 0,
-              sizeof(struct eth_vport_tpa_param));
+       memset(&p_ramrod->tpa_param, 0, sizeof(struct eth_vport_tpa_param));
 
        p_ramrod->tpa_param.max_buff_num = p_params->max_buffers_per_cqe;
 
@@ -336,7 +335,7 @@ int qed_sp_vport_update(struct qed_hwfn *p_hwfn,
        }
 
        rc = qed_fw_vport(p_hwfn, p_params->vport_id, &abs_vport_id);
-       if (rc != 0)
+       if (rc)
                return rc;
 
        memset(&init_data, 0, sizeof(init_data));
@@ -411,7 +410,7 @@ int qed_sp_vport_stop(struct qed_hwfn *p_hwfn, u16 opaque_fid, u8 vport_id)
                return qed_vf_pf_vport_stop(p_hwfn);
 
        rc = qed_fw_vport(p_hwfn, vport_id, &abs_vport_id);
-       if (rc != 0)
+       if (rc)
                return rc;
 
        memset(&init_data, 0, sizeof(init_data));
@@ -476,7 +475,7 @@ static int qed_filter_accept_cmd(struct qed_dev *cdev,
 
                rc = qed_sp_vport_update(p_hwfn, &vport_update_params,
                                         comp_mode, p_comp_data);
-               if (rc != 0) {
+               if (rc) {
                        DP_ERR(cdev, "Update rx_mode failed %d\n", rc);
                        return rc;
                }
@@ -511,7 +510,7 @@ static int qed_sp_release_queue_cid(
 int qed_sp_eth_rxq_start_ramrod(struct qed_hwfn *p_hwfn,
                                u16 opaque_fid,
                                u32 cid,
-                               struct qed_queue_start_common_params *params,
+                               struct qed_queue_start_common_params *p_params,
                                u8 stats_id,
                                u16 bd_max_bytes,
                                dma_addr_t bd_chain_phys_addr,
@@ -526,23 +525,23 @@ int qed_sp_eth_rxq_start_ramrod(struct qed_hwfn *p_hwfn,
        int rc = -EINVAL;
 
        /* Store information for the stop */
-       p_rx_cid                = &p_hwfn->p_rx_cids[params->queue_id];
-       p_rx_cid->cid           = cid;
-       p_rx_cid->opaque_fid    = opaque_fid;
-       p_rx_cid->vport_id      = params->vport_id;
+       p_rx_cid = &p_hwfn->p_rx_cids[p_params->queue_id];
+       p_rx_cid->cid = cid;
+       p_rx_cid->opaque_fid = opaque_fid;
+       p_rx_cid->vport_id = p_params->vport_id;
 
-       rc = qed_fw_vport(p_hwfn, params->vport_id, &abs_vport_id);
-       if (rc != 0)
+       rc = qed_fw_vport(p_hwfn, p_params->vport_id, &abs_vport_id);
+       if (rc)
                return rc;
 
-       rc = qed_fw_l2_queue(p_hwfn, params->queue_id, &abs_rx_q_id);
-       if (rc != 0)
+       rc = qed_fw_l2_queue(p_hwfn, p_params->queue_id, &abs_rx_q_id);
+       if (rc)
                return rc;
 
        DP_VERBOSE(p_hwfn, QED_MSG_SP,
                   "opaque_fid=0x%x, cid=0x%x, rx_qid=0x%x, vport_id=0x%x, sb_id=0x%x\n",
-                  opaque_fid, cid, params->queue_id, params->vport_id,
-                  params->sb);
+                  opaque_fid,
+                  cid, p_params->queue_id, p_params->vport_id, p_params->sb);
 
        /* Get SPQ entry */
        memset(&init_data, 0, sizeof(init_data));
@@ -558,24 +557,25 @@ int qed_sp_eth_rxq_start_ramrod(struct qed_hwfn *p_hwfn,
 
        p_ramrod = &p_ent->ramrod.rx_queue_start;
 
-       p_ramrod->sb_id                 = cpu_to_le16(params->sb);
-       p_ramrod->sb_index              = params->sb_idx;
-       p_ramrod->vport_id              = abs_vport_id;
-       p_ramrod->stats_counter_id      = stats_id;
-       p_ramrod->rx_queue_id           = cpu_to_le16(abs_rx_q_id);
-       p_ramrod->complete_cqe_flg      = 0;
-       p_ramrod->complete_event_flg    = 1;
+       p_ramrod->sb_id = cpu_to_le16(p_params->sb);
+       p_ramrod->sb_index = p_params->sb_idx;
+       p_ramrod->vport_id = abs_vport_id;
+       p_ramrod->stats_counter_id = stats_id;
+       p_ramrod->rx_queue_id = cpu_to_le16(abs_rx_q_id);
+       p_ramrod->complete_cqe_flg = 0;
+       p_ramrod->complete_event_flg = 1;
 
-       p_ramrod->bd_max_bytes  = cpu_to_le16(bd_max_bytes);
+       p_ramrod->bd_max_bytes = cpu_to_le16(bd_max_bytes);
        DMA_REGPAIR_LE(p_ramrod->bd_base, bd_chain_phys_addr);
 
-       p_ramrod->num_of_pbl_pages      = cpu_to_le16(cqe_pbl_size);
+       p_ramrod->num_of_pbl_pages = cpu_to_le16(cqe_pbl_size);
        DMA_REGPAIR_LE(p_ramrod->cqe_pbl_addr, cqe_pbl_addr);
 
-       p_ramrod->vf_rx_prod_index = params->vf_qid;
-       if (params->vf_qid)
+       p_ramrod->vf_rx_prod_index = p_params->vf_qid;
+       if (p_params->vf_qid)
                DP_VERBOSE(p_hwfn, QED_MSG_SP,
-                          "Queue is meant for VF rxq[%04x]\n", params->vf_qid);
+                          "Queue is meant for VF rxq[%04x]\n",
+                          p_params->vf_qid);
 
        return qed_spq_post(p_hwfn, p_ent, NULL);
 }
@@ -583,7 +583,7 @@ int qed_sp_eth_rxq_start_ramrod(struct qed_hwfn *p_hwfn,
 static int
 qed_sp_eth_rx_queue_start(struct qed_hwfn *p_hwfn,
                          u16 opaque_fid,
-                         struct qed_queue_start_common_params *params,
+                         struct qed_queue_start_common_params *p_params,
                          u16 bd_max_bytes,
                          dma_addr_t bd_chain_phys_addr,
                          dma_addr_t cqe_pbl_addr,
@@ -597,20 +597,20 @@ qed_sp_eth_rx_queue_start(struct qed_hwfn *p_hwfn,
 
        if (IS_VF(p_hwfn->cdev)) {
                return qed_vf_pf_rxq_start(p_hwfn,
-                                          params->queue_id,
-                                          params->sb,
-                                          params->sb_idx,
+                                          p_params->queue_id,
+                                          p_params->sb,
+                                          (u8)p_params->sb_idx,
                                           bd_max_bytes,
                                           bd_chain_phys_addr,
                                           cqe_pbl_addr, cqe_pbl_size, pp_prod);
        }
 
-       rc = qed_fw_l2_queue(p_hwfn, params->queue_id, &abs_l2_queue);
-       if (rc != 0)
+       rc = qed_fw_l2_queue(p_hwfn, p_params->queue_id, &abs_l2_queue);
+       if (rc)
                return rc;
 
-       rc = qed_fw_vport(p_hwfn, params->vport_id, &abs_stats_id);
-       if (rc != 0)
+       rc = qed_fw_vport(p_hwfn, p_params->vport_id, &abs_stats_id);
+       if (rc)
                return rc;
 
        *pp_prod = (u8 __iomem *)p_hwfn->regview +
@@ -622,9 +622,8 @@ qed_sp_eth_rx_queue_start(struct qed_hwfn *p_hwfn,
                          (u32 *)(&init_prod_val));
 
        /* Allocate a CID for the queue */
-       p_rx_cid = &p_hwfn->p_rx_cids[params->queue_id];
-       rc = qed_cxt_acquire_cid(p_hwfn, PROTOCOLID_ETH,
-                                &p_rx_cid->cid);
+       p_rx_cid = &p_hwfn->p_rx_cids[p_params->queue_id];
+       rc = qed_cxt_acquire_cid(p_hwfn, PROTOCOLID_ETH, &p_rx_cid->cid);
        if (rc) {
                DP_NOTICE(p_hwfn, "Failed to acquire cid\n");
                return rc;
@@ -634,14 +633,14 @@ qed_sp_eth_rx_queue_start(struct qed_hwfn *p_hwfn,
        rc = qed_sp_eth_rxq_start_ramrod(p_hwfn,
                                         opaque_fid,
                                         p_rx_cid->cid,
-                                        params,
+                                        p_params,
                                         abs_stats_id,
                                         bd_max_bytes,
                                         bd_chain_phys_addr,
                                         cqe_pbl_addr,
                                         cqe_pbl_size);
 
-       if (rc != 0)
+       if (rc)
                qed_sp_release_queue_cid(p_hwfn, p_rx_cid);
 
        return rc;
@@ -788,21 +787,20 @@ int qed_sp_eth_txq_start_ramrod(struct qed_hwfn  *p_hwfn,
        if (rc)
                return rc;
 
-       p_ramrod                = &p_ent->ramrod.tx_queue_start;
-       p_ramrod->vport_id      = abs_vport_id;
+       p_ramrod = &p_ent->ramrod.tx_queue_start;
+       p_ramrod->vport_id = abs_vport_id;
+
+       p_ramrod->sb_id = cpu_to_le16(p_params->sb);
+       p_ramrod->sb_index = p_params->sb_idx;
+       p_ramrod->stats_counter_id = stats_id;
 
-       p_ramrod->sb_id                 = cpu_to_le16(p_params->sb);
-       p_ramrod->sb_index              = p_params->sb_idx;
-       p_ramrod->stats_counter_id      = stats_id;
+       p_ramrod->queue_zone_id = cpu_to_le16(abs_tx_q_id);
 
-       p_ramrod->queue_zone_id         = cpu_to_le16(abs_tx_q_id);
-       p_ramrod->pbl_size              = cpu_to_le16(pbl_size);
+       p_ramrod->pbl_size = cpu_to_le16(pbl_size);
        DMA_REGPAIR_LE(p_ramrod->pbl_base_addr, pbl_addr);
 
-       pq_id                   = qed_get_qm_pq(p_hwfn,
-                                               PROTOCOLID_ETH,
-                                               p_pq_params);
-       p_ramrod->qm_pq_id      = cpu_to_le16(pq_id);
+       pq_id = qed_get_qm_pq(p_hwfn, PROTOCOLID_ETH, p_pq_params);
+       p_ramrod->qm_pq_id = cpu_to_le16(pq_id);
 
        return qed_spq_post(p_hwfn, p_ent, NULL);
 }
@@ -836,8 +834,7 @@ qed_sp_eth_tx_queue_start(struct qed_hwfn *p_hwfn,
        memset(&pq_params, 0, sizeof(pq_params));
 
        /* Allocate a CID for the queue */
-       rc = qed_cxt_acquire_cid(p_hwfn, PROTOCOLID_ETH,
-                                &p_tx_cid->cid);
+       rc = qed_cxt_acquire_cid(p_hwfn, PROTOCOLID_ETH, &p_tx_cid->cid);
        if (rc) {
                DP_NOTICE(p_hwfn, "Failed to acquire cid\n");
                return rc;
@@ -896,8 +893,7 @@ int qed_sp_eth_tx_queue_stop(struct qed_hwfn *p_hwfn, u16 tx_queue_id)
        return qed_sp_release_queue_cid(p_hwfn, p_tx_cid);
 }
 
-static enum eth_filter_action
-qed_filter_action(enum qed_filter_opcode opcode)
+static enum eth_filter_action qed_filter_action(enum qed_filter_opcode opcode)
 {
        enum eth_filter_action action = MAX_ETH_FILTER_ACTION;
 
@@ -1033,19 +1029,19 @@ qed_filter_ucast_common(struct qed_hwfn *p_hwfn,
                p_first_filter->vni = cpu_to_le32(p_filter_cmd->vni);
 
        if (p_filter_cmd->opcode == QED_FILTER_MOVE) {
-               p_second_filter->type           = p_first_filter->type;
-               p_second_filter->mac_msb        = p_first_filter->mac_msb;
-               p_second_filter->mac_mid        = p_first_filter->mac_mid;
-               p_second_filter->mac_lsb        = p_first_filter->mac_lsb;
-               p_second_filter->vlan_id        = p_first_filter->vlan_id;
-               p_second_filter->vni            = p_first_filter->vni;
+               p_second_filter->type = p_first_filter->type;
+               p_second_filter->mac_msb = p_first_filter->mac_msb;
+               p_second_filter->mac_mid = p_first_filter->mac_mid;
+               p_second_filter->mac_lsb = p_first_filter->mac_lsb;
+               p_second_filter->vlan_id = p_first_filter->vlan_id;
+               p_second_filter->vni = p_first_filter->vni;
 
                p_first_filter->action = ETH_FILTER_ACTION_REMOVE;
 
                p_first_filter->vport_id = vport_to_remove_from;
 
-               p_second_filter->action         = ETH_FILTER_ACTION_ADD;
-               p_second_filter->vport_id       = vport_to_add_to;
+               p_second_filter->action = ETH_FILTER_ACTION_ADD;
+               p_second_filter->vport_id = vport_to_add_to;
        } else if (p_filter_cmd->opcode == QED_FILTER_REPLACE) {
                p_first_filter->vport_id = vport_to_add_to;
                memcpy(p_second_filter, p_first_filter,
@@ -1086,7 +1082,7 @@ int qed_sp_eth_filter_ucast(struct qed_hwfn *p_hwfn,
        rc = qed_filter_ucast_common(p_hwfn, opaque_fid, p_filter_cmd,
                                     &p_ramrod, &p_ent,
                                     comp_mode, p_comp_data);
-       if (rc != 0) {
+       if (rc) {
                DP_ERR(p_hwfn, "Uni. filter command failed %d\n", rc);
                return rc;
        }
@@ -1094,10 +1090,8 @@ int qed_sp_eth_filter_ucast(struct qed_hwfn *p_hwfn,
        p_header->assert_on_error = p_filter_cmd->assert_on_error;
 
        rc = qed_spq_post(p_hwfn, p_ent, NULL);
-       if (rc != 0) {
-               DP_ERR(p_hwfn,
-                      "Unicast filter ADD command failed %d\n",
-                      rc);
+       if (rc) {
+               DP_ERR(p_hwfn, "Unicast filter ADD command failed %d\n", rc);
                return rc;
        }
 
@@ -1136,15 +1130,10 @@ int qed_sp_eth_filter_ucast(struct qed_hwfn *p_hwfn,
  * Return:
  ******************************************************************************/
 static u32 qed_calc_crc32c(u8 *crc32_packet,
-                          u32 crc32_length,
-                          u32 crc32_seed,
-                          u8 complement)
+                          u32 crc32_length, u32 crc32_seed, u8 complement)
 {
-       u32 byte = 0;
-       u32 bit = 0;
-       u8 msb = 0;
-       u8 current_byte = 0;
-       u32 crc32_result = crc32_seed;
+       u32 byte = 0, bit = 0, crc32_result = crc32_seed;
+       u8 msb = 0, current_byte = 0;
 
        if ((!crc32_packet) ||
            (crc32_length == 0) ||
@@ -1164,9 +1153,7 @@ static u32 qed_calc_crc32c(u8 *crc32_packet,
        return crc32_result;
 }
 
-static inline u32 qed_crc32c_le(u32 seed,
-                               u8 *mac,
-                               u32 len)
+static u32 qed_crc32c_le(u32 seed, u8 *mac, u32 len)
 {
        u32 packet_buf[2] = { 0 };
 
@@ -1244,11 +1231,11 @@ qed_sp_eth_filter_mcast(struct qed_hwfn *p_hwfn,
 
                /* Convert to correct endianity */
                for (i = 0; i < ETH_MULTICAST_MAC_BINS_IN_REGS; i++) {
+                       struct vport_update_ramrod_mcast *p_ramrod_bins;
                        u32 *p_bins = (u32 *)bins;
-                       struct vport_update_ramrod_mcast *approx_mcast;
 
-                       approx_mcast = &p_ramrod->approx_mcast;
-                       approx_mcast->bins[i] = cpu_to_le32(p_bins[i]);
+                       p_ramrod_bins = &p_ramrod->approx_mcast;
+                       p_ramrod_bins->bins[i] = cpu_to_le32(p_bins[i]);
                }
        }
 
@@ -1286,8 +1273,7 @@ static int qed_filter_mcast_cmd(struct qed_dev *cdev,
                rc = qed_sp_eth_filter_mcast(p_hwfn,
                                             opaque_fid,
                                             p_filter_cmd,
-                                            comp_mode,
-                                            p_comp_data);
+                                            comp_mode, p_comp_data);
        }
        return rc;
 }
@@ -1314,9 +1300,8 @@ static int qed_filter_ucast_cmd(struct qed_dev *cdev,
                rc = qed_sp_eth_filter_ucast(p_hwfn,
                                             opaque_fid,
                                             p_filter_cmd,
-                                            comp_mode,
-                                            p_comp_data);
-               if (rc != 0)
+                                            comp_mode, p_comp_data);
+               if (rc)
                        break;
        }
 
@@ -1590,8 +1575,7 @@ out:
        }
 }
 
-void qed_get_vport_stats(struct qed_dev *cdev,
-                        struct qed_eth_stats *stats)
+void qed_get_vport_stats(struct qed_dev *cdev, struct qed_eth_stats *stats)
 {
        u32 i;
 
@@ -1766,8 +1750,7 @@ static int qed_start_vport(struct qed_dev *cdev,
        return 0;
 }
 
-static int qed_stop_vport(struct qed_dev *cdev,
-                         u8 vport_id)
+static int qed_stop_vport(struct qed_dev *cdev, u8 vport_id)
 {
        int rc, i;
 
@@ -1775,8 +1758,7 @@ static int qed_stop_vport(struct qed_dev *cdev,
                struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
 
                rc = qed_sp_vport_stop(p_hwfn,
-                                      p_hwfn->hw_info.opaque_fid,
-                                      vport_id);
+                                      p_hwfn->hw_info.opaque_fid, vport_id);
 
                if (rc) {
                        DP_ERR(cdev, "Failed to stop VPORT\n");
@@ -1801,10 +1783,8 @@ static int qed_update_vport(struct qed_dev *cdev,
 
        /* Translate protocol params into sp params */
        sp_params.vport_id = params->vport_id;
-       sp_params.update_vport_active_rx_flg =
-               params->update_vport_active_flg;
-       sp_params.update_vport_active_tx_flg =
-               params->update_vport_active_flg;
+       sp_params.update_vport_active_rx_flg = params->update_vport_active_flg;
+       sp_params.update_vport_active_tx_flg = params->update_vport_active_flg;
        sp_params.vport_active_rx_flg = params->vport_active_flg;
        sp_params.vport_active_tx_flg = params->vport_active_flg;
        sp_params.update_tx_switching_flg = params->update_tx_switching_flg;
@@ -1817,8 +1797,7 @@ static int qed_update_vport(struct qed_dev *cdev,
         * We need to re-fix the rss values per engine for CMT.
         */
        if (cdev->num_hwfns > 1 && params->update_rss_flg) {
-               struct qed_update_vport_rss_params *rss =
-                       &params->rss_params;
+               struct qed_update_vport_rss_params *rss = &params->rss_params;
                int k, max = 0;
 
                /* Find largest entry, since it's possible RSS needs to
@@ -1893,8 +1872,8 @@ static int qed_start_rxq(struct qed_dev *cdev,
                         u16 cqe_pbl_size,
                         void __iomem **pp_prod)
 {
-       int rc, hwfn_index;
        struct qed_hwfn *p_hwfn;
+       int rc, hwfn_index;
 
        hwfn_index = params->rss_id % cdev->num_hwfns;
        p_hwfn = &cdev->hwfns[hwfn_index];
@@ -1935,8 +1914,7 @@ static int qed_stop_rxq(struct qed_dev *cdev,
 
        rc = qed_sp_eth_rx_queue_stop(p_hwfn,
                                      params->rx_queue_id / cdev->num_hwfns,
-                                     params->eq_completion_only,
-                                     false);
+                                     params->eq_completion_only, false);
        if (rc) {
                DP_ERR(cdev, "Failed to stop RXQ#%d\n", params->rx_queue_id);
                return rc;
@@ -2047,11 +2025,11 @@ static int qed_configure_filter_rx_mode(struct qed_dev *cdev,
 
        memset(&accept_flags, 0, sizeof(accept_flags));
 
-       accept_flags.update_rx_mode_config      = 1;
-       accept_flags.update_tx_mode_config      = 1;
-       accept_flags.rx_accept_filter           = QED_ACCEPT_UCAST_MATCHED |
-                                                 QED_ACCEPT_MCAST_MATCHED |
-                                                 QED_ACCEPT_BCAST;
+       accept_flags.update_rx_mode_config = 1;
+       accept_flags.update_tx_mode_config = 1;
+       accept_flags.rx_accept_filter = QED_ACCEPT_UCAST_MATCHED |
+                                       QED_ACCEPT_MCAST_MATCHED |
+                                       QED_ACCEPT_BCAST;
        accept_flags.tx_accept_filter = QED_ACCEPT_UCAST_MATCHED |
                                        QED_ACCEPT_MCAST_MATCHED |
                                        QED_ACCEPT_BCAST;
@@ -2072,9 +2050,8 @@ static int qed_configure_filter_ucast(struct qed_dev *cdev,
        struct qed_filter_ucast ucast;
 
        if (!params->vlan_valid && !params->mac_valid) {
-               DP_NOTICE(
-                       cdev,
-                       "Tried configuring a unicast filter, but both MAC and VLAN are not set\n");
+               DP_NOTICE(cdev,
+                         "Tried configuring a unicast filter, but both MAC and VLAN are not set\n");
                return -EINVAL;
        }
 
@@ -2135,8 +2112,7 @@ static int qed_configure_filter_mcast(struct qed_dev *cdev,
        for (i = 0; i < mcast.num_mc_addrs; i++)
                ether_addr_copy(mcast.mac[i], params->mac[i]);
 
-       return qed_filter_mcast_cmd(cdev, &mcast,
-                                   QED_SPQ_MODE_CB, NULL);
+       return qed_filter_mcast_cmd(cdev, &mcast, QED_SPQ_MODE_CB, NULL);
 }
 
 static int qed_configure_filter(struct qed_dev *cdev,
@@ -2153,15 +2129,13 @@ static int qed_configure_filter(struct qed_dev *cdev,
                accept_flags = params->filter.accept_flags;
                return qed_configure_filter_rx_mode(cdev, accept_flags);
        default:
-               DP_NOTICE(cdev, "Unknown filter type %d\n",
-                         (int)params->type);
+               DP_NOTICE(cdev, "Unknown filter type %d\n", (int)params->type);
                return -EINVAL;
        }
 }
 
 static int qed_fp_cqe_completion(struct qed_dev *dev,
-                                u8 rss_id,
-                                struct eth_slow_path_rx_cqe *cqe)
+                                u8 rss_id, struct eth_slow_path_rx_cqe *cqe)
 {
        return qed_eth_cqe_completion(&dev->hwfns[rss_id % dev->num_hwfns],
                                      cqe);