Lines Matching refs:vf

191 static unsigned abs_index(struct siena_vf *vf, unsigned index)
193 return EFX_VI_BASE + vf->index * efx_vf_size(vf->efx) + index;
302 static void efx_siena_sriov_reset_tx_filter(struct siena_vf *vf)
304 struct efx_nic *efx = vf->efx;
309 if (vf->tx_filter_id != -1) {
311 vf->tx_filter_id);
312 netif_dbg(efx, hw, efx->net_dev, "Removed vf %s tx filter %d\n",
313 vf->pci_name, vf->tx_filter_id);
314 vf->tx_filter_id = -1;
317 if (is_zero_ether_addr(vf->addr.mac_addr))
323 if (vf->tx_filter_mode == VF_TX_FILTER_AUTO && vf_max_tx_channels <= 2)
324 vf->tx_filter_mode = VF_TX_FILTER_ON;
326 vlan = ntohs(vf->addr.tci) & VLAN_VID_MASK;
327 efx_filter_init_tx(&filter, abs_index(vf, 0));
330 vf->addr.mac_addr);
336 "Unable to migrate tx filter for vf %s\n",
337 vf->pci_name);
339 netif_dbg(efx, hw, efx->net_dev, "Inserted vf %s tx filter %d\n",
340 vf->pci_name, rc);
341 vf->tx_filter_id = rc;
346 static void efx_siena_sriov_reset_rx_filter(struct siena_vf *vf)
348 struct efx_nic *efx = vf->efx;
353 if (vf->rx_filter_id != -1) {
355 vf->rx_filter_id);
356 netif_dbg(efx, hw, efx->net_dev, "Removed vf %s rx filter %d\n",
357 vf->pci_name, vf->rx_filter_id);
358 vf->rx_filter_id = -1;
361 if (!vf->rx_filtering || is_zero_ether_addr(vf->addr.mac_addr))
364 vlan = ntohs(vf->addr.tci) & VLAN_VID_MASK;
366 vf->rx_filter_flags,
367 abs_index(vf, vf->rx_filter_qid));
370 vf->addr.mac_addr);
376 "Unable to insert rx filter for vf %s\n",
377 vf->pci_name);
379 netif_dbg(efx, hw, efx->net_dev, "Inserted vf %s rx filter %d\n",
380 vf->pci_name, rc);
381 vf->rx_filter_id = rc;
385 static void __efx_siena_sriov_update_vf_addr(struct siena_vf *vf)
387 struct efx_nic *efx = vf->efx;
390 efx_siena_sriov_reset_tx_filter(vf);
391 efx_siena_sriov_reset_rx_filter(vf);
400 static void __efx_siena_sriov_push_vf_status(struct siena_vf *vf)
402 struct efx_nic *efx = vf->efx;
411 WARN_ON(!mutex_is_locked(&vf->status_lock));
412 WARN_ON(!vf->status_addr);
414 status->local = vf->addr;
420 copy[0].to_rid = vf->pci_rid;
421 copy[0].to_addr = vf->status_addr + offsetof(struct vfdi_status,
431 copy[1].to_rid = vf->pci_rid;
432 copy[1].to_addr = vf->status_addr + data_offset;
439 if (count == vf->peer_page_count) {
448 copy[pos].to_rid = vf->pci_rid;
449 copy[pos].to_addr = vf->peer_page_addrs[count];
461 copy[pos].to_rid = vf->pci_rid;
462 copy[pos].to_addr = vf->status_addr + offsetof(struct vfdi_status,
470 VFDI_EV_SEQ, (vf->msg_seqno & 0xff),
472 ++vf->msg_seqno;
474 EFX_VI_BASE + vf->index * efx_vf_size(efx),
524 *vf_out = nic_data->vf + vf_i;
530 static int efx_vfdi_init_evq(struct siena_vf *vf)
532 struct efx_nic *efx = vf->efx;
533 struct vfdi_req *req = vf->buf.addr;
536 unsigned abs_evq = abs_index(vf, vf_evq);
537 unsigned buftbl = EFX_BUFTBL_EVQ_BASE(vf, vf_evq);
545 vf->pci_name, vf_evq, buf_count);
563 memcpy(vf->evq0_addrs, req->u.init_evq.addr,
565 vf->evq0_count = buf_count;
571 static int efx_vfdi_init_rxq(struct siena_vf *vf)
573 struct efx_nic *efx = vf->efx;
574 struct vfdi_req *req = vf->buf.addr;
578 unsigned buftbl = EFX_BUFTBL_RXQ_BASE(vf, vf_rxq);
588 "buf_count %d\n", vf->pci_name, vf_rxq,
592 if (__test_and_set_bit(req->u.init_rxq.index, vf->rxq_mask))
593 ++vf->rxq_count;
599 FRF_AZ_RX_DESCQ_EVQ_ID, abs_index(vf, vf_evq),
607 abs_index(vf, vf_rxq));
612 static int efx_vfdi_init_txq(struct siena_vf *vf)
614 struct efx_nic *efx = vf->efx;
615 struct vfdi_req *req = vf->buf.addr;
619 unsigned buftbl = EFX_BUFTBL_TXQ_BASE(vf, vf_txq);
629 "buf_count %d\n", vf->pci_name, vf_txq,
634 mutex_lock(&vf->txq_lock);
635 if (__test_and_set_bit(req->u.init_txq.index, vf->txq_mask))
636 ++vf->txq_count;
637 mutex_unlock(&vf->txq_lock);
640 eth_filt_en = vf->tx_filter_mode == VF_TX_FILTER_ON;
648 FRF_AZ_TX_DESCQ_EVQ_ID, abs_index(vf, vf_evq),
653 abs_index(vf, vf_txq));
659 static bool efx_vfdi_flush_wake(struct siena_vf *vf)
664 return (!vf->txq_count && !vf->rxq_count) ||
665 atomic_read(&vf->rxq_retry_count);
668 static void efx_vfdi_flush_clear(struct siena_vf *vf)
670 memset(vf->txq_mask, 0, sizeof(vf->txq_mask));
671 vf->txq_count = 0;
672 memset(vf->rxq_mask, 0, sizeof(vf->rxq_mask));
673 vf->rxq_count = 0;
674 memset(vf->rxq_retry_mask, 0, sizeof(vf->rxq_retry_mask));
675 atomic_set(&vf->rxq_retry_count, 0);
678 static int efx_vfdi_fini_all_queues(struct siena_vf *vf)
680 struct efx_nic *efx = vf->efx;
683 unsigned vf_offset = EFX_VI_BASE + vf->index * efx_vf_size(efx);
699 if (test_bit(index, vf->txq_mask)) {
706 if (test_bit(index, vf->rxq_mask)) {
714 atomic_set(&vf->rxq_retry_count, 0);
715 while (timeout && (vf->rxq_count || vf->txq_count)) {
721 timeout = wait_event_timeout(vf->flush_waitq,
722 efx_vfdi_flush_wake(vf),
726 if (test_and_clear_bit(index, vf->rxq_retry_mask)) {
727 atomic_dec(&vf->rxq_retry_count);
752 efx_siena_sriov_bufs(efx, vf->buftbl_base, NULL,
754 efx_vfdi_flush_clear(vf);
756 vf->evq0_count = 0;
761 static int efx_vfdi_insert_filter(struct siena_vf *vf)
763 struct efx_nic *efx = vf->efx;
765 struct vfdi_req *req = vf->buf.addr;
769 if (bad_vf_index(efx, vf_rxq) || vf->rx_filtering) {
773 "flags 0x%x\n", vf->pci_name, vf_rxq,
783 vf->rx_filter_flags = flags;
784 vf->rx_filter_qid = vf_rxq;
785 vf->rx_filtering = true;
787 efx_siena_sriov_reset_rx_filter(vf);
793 static int efx_vfdi_remove_all_filters(struct siena_vf *vf)
795 struct efx_nic *efx = vf->efx;
798 vf->rx_filtering = false;
799 efx_siena_sriov_reset_rx_filter(vf);
805 static int efx_vfdi_set_status_page(struct siena_vf *vf)
807 struct efx_nic *efx = vf->efx;
809 struct vfdi_req *req = vf->buf.addr;
820 vf->pci_name);
825 mutex_lock(&vf->status_lock);
826 vf->status_addr = req->u.set_status_page.dma_addr;
828 kfree(vf->peer_page_addrs);
829 vf->peer_page_addrs = NULL;
830 vf->peer_page_count = 0;
833 vf->peer_page_addrs = kcalloc(page_count, sizeof(u64),
835 if (vf->peer_page_addrs) {
836 memcpy(vf->peer_page_addrs,
839 vf->peer_page_count = page_count;
843 __efx_siena_sriov_push_vf_status(vf);
844 mutex_unlock(&vf->status_lock);
850 static int efx_vfdi_clear_status_page(struct siena_vf *vf)
852 mutex_lock(&vf->status_lock);
853 vf->status_addr = 0;
854 mutex_unlock(&vf->status_lock);
859 typedef int (*efx_vfdi_op_t)(struct siena_vf *vf);
874 struct siena_vf *vf = container_of(work, struct siena_vf, req);
875 struct efx_nic *efx = vf->efx;
876 struct vfdi_req *req = vf->buf.addr;
882 copy[0].from_rid = vf->pci_rid;
883 copy[0].from_addr = vf->req_addr;
885 copy[0].to_addr = vf->buf.dma_addr;
893 vf->pci_name, -rc);
894 vf->busy = false;
899 rc = vfdi_ops[req->op](vf);
903 req->op, vf->pci_name);
908 "%llx\n", req->op, vf->pci_name,
909 (unsigned long long)vf->req_addr);
914 vf->busy = false;
923 copy[0].to_rid = vf->pci_rid;
924 copy[0].to_addr = vf->req_addr + offsetof(struct vfdi_req, rc);
927 copy[1].to_rid = vf->pci_rid;
928 copy[1].to_addr = vf->req_addr + offsetof(struct vfdi_req, op);
941 static void efx_siena_sriov_reset_vf(struct siena_vf *vf,
944 struct efx_nic *efx = vf->efx;
954 if (!vf->evq0_count)
956 BUG_ON(vf->evq0_count & (vf->evq0_count - 1));
958 mutex_lock(&vf->status_lock);
961 VFDI_EV_SEQ, vf->msg_seqno,
963 vf->msg_seqno++;
967 for (pos = 0; pos < vf->evq0_count; pos += count) {
968 count = min_t(unsigned, vf->evq0_count - pos,
974 copy_req[k].to_rid = vf->pci_rid;
975 copy_req[k].to_addr = vf->evq0_addrs[pos + k];
983 ": %d\n", vf->pci_name, -rc);
989 abs_evq = abs_index(vf, 0);
990 buftbl = EFX_BUFTBL_EVQ_BASE(vf, 0);
991 efx_siena_sriov_bufs(efx, buftbl, vf->evq0_addrs, vf->evq0_count);
1000 FRF_AZ_EVQ_SIZE, __ffs(vf->evq0_count),
1006 mutex_unlock(&vf->status_lock);
1011 struct siena_vf *vf = container_of(work, struct siena_vf, req);
1012 struct efx_nic *efx = vf->efx;
1016 efx_siena_sriov_reset_vf(vf, &buf);
1084 struct siena_vf *vf;
1106 vf = nic_data->vf + pos;
1108 mutex_lock(&vf->status_lock);
1109 if (vf->rx_filtering && !is_zero_ether_addr(vf->addr.mac_addr)) {
1110 *peer++ = vf->addr;
1115 mutex_unlock(&vf->status_lock);
1162 vf = nic_data->vf + pos;
1164 mutex_lock(&vf->status_lock);
1165 if (vf->status_addr)
1166 __efx_siena_sriov_push_vf_status(vf);
1167 mutex_unlock(&vf->status_lock);
1197 struct siena_vf *vf;
1200 nic_data->vf = kcalloc(efx->vf_count, sizeof(*nic_data->vf),
1202 if (!nic_data->vf)
1206 vf = nic_data->vf + index;
1208 vf->efx = efx;
1209 vf->index = index;
1210 vf->rx_filter_id = -1;
1211 vf->tx_filter_mode = VF_TX_FILTER_AUTO;
1212 vf->tx_filter_id = -1;
1213 INIT_WORK(&vf->req, efx_siena_sriov_vfdi);
1214 INIT_WORK(&vf->reset_work, efx_siena_sriov_reset_vf_work);
1215 init_waitqueue_head(&vf->flush_waitq);
1216 mutex_init(&vf->status_lock);
1217 mutex_init(&vf->txq_lock);
1226 struct siena_vf *vf;
1230 vf = nic_data->vf + pos;
1232 efx_siena_free_buffer(efx, &vf->buf);
1233 kfree(vf->peer_page_addrs);
1234 vf->peer_page_addrs = NULL;
1235 vf->peer_page_count = 0;
1237 vf->evq0_count = 0;
1247 struct siena_vf *vf;
1260 vf = nic_data->vf + index;
1263 vf->buftbl_base = buftbl_base;
1266 vf->pci_rid = devfn;
1267 snprintf(vf->pci_name, sizeof(vf->pci_name),
1272 rc = efx_siena_alloc_buffer(efx, &vf->buf, EFX_PAGE_SIZE,
1360 kfree(nic_data->vf);
1371 struct siena_vf *vf;
1387 vf = nic_data->vf + pos;
1388 cancel_work_sync(&vf->req);
1389 cancel_work_sync(&vf->reset_work);
1398 kfree(nic_data->vf);
1406 struct siena_vf *vf;
1421 if (map_vi_index(efx, qid, &vf, NULL))
1423 if (vf->busy)
1428 vf->req_type = VFDI_EV_TYPE_REQ_WORD0;
1429 vf->req_seqno = seq + 1;
1430 vf->req_addr = 0;
1431 } else if (seq != (vf->req_seqno++ & 0xff) || type != vf->req_type)
1434 switch (vf->req_type) {
1438 vf->req_addr |= (u64)data << (vf->req_type << 4);
1439 ++vf->req_type;
1443 vf->req_addr |= (u64)data << 48;
1444 vf->req_type = VFDI_EV_TYPE_REQ_WORD0;
1445 vf->busy = true;
1446 queue_work(vfdi_workqueue, &vf->req);
1454 vf->pci_name);
1456 vf->req_type = VFDI_EV_TYPE_REQ_WORD0;
1457 vf->req_seqno = seq + 1;
1463 struct siena_vf *vf;
1467 vf = nic_data->vf + vf_i;
1469 "FLR on VF %s\n", vf->pci_name);
1471 vf->status_addr = 0;
1472 efx_vfdi_remove_all_filters(vf);
1473 efx_vfdi_flush_clear(vf);
1475 vf->evq0_count = 0;
1494 struct siena_vf *vf;
1498 if (map_vi_index(efx, queue, &vf, &qid))
1501 if (!test_bit(qid, vf->txq_mask))
1504 __clear_bit(qid, vf->txq_mask);
1505 --vf->txq_count;
1507 if (efx_vfdi_flush_wake(vf))
1508 wake_up(&vf->flush_waitq);
1513 struct siena_vf *vf;
1519 if (map_vi_index(efx, queue, &vf, &qid))
1521 if (!test_bit(qid, vf->rxq_mask))
1525 set_bit(qid, vf->rxq_retry_mask);
1526 atomic_inc(&vf->rxq_retry_count);
1528 __clear_bit(qid, vf->rxq_mask);
1529 --vf->rxq_count;
1531 if (efx_vfdi_flush_wake(vf))
1532 wake_up(&vf->flush_waitq);
1538 struct siena_vf *vf;
1541 if (map_vi_index(efx, dmaq, &vf, &rel))
1547 vf->index, rel);
1548 queue_work(vfdi_workqueue, &vf->reset_work);
1557 struct siena_vf *vf;
1571 vf = nic_data->vf + vf_i;
1572 efx_siena_sriov_reset_vf(vf, &buf);
1598 struct siena_vf *vf;
1602 vf = nic_data->vf + vf_i;
1604 mutex_lock(&vf->status_lock);
1605 ether_addr_copy(vf->addr.mac_addr, mac);
1606 __efx_siena_sriov_update_vf_addr(vf);
1607 mutex_unlock(&vf->status_lock);
1616 struct siena_vf *vf;
1621 vf = nic_data->vf + vf_i;
1623 mutex_lock(&vf->status_lock);
1625 vf->addr.tci = htons(tci);
1626 __efx_siena_sriov_update_vf_addr(vf);
1627 mutex_unlock(&vf->status_lock);
1636 struct siena_vf *vf;
1641 vf = nic_data->vf + vf_i;
1643 mutex_lock(&vf->txq_lock);
1644 if (vf->txq_count == 0) {
1645 vf->tx_filter_mode =
1652 mutex_unlock(&vf->txq_lock);
1660 struct siena_vf *vf;
1665 vf = nic_data->vf + vf_i;
1667 ivi->vf = vf_i;
1668 ether_addr_copy(ivi->mac, vf->addr.mac_addr);
1671 tci = ntohs(vf->addr.tci);
1674 ivi->spoofchk = vf->tx_filter_mode == VF_TX_FILTER_ON;