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;
301 static void efx_siena_sriov_reset_tx_filter(struct siena_vf *vf)
303 struct efx_nic *efx = vf->efx;
308 if (vf->tx_filter_id != -1) {
310 vf->tx_filter_id);
311 netif_dbg(efx, hw, efx->net_dev, "Removed vf %s tx filter %d\n",
312 vf->pci_name, vf->tx_filter_id);
313 vf->tx_filter_id = -1;
316 if (is_zero_ether_addr(vf->addr.mac_addr))
322 if (vf->tx_filter_mode == VF_TX_FILTER_AUTO && vf_max_tx_channels <= 2)
323 vf->tx_filter_mode = VF_TX_FILTER_ON;
325 vlan = ntohs(vf->addr.tci) & VLAN_VID_MASK;
326 efx_filter_init_tx(&filter, abs_index(vf, 0));
329 vf->addr.mac_addr);
335 "Unable to migrate tx filter for vf %s\n",
336 vf->pci_name);
338 netif_dbg(efx, hw, efx->net_dev, "Inserted vf %s tx filter %d\n",
339 vf->pci_name, rc);
340 vf->tx_filter_id = rc;
345 static void efx_siena_sriov_reset_rx_filter(struct siena_vf *vf)
347 struct efx_nic *efx = vf->efx;
352 if (vf->rx_filter_id != -1) {
354 vf->rx_filter_id);
355 netif_dbg(efx, hw, efx->net_dev, "Removed vf %s rx filter %d\n",
356 vf->pci_name, vf->rx_filter_id);
357 vf->rx_filter_id = -1;
360 if (!vf->rx_filtering || is_zero_ether_addr(vf->addr.mac_addr))
363 vlan = ntohs(vf->addr.tci) & VLAN_VID_MASK;
365 vf->rx_filter_flags,
366 abs_index(vf, vf->rx_filter_qid));
369 vf->addr.mac_addr);
375 "Unable to insert rx filter for vf %s\n",
376 vf->pci_name);
378 netif_dbg(efx, hw, efx->net_dev, "Inserted vf %s rx filter %d\n",
379 vf->pci_name, rc);
380 vf->rx_filter_id = rc;
384 static void __efx_siena_sriov_update_vf_addr(struct siena_vf *vf)
386 struct efx_nic *efx = vf->efx;
389 efx_siena_sriov_reset_tx_filter(vf);
390 efx_siena_sriov_reset_rx_filter(vf);
399 static void __efx_siena_sriov_push_vf_status(struct siena_vf *vf)
401 struct efx_nic *efx = vf->efx;
410 WARN_ON(!mutex_is_locked(&vf->status_lock));
411 WARN_ON(!vf->status_addr);
413 status->local = vf->addr;
419 copy[0].to_rid = vf->pci_rid;
420 copy[0].to_addr = vf->status_addr + offsetof(struct vfdi_status,
430 copy[1].to_rid = vf->pci_rid;
431 copy[1].to_addr = vf->status_addr + data_offset;
438 if (count == vf->peer_page_count) {
447 copy[pos].to_rid = vf->pci_rid;
448 copy[pos].to_addr = vf->peer_page_addrs[count];
460 copy[pos].to_rid = vf->pci_rid;
461 copy[pos].to_addr = vf->status_addr + offsetof(struct vfdi_status,
469 VFDI_EV_SEQ, (vf->msg_seqno & 0xff),
471 ++vf->msg_seqno;
473 EFX_VI_BASE + vf->index * efx_vf_size(efx),
523 *vf_out = nic_data->vf + vf_i;
529 static int efx_vfdi_init_evq(struct siena_vf *vf)
531 struct efx_nic *efx = vf->efx;
532 struct vfdi_req *req = vf->buf.addr;
535 unsigned abs_evq = abs_index(vf, vf_evq);
536 unsigned buftbl = EFX_BUFTBL_EVQ_BASE(vf, vf_evq);
544 vf->pci_name, vf_evq, buf_count);
562 memcpy(vf->evq0_addrs, req->u.init_evq.addr,
564 vf->evq0_count = buf_count;
570 static int efx_vfdi_init_rxq(struct siena_vf *vf)
572 struct efx_nic *efx = vf->efx;
573 struct vfdi_req *req = vf->buf.addr;
577 unsigned buftbl = EFX_BUFTBL_RXQ_BASE(vf, vf_rxq);
587 "buf_count %d\n", vf->pci_name, vf_rxq,
591 if (__test_and_set_bit(req->u.init_rxq.index, vf->rxq_mask))
592 ++vf->rxq_count;
598 FRF_AZ_RX_DESCQ_EVQ_ID, abs_index(vf, vf_evq),
606 abs_index(vf, vf_rxq));
611 static int efx_vfdi_init_txq(struct siena_vf *vf)
613 struct efx_nic *efx = vf->efx;
614 struct vfdi_req *req = vf->buf.addr;
618 unsigned buftbl = EFX_BUFTBL_TXQ_BASE(vf, vf_txq);
628 "buf_count %d\n", vf->pci_name, vf_txq,
633 mutex_lock(&vf->txq_lock);
634 if (__test_and_set_bit(req->u.init_txq.index, vf->txq_mask))
635 ++vf->txq_count;
636 mutex_unlock(&vf->txq_lock);
639 eth_filt_en = vf->tx_filter_mode == VF_TX_FILTER_ON;
647 FRF_AZ_TX_DESCQ_EVQ_ID, abs_index(vf, vf_evq),
652 abs_index(vf, vf_txq));
658 static bool efx_vfdi_flush_wake(struct siena_vf *vf)
663 return (!vf->txq_count && !vf->rxq_count) ||
664 atomic_read(&vf->rxq_retry_count);
667 static void efx_vfdi_flush_clear(struct siena_vf *vf)
669 memset(vf->txq_mask, 0, sizeof(vf->txq_mask));
670 vf->txq_count = 0;
671 memset(vf->rxq_mask, 0, sizeof(vf->rxq_mask));
672 vf->rxq_count = 0;
673 memset(vf->rxq_retry_mask, 0, sizeof(vf->rxq_retry_mask));
674 atomic_set(&vf->rxq_retry_count, 0);
677 static int efx_vfdi_fini_all_queues(struct siena_vf *vf)
679 struct efx_nic *efx = vf->efx;
682 unsigned vf_offset = EFX_VI_BASE + vf->index * efx_vf_size(efx);
698 if (test_bit(index, vf->txq_mask)) {
705 if (test_bit(index, vf->rxq_mask)) {
713 atomic_set(&vf->rxq_retry_count, 0);
714 while (timeout && (vf->rxq_count || vf->txq_count)) {
720 timeout = wait_event_timeout(vf->flush_waitq,
721 efx_vfdi_flush_wake(vf),
725 if (test_and_clear_bit(index, vf->rxq_retry_mask)) {
726 atomic_dec(&vf->rxq_retry_count);
751 efx_siena_sriov_bufs(efx, vf->buftbl_base, NULL,
753 efx_vfdi_flush_clear(vf);
755 vf->evq0_count = 0;
760 static int efx_vfdi_insert_filter(struct siena_vf *vf)
762 struct efx_nic *efx = vf->efx;
764 struct vfdi_req *req = vf->buf.addr;
768 if (bad_vf_index(efx, vf_rxq) || vf->rx_filtering) {
772 "flags 0x%x\n", vf->pci_name, vf_rxq,
782 vf->rx_filter_flags = flags;
783 vf->rx_filter_qid = vf_rxq;
784 vf->rx_filtering = true;
786 efx_siena_sriov_reset_rx_filter(vf);
792 static int efx_vfdi_remove_all_filters(struct siena_vf *vf)
794 struct efx_nic *efx = vf->efx;
797 vf->rx_filtering = false;
798 efx_siena_sriov_reset_rx_filter(vf);
804 static int efx_vfdi_set_status_page(struct siena_vf *vf)
806 struct efx_nic *efx = vf->efx;
808 struct vfdi_req *req = vf->buf.addr;
819 vf->pci_name);
824 mutex_lock(&vf->status_lock);
825 vf->status_addr = req->u.set_status_page.dma_addr;
827 kfree(vf->peer_page_addrs);
828 vf->peer_page_addrs = NULL;
829 vf->peer_page_count = 0;
832 vf->peer_page_addrs = kcalloc(page_count, sizeof(u64),
834 if (vf->peer_page_addrs) {
835 memcpy(vf->peer_page_addrs,
838 vf->peer_page_count = page_count;
842 __efx_siena_sriov_push_vf_status(vf);
843 mutex_unlock(&vf->status_lock);
849 static int efx_vfdi_clear_status_page(struct siena_vf *vf)
851 mutex_lock(&vf->status_lock);
852 vf->status_addr = 0;
853 mutex_unlock(&vf->status_lock);
858 typedef int (*efx_vfdi_op_t)(struct siena_vf *vf);
873 struct siena_vf *vf = container_of(work, struct siena_vf, req);
874 struct efx_nic *efx = vf->efx;
875 struct vfdi_req *req = vf->buf.addr;
881 copy[0].from_rid = vf->pci_rid;
882 copy[0].from_addr = vf->req_addr;
884 copy[0].to_addr = vf->buf.dma_addr;
892 vf->pci_name, -rc);
893 vf->busy = false;
898 rc = vfdi_ops[req->op](vf);
902 req->op, vf->pci_name);
907 "%llx\n", req->op, vf->pci_name,
908 (unsigned long long)vf->req_addr);
913 vf->busy = false;
922 copy[0].to_rid = vf->pci_rid;
923 copy[0].to_addr = vf->req_addr + offsetof(struct vfdi_req, rc);
926 copy[1].to_rid = vf->pci_rid;
927 copy[1].to_addr = vf->req_addr + offsetof(struct vfdi_req, op);
940 static void efx_siena_sriov_reset_vf(struct siena_vf *vf,
943 struct efx_nic *efx = vf->efx;
953 if (!vf->evq0_count)
955 BUG_ON(vf->evq0_count & (vf->evq0_count - 1));
957 mutex_lock(&vf->status_lock);
960 VFDI_EV_SEQ, vf->msg_seqno,
962 vf->msg_seqno++;
966 for (pos = 0; pos < vf->evq0_count; pos += count) {
967 count = min_t(unsigned, vf->evq0_count - pos,
973 copy_req[k].to_rid = vf->pci_rid;
974 copy_req[k].to_addr = vf->evq0_addrs[pos + k];
982 ": %d\n", vf->pci_name, -rc);
988 abs_evq = abs_index(vf, 0);
989 buftbl = EFX_BUFTBL_EVQ_BASE(vf, 0);
990 efx_siena_sriov_bufs(efx, buftbl, vf->evq0_addrs, vf->evq0_count);
999 FRF_AZ_EVQ_SIZE, __ffs(vf->evq0_count),
1005 mutex_unlock(&vf->status_lock);
1010 struct siena_vf *vf = container_of(work, struct siena_vf, req);
1011 struct efx_nic *efx = vf->efx;
1015 efx_siena_sriov_reset_vf(vf, &buf);
1083 struct siena_vf *vf;
1105 vf = nic_data->vf + pos;
1107 mutex_lock(&vf->status_lock);
1108 if (vf->rx_filtering && !is_zero_ether_addr(vf->addr.mac_addr)) {
1109 *peer++ = vf->addr;
1114 mutex_unlock(&vf->status_lock);
1161 vf = nic_data->vf + pos;
1163 mutex_lock(&vf->status_lock);
1164 if (vf->status_addr)
1165 __efx_siena_sriov_push_vf_status(vf);
1166 mutex_unlock(&vf->status_lock);
1196 struct siena_vf *vf;
1199 nic_data->vf = kcalloc(efx->vf_count, sizeof(*nic_data->vf),
1201 if (!nic_data->vf)
1205 vf = nic_data->vf + index;
1207 vf->efx = efx;
1208 vf->index = index;
1209 vf->rx_filter_id = -1;
1210 vf->tx_filter_mode = VF_TX_FILTER_AUTO;
1211 vf->tx_filter_id = -1;
1212 INIT_WORK(&vf->req, efx_siena_sriov_vfdi);
1213 INIT_WORK(&vf->reset_work, efx_siena_sriov_reset_vf_work);
1214 init_waitqueue_head(&vf->flush_waitq);
1215 mutex_init(&vf->status_lock);
1216 mutex_init(&vf->txq_lock);
1225 struct siena_vf *vf;
1229 vf = nic_data->vf + pos;
1231 efx_nic_free_buffer(efx, &vf->buf);
1232 kfree(vf->peer_page_addrs);
1233 vf->peer_page_addrs = NULL;
1234 vf->peer_page_count = 0;
1236 vf->evq0_count = 0;
1246 struct siena_vf *vf;
1259 vf = nic_data->vf + index;
1262 vf->buftbl_base = buftbl_base;
1265 vf->pci_rid = devfn;
1266 snprintf(vf->pci_name, sizeof(vf->pci_name),
1271 rc = efx_nic_alloc_buffer(efx, &vf->buf, EFX_PAGE_SIZE,
1359 kfree(nic_data->vf);
1370 struct siena_vf *vf;
1386 vf = nic_data->vf + pos;
1387 cancel_work_sync(&vf->req);
1388 cancel_work_sync(&vf->reset_work);
1397 kfree(nic_data->vf);
1405 struct siena_vf *vf;
1420 if (map_vi_index(efx, qid, &vf, NULL))
1422 if (vf->busy)
1427 vf->req_type = VFDI_EV_TYPE_REQ_WORD0;
1428 vf->req_seqno = seq + 1;
1429 vf->req_addr = 0;
1430 } else if (seq != (vf->req_seqno++ & 0xff) || type != vf->req_type)
1433 switch (vf->req_type) {
1437 vf->req_addr |= (u64)data << (vf->req_type << 4);
1438 ++vf->req_type;
1442 vf->req_addr |= (u64)data << 48;
1443 vf->req_type = VFDI_EV_TYPE_REQ_WORD0;
1444 vf->busy = true;
1445 queue_work(vfdi_workqueue, &vf->req);
1453 vf->pci_name);
1455 vf->req_type = VFDI_EV_TYPE_REQ_WORD0;
1456 vf->req_seqno = seq + 1;
1462 struct siena_vf *vf;
1466 vf = nic_data->vf + vf_i;
1468 "FLR on VF %s\n", vf->pci_name);
1470 vf->status_addr = 0;
1471 efx_vfdi_remove_all_filters(vf);
1472 efx_vfdi_flush_clear(vf);
1474 vf->evq0_count = 0;
1493 struct siena_vf *vf;
1497 if (map_vi_index(efx, queue, &vf, &qid))
1500 if (!test_bit(qid, vf->txq_mask))
1503 __clear_bit(qid, vf->txq_mask);
1504 --vf->txq_count;
1506 if (efx_vfdi_flush_wake(vf))
1507 wake_up(&vf->flush_waitq);
1512 struct siena_vf *vf;
1518 if (map_vi_index(efx, queue, &vf, &qid))
1520 if (!test_bit(qid, vf->rxq_mask))
1524 set_bit(qid, vf->rxq_retry_mask);
1525 atomic_inc(&vf->rxq_retry_count);
1527 __clear_bit(qid, vf->rxq_mask);
1528 --vf->rxq_count;
1530 if (efx_vfdi_flush_wake(vf))
1531 wake_up(&vf->flush_waitq);
1537 struct siena_vf *vf;
1540 if (map_vi_index(efx, dmaq, &vf, &rel))
1546 vf->index, rel);
1547 queue_work(vfdi_workqueue, &vf->reset_work);
1556 struct siena_vf *vf;
1570 vf = nic_data->vf + vf_i;
1571 efx_siena_sriov_reset_vf(vf, &buf);
1597 struct siena_vf *vf;
1601 vf = nic_data->vf + vf_i;
1603 mutex_lock(&vf->status_lock);
1604 ether_addr_copy(vf->addr.mac_addr, mac);
1605 __efx_siena_sriov_update_vf_addr(vf);
1606 mutex_unlock(&vf->status_lock);
1615 struct siena_vf *vf;
1620 vf = nic_data->vf + vf_i;
1622 mutex_lock(&vf->status_lock);
1624 vf->addr.tci = htons(tci);
1625 __efx_siena_sriov_update_vf_addr(vf);
1626 mutex_unlock(&vf->status_lock);
1635 struct siena_vf *vf;
1640 vf = nic_data->vf + vf_i;
1642 mutex_lock(&vf->txq_lock);
1643 if (vf->txq_count == 0) {
1644 vf->tx_filter_mode =
1651 mutex_unlock(&vf->txq_lock);
1659 struct siena_vf *vf;
1664 vf = nic_data->vf + vf_i;
1666 ivi->vf = vf_i;
1667 ether_addr_copy(ivi->mac, vf->addr.mac_addr);
1670 tci = ntohs(vf->addr.tci);
1673 ivi->spoofchk = vf->tx_filter_mode == VF_TX_FILTER_ON;