2 * Copyright 2008-2010 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
5 * This program is free software; you may redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
10 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
12 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
13 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
14 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
15 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 #include <linux/kernel.h>
21 #include <linux/errno.h>
22 #include <linux/types.h>
23 #include <linux/pci.h>
24 #include <linux/delay.h>
25 #include <linux/if_ether.h>
27 #include "vnic_resource.h"
28 #include "vnic_devcmd.h"
30 #include "vnic_stats.h"
32 enum vnic_proxy_type {
44 struct vnic_intr_coal_timer_info {
53 struct vnic_res res[RES_TYPE_MAX];
54 enum vnic_dev_intr_mode intr_mode;
55 struct vnic_devcmd __iomem *devcmd;
56 struct vnic_devcmd_notify *notify;
57 struct vnic_devcmd_notify notify_copy;
60 dma_addr_t linkstatus_pa;
61 struct vnic_stats *stats;
63 struct vnic_devcmd_fw_info *fw_info;
64 dma_addr_t fw_info_pa;
65 enum vnic_proxy_type proxy;
67 u64 args[VNIC_DEVCMD_NARGS];
68 struct vnic_intr_coal_timer_info intr_coal_timer_info;
71 #define VNIC_MAX_RES_HDR_SIZE \
72 (sizeof(struct vnic_resource_header) + \
73 sizeof(struct vnic_resource) * RES_TYPE_MAX)
74 #define VNIC_RES_STRIDE 128
76 void *vnic_dev_priv(struct vnic_dev *vdev)
81 static int vnic_dev_discover_res(struct vnic_dev *vdev,
82 struct vnic_dev_bar *bar, unsigned int num_bars)
84 struct vnic_resource_header __iomem *rh;
85 struct mgmt_barmap_hdr __iomem *mrh;
86 struct vnic_resource __iomem *r;
92 if (bar->len < VNIC_MAX_RES_HDR_SIZE) {
93 pr_err("vNIC BAR0 res hdr length error\n");
100 pr_err("vNIC BAR0 res hdr not mem-mapped\n");
104 /* Check for mgmt vnic in addition to normal vnic */
105 if ((ioread32(&rh->magic) != VNIC_RES_MAGIC) ||
106 (ioread32(&rh->version) != VNIC_RES_VERSION)) {
107 if ((ioread32(&mrh->magic) != MGMTVNIC_MAGIC) ||
108 (ioread32(&mrh->version) != MGMTVNIC_VERSION)) {
109 pr_err("vNIC BAR0 res magic/version error "
110 "exp (%lx/%lx) or (%lx/%lx), curr (%x/%x)\n",
111 VNIC_RES_MAGIC, VNIC_RES_VERSION,
112 MGMTVNIC_MAGIC, MGMTVNIC_VERSION,
113 ioread32(&rh->magic), ioread32(&rh->version));
118 if (ioread32(&mrh->magic) == MGMTVNIC_MAGIC)
119 r = (struct vnic_resource __iomem *)(mrh + 1);
121 r = (struct vnic_resource __iomem *)(rh + 1);
124 while ((type = ioread8(&r->type)) != RES_TYPE_EOL) {
126 u8 bar_num = ioread8(&r->bar);
127 u32 bar_offset = ioread32(&r->bar_offset);
128 u32 count = ioread32(&r->count);
133 if (bar_num >= num_bars)
136 if (!bar[bar_num].len || !bar[bar_num].vaddr)
143 case RES_TYPE_INTR_CTRL:
144 /* each count is stride bytes long */
145 len = count * VNIC_RES_STRIDE;
146 if (len + bar_offset > bar[bar_num].len) {
147 pr_err("vNIC BAR0 resource %d "
148 "out-of-bounds, offset 0x%x + "
149 "size 0x%x > bar len 0x%lx\n",
156 case RES_TYPE_INTR_PBA_LEGACY:
157 case RES_TYPE_DEVCMD:
164 vdev->res[type].count = count;
165 vdev->res[type].vaddr = (char __iomem *)bar[bar_num].vaddr +
167 vdev->res[type].bus_addr = bar[bar_num].bus_addr + bar_offset;
173 unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev,
174 enum vnic_res_type type)
176 return vdev->res[type].count;
179 void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
182 if (!vdev->res[type].vaddr)
189 case RES_TYPE_INTR_CTRL:
190 return (char __iomem *)vdev->res[type].vaddr +
191 index * VNIC_RES_STRIDE;
193 return (char __iomem *)vdev->res[type].vaddr;
197 static unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
198 unsigned int desc_count, unsigned int desc_size)
200 /* The base address of the desc rings must be 512 byte aligned.
201 * Descriptor count is aligned to groups of 32 descriptors. A
202 * count of 0 means the maximum 4096 descriptors. Descriptor
203 * size is aligned to 16 bytes.
206 unsigned int count_align = 32;
207 unsigned int desc_align = 16;
209 ring->base_align = 512;
214 ring->desc_count = ALIGN(desc_count, count_align);
216 ring->desc_size = ALIGN(desc_size, desc_align);
218 ring->size = ring->desc_count * ring->desc_size;
219 ring->size_unaligned = ring->size + ring->base_align;
221 return ring->size_unaligned;
224 void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring)
226 memset(ring->descs, 0, ring->size);
229 int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring,
230 unsigned int desc_count, unsigned int desc_size)
232 vnic_dev_desc_ring_size(ring, desc_count, desc_size);
234 ring->descs_unaligned = pci_alloc_consistent(vdev->pdev,
235 ring->size_unaligned,
236 &ring->base_addr_unaligned);
238 if (!ring->descs_unaligned) {
239 pr_err("Failed to allocate ring (size=%d), aborting\n",
244 ring->base_addr = ALIGN(ring->base_addr_unaligned,
246 ring->descs = (u8 *)ring->descs_unaligned +
247 (ring->base_addr - ring->base_addr_unaligned);
249 vnic_dev_clear_desc_ring(ring);
251 ring->desc_avail = ring->desc_count - 1;
256 void vnic_dev_free_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring)
259 pci_free_consistent(vdev->pdev,
260 ring->size_unaligned,
261 ring->descs_unaligned,
262 ring->base_addr_unaligned);
267 static int _vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
270 struct vnic_devcmd __iomem *devcmd = vdev->devcmd;
276 status = ioread32(&devcmd->status);
277 if (status == 0xFFFFFFFF) {
278 /* PCI-e target device is gone */
281 if (status & STAT_BUSY) {
282 pr_err("Busy devcmd %d\n", _CMD_N(cmd));
286 if (_CMD_DIR(cmd) & _CMD_DIR_WRITE) {
287 for (i = 0; i < VNIC_DEVCMD_NARGS; i++)
288 writeq(vdev->args[i], &devcmd->args[i]);
292 iowrite32(cmd, &devcmd->cmd);
294 if ((_CMD_FLAGS(cmd) & _CMD_FLAGS_NOWAIT))
297 for (delay = 0; delay < wait; delay++) {
301 status = ioread32(&devcmd->status);
302 if (status == 0xFFFFFFFF) {
303 /* PCI-e target device is gone */
307 if (!(status & STAT_BUSY)) {
309 if (status & STAT_ERROR) {
310 err = (int)readq(&devcmd->args[0]);
311 if (err != ERR_ECMDUNKNOWN ||
312 cmd != CMD_CAPABILITY)
313 pr_err("Error %d devcmd %d\n",
318 if (_CMD_DIR(cmd) & _CMD_DIR_READ) {
320 for (i = 0; i < VNIC_DEVCMD_NARGS; i++)
321 vdev->args[i] = readq(&devcmd->args[i]);
328 pr_err("Timedout devcmd %d\n", _CMD_N(cmd));
332 static int vnic_dev_cmd_proxy(struct vnic_dev *vdev,
333 enum vnic_devcmd_cmd proxy_cmd, enum vnic_devcmd_cmd cmd,
334 u64 *a0, u64 *a1, int wait)
339 memset(vdev->args, 0, sizeof(vdev->args));
341 vdev->args[0] = vdev->proxy_index;
346 err = _vnic_dev_cmd(vdev, proxy_cmd, wait);
350 status = (u32)vdev->args[0];
351 if (status & STAT_ERROR) {
352 err = (int)vdev->args[1];
353 if (err != ERR_ECMDUNKNOWN ||
354 cmd != CMD_CAPABILITY)
355 pr_err("Error %d proxy devcmd %d\n", err, _CMD_N(cmd));
365 static int vnic_dev_cmd_no_proxy(struct vnic_dev *vdev,
366 enum vnic_devcmd_cmd cmd, u64 *a0, u64 *a1, int wait)
373 err = _vnic_dev_cmd(vdev, cmd, wait);
381 void vnic_dev_cmd_proxy_by_index_start(struct vnic_dev *vdev, u16 index)
383 vdev->proxy = PROXY_BY_INDEX;
384 vdev->proxy_index = index;
387 void vnic_dev_cmd_proxy_end(struct vnic_dev *vdev)
389 vdev->proxy = PROXY_NONE;
390 vdev->proxy_index = 0;
393 int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
394 u64 *a0, u64 *a1, int wait)
396 memset(vdev->args, 0, sizeof(vdev->args));
398 switch (vdev->proxy) {
400 return vnic_dev_cmd_proxy(vdev, CMD_PROXY_BY_INDEX, cmd,
403 return vnic_dev_cmd_proxy(vdev, CMD_PROXY_BY_BDF, cmd,
407 return vnic_dev_cmd_no_proxy(vdev, cmd, a0, a1, wait);
411 static int vnic_dev_capable(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd)
413 u64 a0 = (u32)cmd, a1 = 0;
417 err = vnic_dev_cmd(vdev, CMD_CAPABILITY, &a0, &a1, wait);
422 int vnic_dev_fw_info(struct vnic_dev *vdev,
423 struct vnic_devcmd_fw_info **fw_info)
429 if (!vdev->fw_info) {
430 vdev->fw_info = pci_alloc_consistent(vdev->pdev,
431 sizeof(struct vnic_devcmd_fw_info),
436 memset(vdev->fw_info, 0, sizeof(struct vnic_devcmd_fw_info));
438 a0 = vdev->fw_info_pa;
439 a1 = sizeof(struct vnic_devcmd_fw_info);
441 /* only get fw_info once and cache it */
442 if (vnic_dev_capable(vdev, CMD_MCPU_FW_INFO))
443 err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO,
446 err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO_OLD,
450 *fw_info = vdev->fw_info;
455 int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, unsigned int size,
465 err = vnic_dev_cmd(vdev, CMD_DEV_SPEC, &a0, &a1, wait);
468 case 1: *(u8 *)value = (u8)a0; break;
469 case 2: *(u16 *)value = (u16)a0; break;
470 case 4: *(u32 *)value = (u32)a0; break;
471 case 8: *(u64 *)value = a0; break;
472 default: BUG(); break;
478 int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats)
484 vdev->stats = pci_alloc_consistent(vdev->pdev,
485 sizeof(struct vnic_stats), &vdev->stats_pa);
490 *stats = vdev->stats;
492 a1 = sizeof(struct vnic_stats);
494 return vnic_dev_cmd(vdev, CMD_STATS_DUMP, &a0, &a1, wait);
497 int vnic_dev_close(struct vnic_dev *vdev)
501 return vnic_dev_cmd(vdev, CMD_CLOSE, &a0, &a1, wait);
504 int vnic_dev_enable_wait(struct vnic_dev *vdev)
509 if (vnic_dev_capable(vdev, CMD_ENABLE_WAIT))
510 return vnic_dev_cmd(vdev, CMD_ENABLE_WAIT, &a0, &a1, wait);
512 return vnic_dev_cmd(vdev, CMD_ENABLE, &a0, &a1, wait);
515 int vnic_dev_disable(struct vnic_dev *vdev)
519 return vnic_dev_cmd(vdev, CMD_DISABLE, &a0, &a1, wait);
522 int vnic_dev_open(struct vnic_dev *vdev, int arg)
524 u64 a0 = (u32)arg, a1 = 0;
526 return vnic_dev_cmd(vdev, CMD_OPEN, &a0, &a1, wait);
529 int vnic_dev_open_done(struct vnic_dev *vdev, int *done)
537 err = vnic_dev_cmd(vdev, CMD_OPEN_STATUS, &a0, &a1, wait);
546 static int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg)
548 u64 a0 = (u32)arg, a1 = 0;
550 return vnic_dev_cmd(vdev, CMD_SOFT_RESET, &a0, &a1, wait);
553 static int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done)
561 err = vnic_dev_cmd(vdev, CMD_SOFT_RESET_STATUS, &a0, &a1, wait);
570 int vnic_dev_hang_reset(struct vnic_dev *vdev, int arg)
572 u64 a0 = (u32)arg, a1 = 0;
576 if (vnic_dev_capable(vdev, CMD_HANG_RESET)) {
577 return vnic_dev_cmd(vdev, CMD_HANG_RESET,
580 err = vnic_dev_soft_reset(vdev, arg);
583 return vnic_dev_init(vdev, 0);
587 int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done)
595 if (vnic_dev_capable(vdev, CMD_HANG_RESET_STATUS)) {
596 err = vnic_dev_cmd(vdev, CMD_HANG_RESET_STATUS,
601 return vnic_dev_soft_reset_done(vdev, done);
609 int vnic_dev_hang_notify(struct vnic_dev *vdev)
613 return vnic_dev_cmd(vdev, CMD_HANG_NOTIFY, &a0, &a1, wait);
616 int vnic_dev_get_mac_addr(struct vnic_dev *vdev, u8 *mac_addr)
622 for (i = 0; i < ETH_ALEN; i++)
625 err = vnic_dev_cmd(vdev, CMD_GET_MAC_ADDR, &a0, &a1, wait);
629 for (i = 0; i < ETH_ALEN; i++)
630 mac_addr[i] = ((u8 *)&a0)[i];
635 int vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast,
636 int broadcast, int promisc, int allmulti)
642 a0 = (directed ? CMD_PFILTER_DIRECTED : 0) |
643 (multicast ? CMD_PFILTER_MULTICAST : 0) |
644 (broadcast ? CMD_PFILTER_BROADCAST : 0) |
645 (promisc ? CMD_PFILTER_PROMISCUOUS : 0) |
646 (allmulti ? CMD_PFILTER_ALL_MULTICAST : 0);
648 err = vnic_dev_cmd(vdev, CMD_PACKET_FILTER, &a0, &a1, wait);
650 pr_err("Can't set packet filter\n");
655 int vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr)
662 for (i = 0; i < ETH_ALEN; i++)
663 ((u8 *)&a0)[i] = addr[i];
665 err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, &a0, &a1, wait);
667 pr_err("Can't add addr [%pM], %d\n", addr, err);
672 int vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
679 for (i = 0; i < ETH_ALEN; i++)
680 ((u8 *)&a0)[i] = addr[i];
682 err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, &a0, &a1, wait);
684 pr_err("Can't del addr [%pM], %d\n", addr, err);
689 int vnic_dev_set_ig_vlan_rewrite_mode(struct vnic_dev *vdev,
690 u8 ig_vlan_rewrite_mode)
692 u64 a0 = ig_vlan_rewrite_mode, a1 = 0;
695 if (vnic_dev_capable(vdev, CMD_IG_VLAN_REWRITE_MODE))
696 return vnic_dev_cmd(vdev, CMD_IG_VLAN_REWRITE_MODE,
702 static int vnic_dev_notify_setcmd(struct vnic_dev *vdev,
703 void *notify_addr, dma_addr_t notify_pa, u16 intr)
709 memset(notify_addr, 0, sizeof(struct vnic_devcmd_notify));
710 vdev->notify = notify_addr;
711 vdev->notify_pa = notify_pa;
714 a1 = ((u64)intr << 32) & 0x0000ffff00000000ULL;
715 a1 += sizeof(struct vnic_devcmd_notify);
717 r = vnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait);
718 vdev->notify_sz = (r == 0) ? (u32)a1 : 0;
722 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
725 dma_addr_t notify_pa;
727 if (vdev->notify || vdev->notify_pa) {
728 pr_err("notify block %p still allocated", vdev->notify);
732 notify_addr = pci_alloc_consistent(vdev->pdev,
733 sizeof(struct vnic_devcmd_notify),
738 return vnic_dev_notify_setcmd(vdev, notify_addr, notify_pa, intr);
741 static int vnic_dev_notify_unsetcmd(struct vnic_dev *vdev)
747 a0 = 0; /* paddr = 0 to unset notify buffer */
748 a1 = 0x0000ffff00000000ULL; /* intr num = -1 to unreg for intr */
749 a1 += sizeof(struct vnic_devcmd_notify);
751 err = vnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait);
759 int vnic_dev_notify_unset(struct vnic_dev *vdev)
762 pci_free_consistent(vdev->pdev,
763 sizeof(struct vnic_devcmd_notify),
768 return vnic_dev_notify_unsetcmd(vdev);
771 static int vnic_dev_notify_ready(struct vnic_dev *vdev)
774 unsigned int nwords = vdev->notify_sz / 4;
778 if (!vdev->notify || !vdev->notify_sz)
783 memcpy(&vdev->notify_copy, vdev->notify, vdev->notify_sz);
784 words = (u32 *)&vdev->notify_copy;
785 for (i = 1; i < nwords; i++)
787 } while (csum != words[0]);
792 int vnic_dev_init(struct vnic_dev *vdev, int arg)
794 u64 a0 = (u32)arg, a1 = 0;
798 if (vnic_dev_capable(vdev, CMD_INIT))
799 r = vnic_dev_cmd(vdev, CMD_INIT, &a0, &a1, wait);
801 vnic_dev_cmd(vdev, CMD_INIT_v1, &a0, &a1, wait);
802 if (a0 & CMD_INITF_DEFAULT_MAC) {
803 /* Emulate these for old CMD_INIT_v1 which
804 * didn't pass a0 so no CMD_INITF_*.
806 vnic_dev_cmd(vdev, CMD_GET_MAC_ADDR, &a0, &a1, wait);
807 vnic_dev_cmd(vdev, CMD_ADDR_ADD, &a0, &a1, wait);
813 int vnic_dev_deinit(struct vnic_dev *vdev)
818 return vnic_dev_cmd(vdev, CMD_DEINIT, &a0, &a1, wait);
821 void vnic_dev_intr_coal_timer_info_default(struct vnic_dev *vdev)
823 /* Default: hardware intr coal timer is in units of 1.5 usecs */
824 vdev->intr_coal_timer_info.mul = 2;
825 vdev->intr_coal_timer_info.div = 3;
826 vdev->intr_coal_timer_info.max_usec =
827 vnic_dev_intr_coal_timer_hw_to_usec(vdev, 0xffff);
830 int vnic_dev_intr_coal_timer_info(struct vnic_dev *vdev)
835 memset(vdev->args, 0, sizeof(vdev->args));
837 if (vnic_dev_capable(vdev, CMD_INTR_COAL_CONVERT))
838 err = _vnic_dev_cmd(vdev, CMD_INTR_COAL_CONVERT, wait);
840 err = ERR_ECMDUNKNOWN;
842 /* Use defaults when firmware doesn't support the devcmd at all or
843 * supports it for only specific hardware
845 if ((err == ERR_ECMDUNKNOWN) ||
846 (!err && !(vdev->args[0] && vdev->args[1] && vdev->args[2]))) {
847 pr_warning("Using default conversion factor for "
848 "interrupt coalesce timer\n");
849 vnic_dev_intr_coal_timer_info_default(vdev);
854 vdev->intr_coal_timer_info.mul = (u32) vdev->args[0];
855 vdev->intr_coal_timer_info.div = (u32) vdev->args[1];
856 vdev->intr_coal_timer_info.max_usec = (u32) vdev->args[2];
862 int vnic_dev_link_status(struct vnic_dev *vdev)
864 if (!vnic_dev_notify_ready(vdev))
867 return vdev->notify_copy.link_state;
870 u32 vnic_dev_port_speed(struct vnic_dev *vdev)
872 if (!vnic_dev_notify_ready(vdev))
875 return vdev->notify_copy.port_speed;
878 u32 vnic_dev_msg_lvl(struct vnic_dev *vdev)
880 if (!vnic_dev_notify_ready(vdev))
883 return vdev->notify_copy.msglvl;
886 u32 vnic_dev_mtu(struct vnic_dev *vdev)
888 if (!vnic_dev_notify_ready(vdev))
891 return vdev->notify_copy.mtu;
894 void vnic_dev_set_intr_mode(struct vnic_dev *vdev,
895 enum vnic_dev_intr_mode intr_mode)
897 vdev->intr_mode = intr_mode;
900 enum vnic_dev_intr_mode vnic_dev_get_intr_mode(
901 struct vnic_dev *vdev)
903 return vdev->intr_mode;
906 u32 vnic_dev_intr_coal_timer_usec_to_hw(struct vnic_dev *vdev, u32 usec)
908 return (usec * vdev->intr_coal_timer_info.mul) /
909 vdev->intr_coal_timer_info.div;
912 u32 vnic_dev_intr_coal_timer_hw_to_usec(struct vnic_dev *vdev, u32 hw_cycles)
914 return (hw_cycles * vdev->intr_coal_timer_info.div) /
915 vdev->intr_coal_timer_info.mul;
918 u32 vnic_dev_get_intr_coal_timer_max(struct vnic_dev *vdev)
920 return vdev->intr_coal_timer_info.max_usec;
923 void vnic_dev_unregister(struct vnic_dev *vdev)
927 pci_free_consistent(vdev->pdev,
928 sizeof(struct vnic_devcmd_notify),
932 pci_free_consistent(vdev->pdev,
933 sizeof(struct vnic_stats),
934 vdev->stats, vdev->stats_pa);
936 pci_free_consistent(vdev->pdev,
937 sizeof(struct vnic_devcmd_fw_info),
938 vdev->fw_info, vdev->fw_info_pa);
943 struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
944 void *priv, struct pci_dev *pdev, struct vnic_dev_bar *bar,
945 unsigned int num_bars)
948 vdev = kzalloc(sizeof(struct vnic_dev), GFP_ATOMIC);
956 if (vnic_dev_discover_res(vdev, bar, num_bars))
959 vdev->devcmd = vnic_dev_get_res(vdev, RES_TYPE_DEVCMD, 0);
966 vnic_dev_unregister(vdev);
970 int vnic_dev_init_prov2(struct vnic_dev *vdev, u8 *buf, u32 len)
978 prov_buf = pci_alloc_consistent(vdev->pdev, len, &prov_pa);
982 memcpy(prov_buf, buf, len);
986 ret = vnic_dev_cmd(vdev, CMD_INIT_PROV_INFO2, &a0, &a1, wait);
988 pci_free_consistent(vdev->pdev, len, prov_buf, prov_pa);
993 int vnic_dev_enable2(struct vnic_dev *vdev, int active)
998 a0 = (active ? CMD_ENABLE2_ACTIVE : 0);
1000 return vnic_dev_cmd(vdev, CMD_ENABLE2, &a0, &a1, wait);
1003 static int vnic_dev_cmd_status(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
1006 u64 a0 = cmd, a1 = 0;
1010 ret = vnic_dev_cmd(vdev, CMD_STATUS, &a0, &a1, wait);
1017 int vnic_dev_enable2_done(struct vnic_dev *vdev, int *status)
1019 return vnic_dev_cmd_status(vdev, CMD_ENABLE2, status);
1022 int vnic_dev_deinit_done(struct vnic_dev *vdev, int *status)
1024 return vnic_dev_cmd_status(vdev, CMD_DEINIT, status);
1027 int vnic_dev_set_mac_addr(struct vnic_dev *vdev, u8 *mac_addr)
1033 for (i = 0; i < ETH_ALEN; i++)
1034 ((u8 *)&a0)[i] = mac_addr[i];
1036 return vnic_dev_cmd(vdev, CMD_SET_MAC_ADDR, &a0, &a1, wait);