Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Copyright 2008 Cisco Systems, Inc.  All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * This program is free software; you may redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * it under the terms of the GNU General Public License as published by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * the Free Software Foundation; version 2 of the License.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include "wq_enet_desc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "rq_enet_desc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include "cq_enet_desc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include "vnic_resource.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include "vnic_dev.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include "vnic_wq.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include "vnic_rq.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include "vnic_cq.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include "vnic_intr.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include "vnic_stats.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include "vnic_nic.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include "fnic.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) int fnic_get_vnic_config(struct fnic *fnic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	struct vnic_fc_config *c = &fnic->config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define GET_CONFIG(m) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		err = vnic_dev_spec(fnic->vdev, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 				    offsetof(struct vnic_fc_config, m), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 				    sizeof(c->m), &c->m); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		if (err) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 			shost_printk(KERN_ERR, fnic->lport->host, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 				     "Error getting %s, %d\n", #m, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 				     err); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 			return err; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	} while (0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	GET_CONFIG(node_wwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	GET_CONFIG(port_wwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	GET_CONFIG(wq_enet_desc_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	GET_CONFIG(wq_copy_desc_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	GET_CONFIG(rq_desc_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	GET_CONFIG(maxdatafieldsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	GET_CONFIG(ed_tov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	GET_CONFIG(ra_tov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	GET_CONFIG(intr_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	GET_CONFIG(intr_timer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	GET_CONFIG(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	GET_CONFIG(flogi_retries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	GET_CONFIG(flogi_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	GET_CONFIG(plogi_retries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	GET_CONFIG(plogi_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	GET_CONFIG(io_throttle_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	GET_CONFIG(link_down_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	GET_CONFIG(port_down_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	GET_CONFIG(port_down_io_retries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	GET_CONFIG(luns_per_tgt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	c->wq_enet_desc_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		min_t(u32, VNIC_FNIC_WQ_DESCS_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		      max_t(u32, VNIC_FNIC_WQ_DESCS_MIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			    c->wq_enet_desc_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	c->wq_enet_desc_count = ALIGN(c->wq_enet_desc_count, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	c->wq_copy_desc_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		min_t(u32, VNIC_FNIC_WQ_COPY_DESCS_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		      max_t(u32, VNIC_FNIC_WQ_COPY_DESCS_MIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			    c->wq_copy_desc_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	c->wq_copy_desc_count = ALIGN(c->wq_copy_desc_count, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	c->rq_desc_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		min_t(u32, VNIC_FNIC_RQ_DESCS_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		      max_t(u32, VNIC_FNIC_RQ_DESCS_MIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 			    c->rq_desc_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	c->rq_desc_count = ALIGN(c->rq_desc_count, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	c->maxdatafieldsize =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		min_t(u16, VNIC_FNIC_MAXDATAFIELDSIZE_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		      max_t(u16, VNIC_FNIC_MAXDATAFIELDSIZE_MIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			    c->maxdatafieldsize));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	c->ed_tov =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		min_t(u32, VNIC_FNIC_EDTOV_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		      max_t(u32, VNIC_FNIC_EDTOV_MIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 			    c->ed_tov));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	c->ra_tov =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		min_t(u32, VNIC_FNIC_RATOV_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		      max_t(u32, VNIC_FNIC_RATOV_MIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			    c->ra_tov));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	c->flogi_retries =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		min_t(u32, VNIC_FNIC_FLOGI_RETRIES_MAX, c->flogi_retries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	c->flogi_timeout =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		min_t(u32, VNIC_FNIC_FLOGI_TIMEOUT_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		      max_t(u32, VNIC_FNIC_FLOGI_TIMEOUT_MIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			    c->flogi_timeout));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	c->plogi_retries =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		min_t(u32, VNIC_FNIC_PLOGI_RETRIES_MAX, c->plogi_retries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	c->plogi_timeout =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		min_t(u32, VNIC_FNIC_PLOGI_TIMEOUT_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		      max_t(u32, VNIC_FNIC_PLOGI_TIMEOUT_MIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			    c->plogi_timeout));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	c->io_throttle_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		min_t(u32, VNIC_FNIC_IO_THROTTLE_COUNT_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		      max_t(u32, VNIC_FNIC_IO_THROTTLE_COUNT_MIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 			    c->io_throttle_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	c->link_down_timeout =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		min_t(u32, VNIC_FNIC_LINK_DOWN_TIMEOUT_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		      c->link_down_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	c->port_down_timeout =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		min_t(u32, VNIC_FNIC_PORT_DOWN_TIMEOUT_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		      c->port_down_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	c->port_down_io_retries =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		min_t(u32, VNIC_FNIC_PORT_DOWN_IO_RETRIES_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		      c->port_down_io_retries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	c->luns_per_tgt =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		min_t(u32, VNIC_FNIC_LUNS_PER_TARGET_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		      max_t(u32, VNIC_FNIC_LUNS_PER_TARGET_MIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 			    c->luns_per_tgt));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	c->intr_timer = min_t(u16, VNIC_INTR_TIMER_MAX, c->intr_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	c->intr_timer_type = c->intr_timer_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	shost_printk(KERN_INFO, fnic->lport->host,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		     "vNIC MAC addr %pM "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		     "wq/wq_copy/rq %d/%d/%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		     fnic->ctlr.ctl_src_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		     c->wq_enet_desc_count, c->wq_copy_desc_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		     c->rq_desc_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	shost_printk(KERN_INFO, fnic->lport->host,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		     "vNIC node wwn %llx port wwn %llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		     c->node_wwn, c->port_wwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	shost_printk(KERN_INFO, fnic->lport->host,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		     "vNIC ed_tov %d ra_tov %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		     c->ed_tov, c->ra_tov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	shost_printk(KERN_INFO, fnic->lport->host,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		     "vNIC mtu %d intr timer %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		     c->maxdatafieldsize, c->intr_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	shost_printk(KERN_INFO, fnic->lport->host,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		     "vNIC flags 0x%x luns per tgt %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		     c->flags, c->luns_per_tgt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	shost_printk(KERN_INFO, fnic->lport->host,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		     "vNIC flogi_retries %d flogi timeout %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		     c->flogi_retries, c->flogi_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	shost_printk(KERN_INFO, fnic->lport->host,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		     "vNIC plogi retries %d plogi timeout %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		     c->plogi_retries, c->plogi_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	shost_printk(KERN_INFO, fnic->lport->host,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		     "vNIC io throttle count %d link dn timeout %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		     c->io_throttle_count, c->link_down_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	shost_printk(KERN_INFO, fnic->lport->host,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		     "vNIC port dn io retries %d port dn timeout %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		     c->port_down_io_retries, c->port_down_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) int fnic_set_nic_config(struct fnic *fnic, u8 rss_default_cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 			u8 rss_hash_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 			u8 rss_hash_bits, u8 rss_base_cpu, u8 rss_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 			u8 tso_ipid_split_en, u8 ig_vlan_strip_en)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	u64 a0, a1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	u32 nic_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	int wait = 1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	vnic_set_nic_cfg(&nic_cfg, rss_default_cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		rss_hash_type, rss_hash_bits, rss_base_cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		rss_enable, tso_ipid_split_en, ig_vlan_strip_en);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	a0 = nic_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	a1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	return vnic_dev_cmd(fnic->vdev, CMD_NIC_CFG, &a0, &a1, wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) void fnic_get_res_counts(struct fnic *fnic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	fnic->wq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_WQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	fnic->raw_wq_count = fnic->wq_count - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	fnic->wq_copy_count = fnic->wq_count - fnic->raw_wq_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	fnic->rq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_RQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	fnic->cq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_CQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	fnic->intr_count = vnic_dev_get_res_count(fnic->vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		RES_TYPE_INTR_CTRL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) void fnic_free_vnic_resources(struct fnic *fnic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	for (i = 0; i < fnic->raw_wq_count; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		vnic_wq_free(&fnic->wq[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	for (i = 0; i < fnic->wq_copy_count; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		vnic_wq_copy_free(&fnic->wq_copy[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	for (i = 0; i < fnic->rq_count; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		vnic_rq_free(&fnic->rq[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	for (i = 0; i < fnic->cq_count; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		vnic_cq_free(&fnic->cq[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	for (i = 0; i < fnic->intr_count; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		vnic_intr_free(&fnic->intr[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) int fnic_alloc_vnic_resources(struct fnic *fnic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	enum vnic_dev_intr_mode intr_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	unsigned int mask_on_assertion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	unsigned int interrupt_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	unsigned int error_interrupt_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	unsigned int error_interrupt_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	unsigned int i, cq_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	unsigned int wq_copy_cq_desc_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	intr_mode = vnic_dev_get_intr_mode(fnic->vdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	shost_printk(KERN_INFO, fnic->lport->host, "vNIC interrupt mode: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		     intr_mode == VNIC_DEV_INTR_MODE_INTX ? "legacy PCI INTx" :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		     intr_mode == VNIC_DEV_INTR_MODE_MSI ? "MSI" :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		     intr_mode == VNIC_DEV_INTR_MODE_MSIX ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		     "MSI-X" : "unknown");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	shost_printk(KERN_INFO, fnic->lport->host, "vNIC resources avail: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		     "wq %d cp_wq %d raw_wq %d rq %d cq %d intr %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		     fnic->wq_count, fnic->wq_copy_count, fnic->raw_wq_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		     fnic->rq_count, fnic->cq_count, fnic->intr_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	/* Allocate Raw WQ used for FCS frames */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	for (i = 0; i < fnic->raw_wq_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		err = vnic_wq_alloc(fnic->vdev, &fnic->wq[i], i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			fnic->config.wq_enet_desc_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 			sizeof(struct wq_enet_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 			goto err_out_cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	/* Allocate Copy WQs used for SCSI IOs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	for (i = 0; i < fnic->wq_copy_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		err = vnic_wq_copy_alloc(fnic->vdev, &fnic->wq_copy[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 			(fnic->raw_wq_count + i),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 			fnic->config.wq_copy_desc_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 			sizeof(struct fcpio_host_req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 			goto err_out_cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	/* RQ for receiving FCS frames */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	for (i = 0; i < fnic->rq_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		err = vnic_rq_alloc(fnic->vdev, &fnic->rq[i], i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 			fnic->config.rq_desc_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 			sizeof(struct rq_enet_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 			goto err_out_cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	/* CQ for each RQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	for (i = 0; i < fnic->rq_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		cq_index = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		err = vnic_cq_alloc(fnic->vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 			&fnic->cq[cq_index], cq_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 			fnic->config.rq_desc_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 			sizeof(struct cq_enet_rq_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 			goto err_out_cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	/* CQ for each WQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	for (i = 0; i < fnic->raw_wq_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		cq_index = fnic->rq_count + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		err = vnic_cq_alloc(fnic->vdev, &fnic->cq[cq_index], cq_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 			fnic->config.wq_enet_desc_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 			sizeof(struct cq_enet_wq_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 			goto err_out_cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	/* CQ for each COPY WQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	wq_copy_cq_desc_count = (fnic->config.wq_copy_desc_count * 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	for (i = 0; i < fnic->wq_copy_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		cq_index = fnic->raw_wq_count + fnic->rq_count + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		err = vnic_cq_alloc(fnic->vdev, &fnic->cq[cq_index],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 			cq_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 			wq_copy_cq_desc_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 			sizeof(struct fcpio_fw_req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 		if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 			goto err_out_cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	for (i = 0; i < fnic->intr_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 		err = vnic_intr_alloc(fnic->vdev, &fnic->intr[i], i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 		if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 			goto err_out_cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	fnic->legacy_pba = vnic_dev_get_res(fnic->vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 				RES_TYPE_INTR_PBA_LEGACY, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	if (!fnic->legacy_pba && intr_mode == VNIC_DEV_INTR_MODE_INTX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		shost_printk(KERN_ERR, fnic->lport->host,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 			     "Failed to hook legacy pba resource\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		err = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 		goto err_out_cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	 * Init RQ/WQ resources.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	 * RQ[0 to n-1] point to CQ[0 to n-1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	 * WQ[0 to m-1] point to CQ[n to n+m-1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	 * WQ_COPY[0 to k-1] points to CQ[n+m to n+m+k-1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	 * Note for copy wq we always initialize with cq_index = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	 * Error interrupt is not enabled for MSI.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	switch (intr_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	case VNIC_DEV_INTR_MODE_INTX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	case VNIC_DEV_INTR_MODE_MSIX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		error_interrupt_enable = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 		error_interrupt_offset = fnic->err_intr_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		error_interrupt_enable = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		error_interrupt_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	for (i = 0; i < fnic->rq_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 		cq_index = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		vnic_rq_init(&fnic->rq[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 			     cq_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 			     error_interrupt_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 			     error_interrupt_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	for (i = 0; i < fnic->raw_wq_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 		cq_index = i + fnic->rq_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		vnic_wq_init(&fnic->wq[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 			     cq_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 			     error_interrupt_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 			     error_interrupt_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	for (i = 0; i < fnic->wq_copy_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		vnic_wq_copy_init(&fnic->wq_copy[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 				  0 /* cq_index 0 - always */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 				  error_interrupt_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 				  error_interrupt_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	for (i = 0; i < fnic->cq_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		switch (intr_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		case VNIC_DEV_INTR_MODE_MSIX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 			interrupt_offset = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 			interrupt_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		vnic_cq_init(&fnic->cq[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 			0 /* flow_control_enable */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 			1 /* color_enable */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 			0 /* cq_head */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 			0 /* cq_tail */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 			1 /* cq_tail_color */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 			1 /* interrupt_enable */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 			1 /* cq_entry_enable */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 			0 /* cq_message_enable */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 			interrupt_offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 			0 /* cq_message_addr */);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	 * Init INTR resources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	 * mask_on_assertion is not used for INTx due to the level-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	 * triggered nature of INTx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	switch (intr_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	case VNIC_DEV_INTR_MODE_MSI:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	case VNIC_DEV_INTR_MODE_MSIX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 		mask_on_assertion = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		mask_on_assertion = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	for (i = 0; i < fnic->intr_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		vnic_intr_init(&fnic->intr[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 			fnic->config.intr_timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 			fnic->config.intr_timer_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 			mask_on_assertion);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	/* init the stats memory by making the first call here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	err = vnic_dev_stats_dump(fnic->vdev, &fnic->stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		shost_printk(KERN_ERR, fnic->lport->host,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 			     "vnic_dev_stats_dump failed - x%x\n", err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 		goto err_out_cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	/* Clear LIF stats */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	vnic_dev_stats_clear(fnic->vdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) err_out_cleanup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	fnic_free_vnic_resources(fnic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) }