BNX2X: spatch ether->mtu -> ether->maxmtu
[akaros.git] / kern / drivers / net / bnx2x / bnx2x_vfpf.c
index 5f334ad..84e4dd8 100644 (file)
@@ -39,7 +39,7 @@ static void bnx2x_add_tlv(struct bnx2x *bp, void *tlvs_list,
 static void bnx2x_vfpf_prep(struct bnx2x *bp, struct vfpf_first_tlv *first_tlv,
                            uint16_t type, uint16_t length)
 {
-       mutex_lock(&bp->vf2pf_mutex);
+       qlock(&bp->vf2pf_mutex);
 
        DP(BNX2X_MSG_IOV, "preparing to send %d tlv over vf pf channel\n",
           type);
@@ -61,7 +61,7 @@ static void bnx2x_vfpf_finalize(struct bnx2x *bp,
        DP(BNX2X_MSG_IOV, "done sending [%d] tlv over vf pf channel\n",
           first_tlv->tl.type);
 
-       mutex_unlock(&bp->vf2pf_mutex);
+       qunlock(&bp->vf2pf_mutex);
 }
 
 /* Finds a TLV by type in a TLV buffer; If found, returns pointer to the TLV */
@@ -161,20 +161,20 @@ static int bnx2x_send_msg2pf(struct bnx2x *bp, uint8_t *done,
        }
 
        /* Write message address */
-       writel(U64_LO(msg_mapping),
+       write32(U64_LO(msg_mapping),
               &zone_data->non_trigger.vf_pf_channel.msg_addr_lo);
-       writel(U64_HI(msg_mapping),
+       write32(U64_HI(msg_mapping),
               &zone_data->non_trigger.vf_pf_channel.msg_addr_hi);
 
        /* make sure the address is written before FW accesses it */
        wmb();
 
        /* Trigger the PF FW */
-       writeb(1, &zone_data->trigger.vf_pf_channel.addr_valid);
+       write8(1, &zone_data->trigger.vf_pf_channel.addr_valid);
 
        /* Wait for PF to complete */
        while ((tout >= 0) && (!*done)) {
-               msleep(interval);
+               kthread_usleep(1000 * interval);
                tout -= 1;
 
                /* progress indicator - HV can take its own sweet time in
@@ -198,11 +198,11 @@ static int bnx2x_get_vf_id(struct bnx2x *bp, uint32_t *vf_id)
 
        do {
                /* pxp traps vf read of doorbells and returns me reg value */
-               me_reg = readl(bp->doorbells);
+               me_reg = read32(bp->doorbells);
                if (GOOD_ME_REG(me_reg))
                        break;
 
-               msleep(interval);
+               kthread_usleep(1000 * interval);
 
                BNX2X_ERR("Invalid ME register value: 0x%08x\n. Is pf driver up?",
                          me_reg);
@@ -298,22 +298,22 @@ int bnx2x_vfpf_acquire(struct bnx2x *bp, uint8_t tx_count, uint8_t rx_count)
 
                        /* humble our request */
                        req->resc_request.num_txqs =
-                               min(req->resc_request.num_txqs,
+                               MIN(req->resc_request.num_txqs,
                                    bp->acquire_resp.resc.num_txqs);
                        req->resc_request.num_rxqs =
-                               min(req->resc_request.num_rxqs,
+                               MIN(req->resc_request.num_rxqs,
                                    bp->acquire_resp.resc.num_rxqs);
                        req->resc_request.num_sbs =
-                               min(req->resc_request.num_sbs,
+                               MIN(req->resc_request.num_sbs,
                                    bp->acquire_resp.resc.num_sbs);
                        req->resc_request.num_mac_filters =
-                               min(req->resc_request.num_mac_filters,
+                               MIN(req->resc_request.num_mac_filters,
                                    bp->acquire_resp.resc.num_mac_filters);
                        req->resc_request.num_vlan_filters =
-                               min(req->resc_request.num_vlan_filters,
+                               MIN(req->resc_request.num_vlan_filters,
                                    bp->acquire_resp.resc.num_vlan_filters);
                        req->resc_request.num_mc_filters =
-                               min(req->resc_request.num_mc_filters,
+                               MIN(req->resc_request.num_mc_filters,
                                    bp->acquire_resp.resc.num_mc_filters);
 
                        /* Clear response buffer */
@@ -338,7 +338,7 @@ int bnx2x_vfpf_acquire(struct bnx2x *bp, uint8_t tx_count, uint8_t rx_count)
                         bnx2x_search_tlv_list(bp, resp,
                                               CHANNEL_TLV_PHYS_PORT_ID);
        if (phys_port_resp) {
-               memcpy(bp->phys_port_id, phys_port_resp->id, ETH_ALEN);
+               memcpy(bp->phys_port_id, phys_port_resp->id, Eaddrlen);
                bp->flags |= HAS_PHYS_PORT_ID;
        }
 
@@ -381,7 +381,7 @@ int bnx2x_vfpf_acquire(struct bnx2x *bp, uint8_t tx_count, uint8_t rx_count)
        if (is_valid_ether_addr(bp->acquire_resp.resc.current_mac_addr))
                memcpy(bp->dev->dev_addr,
                       bp->acquire_resp.resc.current_mac_addr,
-                      ETH_ALEN);
+                      Eaddrlen);
 
 out:
        bnx2x_vfpf_finalize(bp, &req->first_tlv);
@@ -624,11 +624,11 @@ int bnx2x_vfpf_setup_q(struct bnx2x *bp, struct bnx2x_fastpath *fp,
        req->rxq.vf_sb = fp_idx;
        req->rxq.sb_index = HC_INDEX_ETH_RX_CQ_CONS;
        req->rxq.hc_rate = bp->rx_ticks ? 1000000/bp->rx_ticks : 0;
-       req->rxq.mtu = bp->dev->mtu;
+       req->rxq.mtu = bp->dev->maxmtu;
        req->rxq.buf_sz = fp->rx_buf_size;
        req->rxq.sge_buf_sz = BCM_PAGE_SIZE * PAGES_PER_SGE;
        req->rxq.tpa_agg_sz = tpa_agg_size;
-       req->rxq.max_sge_pkt = SGE_PAGE_ALIGN(bp->dev->mtu) >> SGE_PAGE_SHIFT;
+       req->rxq.max_sge_pkt = SGE_PAGE_ALIGN(bp->dev->maxmtu) >> SGE_PAGE_SHIFT;
        req->rxq.max_sge_pkt = ((req->rxq.max_sge_pkt + PAGES_PER_SGE - 1) &
                          (~(PAGES_PER_SGE-1))) >> PAGES_PER_SGE_SHIFT;
        req->rxq.flags = flags;
@@ -732,7 +732,7 @@ int bnx2x_vfpf_config_mac(struct bnx2x *bp, uint8_t *addr, uint8_t vf_qid,
        bnx2x_sample_bulletin(bp);
 
        /* copy mac from device to request */
-       memcpy(req->filters[0].mac, addr, ETH_ALEN);
+       memcpy(req->filters[0].mac, addr, Eaddrlen);
 
        /* add list termination tlv */
        bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
@@ -754,13 +754,13 @@ int bnx2x_vfpf_config_mac(struct bnx2x *bp, uint8_t *addr, uint8_t vf_qid,
                   "vfpf SET MAC failed. Check bulletin board for new posts\n");
 
                /* copy mac from bulletin to device */
-               memcpy(bp->dev->dev_addr, bulletin.mac, ETH_ALEN);
+               memcpy(bp->dev->dev_addr, bulletin.mac, Eaddrlen);
 
                /* check if bulletin board was updated */
                if (bnx2x_sample_bulletin(bp) == PFVF_BULLETIN_UPDATED) {
                        /* copy mac from device to request */
                        memcpy(req->filters[0].mac, bp->dev->dev_addr,
-                              ETH_ALEN);
+                              Eaddrlen);
 
                        /* send message to pf */
                        rc = bnx2x_send_msg2pf(bp, &resp->hdr.status,
@@ -850,7 +850,7 @@ out:
        return rc;
 }
 
-int bnx2x_vfpf_set_mcast(struct net_device *dev)
+int bnx2x_vfpf_set_mcast(struct ether *dev)
 {
        struct bnx2x *bp = netdev_priv(dev);
        struct vfpf_set_q_filters_tlv *req = &bp->vf2pf_mbox->req.set_q_filters;
@@ -873,7 +873,7 @@ int bnx2x_vfpf_set_mcast(struct net_device *dev)
        netdev_for_each_mc_addr(ha, dev) {
                DP(NETIF_MSG_IFUP, "Adding mcast MAC: %pM\n",
                   bnx2x_mc_addr(ha));
-               memcpy(req->multicast[i], bnx2x_mc_addr(ha), ETH_ALEN);
+               memcpy(req->multicast[i], bnx2x_mc_addr(ha), Eaddrlen);
                i++;
        }
 
@@ -1100,7 +1100,7 @@ static void bnx2x_vf_mbx_resp_send_msg(struct bnx2x *bp,
 
        /* ack the FW */
        storm_memset_vf_mbx_ack(bp, vf->abs_vfid);
-       mmiowb();
+       bus_wmb();
 
        /* copy the response header including status-done field,
         * must be last dmae, must be after FW is acked
@@ -1147,7 +1147,7 @@ static void bnx2x_vf_mbx_resp_phys_port(struct bnx2x *bp,
 
        port_id = (struct vfpf_port_phys_id_resp_tlv *)
                  (((uint8_t *)buffer) + *offset);
-       memcpy(port_id->id, bp->phys_port_id, ETH_ALEN);
+       memcpy(port_id->id, bp->phys_port_id, Eaddrlen);
 
        /* Offset should continue representing the offset to the tail
         * of TLV data (outside this function scope)
@@ -1227,7 +1227,7 @@ static void bnx2x_vf_mbx_acquire_resp(struct bnx2x *bp, struct bnx2x_virtf *vf,
                        /* if a mac has been set for this vf, supply it */
                        if (bulletin->valid_bitmap & 1 << MAC_ADDR_VALID) {
                                memcpy(resc->current_mac_addr, bulletin->mac,
-                                      ETH_ALEN);
+                                      Eaddrlen);
                        }
                }
        }
@@ -1350,7 +1350,7 @@ static void bnx2x_vf_mbx_acquire(struct bnx2x *bp, struct bnx2x_virtf *vf,
        if (bnx2x_vf_mbx_is_windows_vm(bp, &mbx->msg->req.acquire))
                vf->fp_hsi = acquire->vfdev_info.fp_hsi_ver;
        else
-               vf->fp_hsi = max_t(uint8_t, acquire->vfdev_info.fp_hsi_ver,
+               vf->fp_hsi = MAX_T(uint8_t, acquire->vfdev_info.fp_hsi_ver,
                                   ETH_FP_HSI_VER_2);
        if (vf->fp_hsi > ETH_FP_HSI_VERSION) {
                DP(BNX2X_MSG_IOV,
@@ -1573,7 +1573,7 @@ static int bnx2x_vf_mbx_macvlan_list(struct bnx2x *bp,
              sizeof(struct bnx2x_vf_mac_vlan_filter) +
              sizeof(struct bnx2x_vf_mac_vlan_filters);
 
-       fl = kzalloc(fsz, GFP_KERNEL);
+       fl = kzmalloc(fsz, KMALLOC_WAIT);
        if (!fl)
                return -ENOMEM;
 
@@ -2044,7 +2044,7 @@ static void bnx2x_vf_mbx_request(struct bnx2x *bp, struct bnx2x_virtf *vf,
                 */
                storm_memset_vf_mbx_ack(bp, vf->abs_vfid);
                /* Firmware ack should be written before unlocking channel */
-               mmiowb();
+               bus_wmb();
                bnx2x_unlock_vf_pf_channel(bp, vf, mbx->first_tlv.tl.type);
        }
 }
@@ -2070,11 +2070,11 @@ void bnx2x_vf_mbx_schedule(struct bnx2x *bp,
        vf_idx = bnx2x_vf_idx_by_abs_fid(bp, vfpf_event->vf_id);
 
        /* Update VFDB with current message and schedule its handling */
-       mutex_lock(&BP_VFDB(bp)->event_mutex);
+       qlock(&BP_VFDB(bp)->event_mutex);
        BP_VF_MBX(bp, vf_idx)->vf_addr_hi = vfpf_event->msg_addr_hi;
        BP_VF_MBX(bp, vf_idx)->vf_addr_lo = vfpf_event->msg_addr_lo;
        BP_VFDB(bp)->event_occur |= (1ULL << vf_idx);
-       mutex_unlock(&BP_VFDB(bp)->event_mutex);
+       qunlock(&BP_VFDB(bp)->event_mutex);
 
        bnx2x_schedule_iov_task(bp, BNX2X_IOV_HANDLE_VF_MSG);
 }
@@ -2090,10 +2090,10 @@ void bnx2x_vf_mbx(struct bnx2x *bp)
        if (!vfdb)
                return;
 
-       mutex_lock(&vfdb->event_mutex);
+       qlock(&vfdb->event_mutex);
        events = vfdb->event_occur;
        vfdb->event_occur = 0;
-       mutex_unlock(&vfdb->event_mutex);
+       qunlock(&vfdb->event_mutex);
 
        for_each_vf(bp, vf_idx) {
                struct bnx2x_vf_mbx *mbx = BP_VF_MBX(bp, vf_idx);