bnx2x_vfpf.c 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006
  1. /* bnx2x_vfpf.c: Broadcom Everest network driver.
  2. *
  3. * Copyright 2009-2013 Broadcom Corporation
  4. *
  5. * Unless you and Broadcom execute a separate written software license
  6. * agreement governing use of this software, this software is licensed to you
  7. * under the terms of the GNU General Public License version 2, available
  8. * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
  9. *
  10. * Notwithstanding the above, under no circumstances may you combine this
  11. * software in any way with any other Broadcom software provided under a
  12. * license other than the GPL, without Broadcom's express prior written
  13. * consent.
  14. *
  15. * Maintained by: Eilon Greenstein <eilong@broadcom.com>
  16. * Written by: Shmulik Ravid <shmulikr@broadcom.com>
  17. * Ariel Elior <ariele@broadcom.com>
  18. */
  19. #include "bnx2x.h"
  20. #include "bnx2x_cmn.h"
  21. #include <linux/crc32.h>
  22. /* place a given tlv on the tlv buffer at a given offset */
  23. void bnx2x_add_tlv(struct bnx2x *bp, void *tlvs_list, u16 offset, u16 type,
  24. u16 length)
  25. {
  26. struct channel_tlv *tl =
  27. (struct channel_tlv *)(tlvs_list + offset);
  28. tl->type = type;
  29. tl->length = length;
  30. }
  31. /* Clear the mailbox and init the header of the first tlv */
  32. void bnx2x_vfpf_prep(struct bnx2x *bp, struct vfpf_first_tlv *first_tlv,
  33. u16 type, u16 length)
  34. {
  35. mutex_lock(&bp->vf2pf_mutex);
  36. DP(BNX2X_MSG_IOV, "preparing to send %d tlv over vf pf channel\n",
  37. type);
  38. /* Clear mailbox */
  39. memset(bp->vf2pf_mbox, 0, sizeof(struct bnx2x_vf_mbx_msg));
  40. /* init type and length */
  41. bnx2x_add_tlv(bp, &first_tlv->tl, 0, type, length);
  42. /* init first tlv header */
  43. first_tlv->resp_msg_offset = sizeof(bp->vf2pf_mbox->req);
  44. }
  45. /* releases the mailbox */
  46. void bnx2x_vfpf_finalize(struct bnx2x *bp, struct vfpf_first_tlv *first_tlv)
  47. {
  48. DP(BNX2X_MSG_IOV, "done sending [%d] tlv over vf pf channel\n",
  49. first_tlv->tl.type);
  50. mutex_unlock(&bp->vf2pf_mutex);
  51. }
  52. /* Finds a TLV by type in a TLV buffer; If found, returns pointer to the TLV */
  53. static void *bnx2x_search_tlv_list(struct bnx2x *bp, void *tlvs_list,
  54. enum channel_tlvs req_tlv)
  55. {
  56. struct channel_tlv *tlv = (struct channel_tlv *)tlvs_list;
  57. do {
  58. if (tlv->type == req_tlv)
  59. return tlv;
  60. if (!tlv->length) {
  61. BNX2X_ERR("Found TLV with length 0\n");
  62. return NULL;
  63. }
  64. tlvs_list += tlv->length;
  65. tlv = (struct channel_tlv *)tlvs_list;
  66. } while (tlv->type != CHANNEL_TLV_LIST_END);
  67. DP(BNX2X_MSG_IOV, "TLV list does not contain %d TLV\n", req_tlv);
  68. return NULL;
  69. }
  70. /* list the types and lengths of the tlvs on the buffer */
  71. void bnx2x_dp_tlv_list(struct bnx2x *bp, void *tlvs_list)
  72. {
  73. int i = 1;
  74. struct channel_tlv *tlv = (struct channel_tlv *)tlvs_list;
  75. while (tlv->type != CHANNEL_TLV_LIST_END) {
  76. /* output tlv */
  77. DP(BNX2X_MSG_IOV, "TLV number %d: type %d, length %d\n", i,
  78. tlv->type, tlv->length);
  79. /* advance to next tlv */
  80. tlvs_list += tlv->length;
  81. /* cast general tlv list pointer to channel tlv header*/
  82. tlv = (struct channel_tlv *)tlvs_list;
  83. i++;
  84. /* break condition for this loop */
  85. if (i > MAX_TLVS_IN_LIST) {
  86. WARN(true, "corrupt tlvs");
  87. return;
  88. }
  89. }
  90. /* output last tlv */
  91. DP(BNX2X_MSG_IOV, "TLV number %d: type %d, length %d\n", i,
  92. tlv->type, tlv->length);
  93. }
  94. /* test whether we support a tlv type */
  95. bool bnx2x_tlv_supported(u16 tlvtype)
  96. {
  97. return CHANNEL_TLV_NONE < tlvtype && tlvtype < CHANNEL_TLV_MAX;
  98. }
  99. static inline int bnx2x_pfvf_status_codes(int rc)
  100. {
  101. switch (rc) {
  102. case 0:
  103. return PFVF_STATUS_SUCCESS;
  104. case -ENOMEM:
  105. return PFVF_STATUS_NO_RESOURCE;
  106. default:
  107. return PFVF_STATUS_FAILURE;
  108. }
  109. }
  110. static int bnx2x_send_msg2pf(struct bnx2x *bp, u8 *done, dma_addr_t msg_mapping)
  111. {
  112. struct cstorm_vf_zone_data __iomem *zone_data =
  113. REG_ADDR(bp, PXP_VF_ADDR_CSDM_GLOBAL_START);
  114. int tout = 100, interval = 100; /* wait for 10 seconds */
  115. if (*done) {
  116. BNX2X_ERR("done was non zero before message to pf was sent\n");
  117. WARN_ON(true);
  118. return -EINVAL;
  119. }
  120. /* if PF indicated channel is down avoid sending message. Return success
  121. * so calling flow can continue
  122. */
  123. bnx2x_sample_bulletin(bp);
  124. if (bp->old_bulletin.valid_bitmap & 1 << CHANNEL_DOWN) {
  125. DP(BNX2X_MSG_IOV, "detecting channel down. Aborting message\n");
  126. *done = PFVF_STATUS_SUCCESS;
  127. return 0;
  128. }
  129. /* Write message address */
  130. writel(U64_LO(msg_mapping),
  131. &zone_data->non_trigger.vf_pf_channel.msg_addr_lo);
  132. writel(U64_HI(msg_mapping),
  133. &zone_data->non_trigger.vf_pf_channel.msg_addr_hi);
  134. /* make sure the address is written before FW accesses it */
  135. wmb();
  136. /* Trigger the PF FW */
  137. writeb(1, &zone_data->trigger.vf_pf_channel.addr_valid);
  138. /* Wait for PF to complete */
  139. while ((tout >= 0) && (!*done)) {
  140. msleep(interval);
  141. tout -= 1;
  142. /* progress indicator - HV can take its own sweet time in
  143. * answering VFs...
  144. */
  145. DP_CONT(BNX2X_MSG_IOV, ".");
  146. }
  147. if (!*done) {
  148. BNX2X_ERR("PF response has timed out\n");
  149. return -EAGAIN;
  150. }
  151. DP(BNX2X_MSG_SP, "Got a response from PF\n");
  152. return 0;
  153. }
  154. static int bnx2x_get_vf_id(struct bnx2x *bp, u32 *vf_id)
  155. {
  156. u32 me_reg;
  157. int tout = 10, interval = 100; /* Wait for 1 sec */
  158. do {
  159. /* pxp traps vf read of doorbells and returns me reg value */
  160. me_reg = readl(bp->doorbells);
  161. if (GOOD_ME_REG(me_reg))
  162. break;
  163. msleep(interval);
  164. BNX2X_ERR("Invalid ME register value: 0x%08x\n. Is pf driver up?",
  165. me_reg);
  166. } while (tout-- > 0);
  167. if (!GOOD_ME_REG(me_reg)) {
  168. BNX2X_ERR("Invalid ME register value: 0x%08x\n", me_reg);
  169. return -EINVAL;
  170. }
  171. BNX2X_ERR("valid ME register value: 0x%08x\n", me_reg);
  172. *vf_id = (me_reg & ME_REG_VF_NUM_MASK) >> ME_REG_VF_NUM_SHIFT;
  173. return 0;
  174. }
  175. int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count)
  176. {
  177. int rc = 0, attempts = 0;
  178. struct vfpf_acquire_tlv *req = &bp->vf2pf_mbox->req.acquire;
  179. struct pfvf_acquire_resp_tlv *resp = &bp->vf2pf_mbox->resp.acquire_resp;
  180. struct vfpf_port_phys_id_resp_tlv *phys_port_resp;
  181. u32 vf_id;
  182. bool resources_acquired = false;
  183. /* clear mailbox and prep first tlv */
  184. bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_ACQUIRE, sizeof(*req));
  185. if (bnx2x_get_vf_id(bp, &vf_id)) {
  186. rc = -EAGAIN;
  187. goto out;
  188. }
  189. req->vfdev_info.vf_id = vf_id;
  190. req->vfdev_info.vf_os = 0;
  191. req->resc_request.num_rxqs = rx_count;
  192. req->resc_request.num_txqs = tx_count;
  193. req->resc_request.num_sbs = bp->igu_sb_cnt;
  194. req->resc_request.num_mac_filters = VF_ACQUIRE_MAC_FILTERS;
  195. req->resc_request.num_mc_filters = VF_ACQUIRE_MC_FILTERS;
  196. /* pf 2 vf bulletin board address */
  197. req->bulletin_addr = bp->pf2vf_bulletin_mapping;
  198. /* Request physical port identifier */
  199. bnx2x_add_tlv(bp, req, req->first_tlv.tl.length,
  200. CHANNEL_TLV_PHYS_PORT_ID, sizeof(struct channel_tlv));
  201. /* add list termination tlv */
  202. bnx2x_add_tlv(bp, req,
  203. req->first_tlv.tl.length + sizeof(struct channel_tlv),
  204. CHANNEL_TLV_LIST_END,
  205. sizeof(struct channel_list_end_tlv));
  206. /* output tlvs list */
  207. bnx2x_dp_tlv_list(bp, req);
  208. while (!resources_acquired) {
  209. DP(BNX2X_MSG_SP, "attempting to acquire resources\n");
  210. /* send acquire request */
  211. rc = bnx2x_send_msg2pf(bp,
  212. &resp->hdr.status,
  213. bp->vf2pf_mbox_mapping);
  214. /* PF timeout */
  215. if (rc)
  216. goto out;
  217. /* copy acquire response from buffer to bp */
  218. memcpy(&bp->acquire_resp, resp, sizeof(bp->acquire_resp));
  219. attempts++;
  220. /* test whether the PF accepted our request. If not, humble
  221. * the request and try again.
  222. */
  223. if (bp->acquire_resp.hdr.status == PFVF_STATUS_SUCCESS) {
  224. DP(BNX2X_MSG_SP, "resources acquired\n");
  225. resources_acquired = true;
  226. } else if (bp->acquire_resp.hdr.status ==
  227. PFVF_STATUS_NO_RESOURCE &&
  228. attempts < VF_ACQUIRE_THRESH) {
  229. DP(BNX2X_MSG_SP,
  230. "PF unwilling to fulfill resource request. Try PF recommended amount\n");
  231. /* humble our request */
  232. req->resc_request.num_txqs =
  233. min(req->resc_request.num_txqs,
  234. bp->acquire_resp.resc.num_txqs);
  235. req->resc_request.num_rxqs =
  236. min(req->resc_request.num_rxqs,
  237. bp->acquire_resp.resc.num_rxqs);
  238. req->resc_request.num_sbs =
  239. min(req->resc_request.num_sbs,
  240. bp->acquire_resp.resc.num_sbs);
  241. req->resc_request.num_mac_filters =
  242. min(req->resc_request.num_mac_filters,
  243. bp->acquire_resp.resc.num_mac_filters);
  244. req->resc_request.num_vlan_filters =
  245. min(req->resc_request.num_vlan_filters,
  246. bp->acquire_resp.resc.num_vlan_filters);
  247. req->resc_request.num_mc_filters =
  248. min(req->resc_request.num_mc_filters,
  249. bp->acquire_resp.resc.num_mc_filters);
  250. /* Clear response buffer */
  251. memset(&bp->vf2pf_mbox->resp, 0,
  252. sizeof(union pfvf_tlvs));
  253. } else {
  254. /* PF reports error */
  255. BNX2X_ERR("Failed to get the requested amount of resources: %d. Breaking...\n",
  256. bp->acquire_resp.hdr.status);
  257. rc = -EAGAIN;
  258. goto out;
  259. }
  260. }
  261. /* Retrieve physical port id (if possible) */
  262. phys_port_resp = (struct vfpf_port_phys_id_resp_tlv *)
  263. bnx2x_search_tlv_list(bp, resp,
  264. CHANNEL_TLV_PHYS_PORT_ID);
  265. if (phys_port_resp) {
  266. memcpy(bp->phys_port_id, phys_port_resp->id, ETH_ALEN);
  267. bp->flags |= HAS_PHYS_PORT_ID;
  268. }
  269. /* get HW info */
  270. bp->common.chip_id |= (bp->acquire_resp.pfdev_info.chip_num & 0xffff);
  271. bp->link_params.chip_id = bp->common.chip_id;
  272. bp->db_size = bp->acquire_resp.pfdev_info.db_size;
  273. bp->common.int_block = INT_BLOCK_IGU;
  274. bp->common.chip_port_mode = CHIP_2_PORT_MODE;
  275. bp->igu_dsb_id = -1;
  276. bp->mf_ov = 0;
  277. bp->mf_mode = 0;
  278. bp->common.flash_size = 0;
  279. bp->flags |=
  280. NO_WOL_FLAG | NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG | NO_FCOE_FLAG;
  281. bp->igu_sb_cnt = bp->acquire_resp.resc.num_sbs;
  282. bp->igu_base_sb = bp->acquire_resp.resc.hw_sbs[0].hw_sb_id;
  283. strlcpy(bp->fw_ver, bp->acquire_resp.pfdev_info.fw_ver,
  284. sizeof(bp->fw_ver));
  285. if (is_valid_ether_addr(bp->acquire_resp.resc.current_mac_addr))
  286. memcpy(bp->dev->dev_addr,
  287. bp->acquire_resp.resc.current_mac_addr,
  288. ETH_ALEN);
  289. out:
  290. bnx2x_vfpf_finalize(bp, &req->first_tlv);
  291. return rc;
  292. }
  293. int bnx2x_vfpf_release(struct bnx2x *bp)
  294. {
  295. struct vfpf_release_tlv *req = &bp->vf2pf_mbox->req.release;
  296. struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
  297. u32 rc, vf_id;
  298. /* clear mailbox and prep first tlv */
  299. bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_RELEASE, sizeof(*req));
  300. if (bnx2x_get_vf_id(bp, &vf_id)) {
  301. rc = -EAGAIN;
  302. goto out;
  303. }
  304. req->vf_id = vf_id;
  305. /* add list termination tlv */
  306. bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
  307. sizeof(struct channel_list_end_tlv));
  308. /* output tlvs list */
  309. bnx2x_dp_tlv_list(bp, req);
  310. /* send release request */
  311. rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
  312. if (rc)
  313. /* PF timeout */
  314. goto out;
  315. if (resp->hdr.status == PFVF_STATUS_SUCCESS) {
  316. /* PF released us */
  317. DP(BNX2X_MSG_SP, "vf released\n");
  318. } else {
  319. /* PF reports error */
  320. BNX2X_ERR("PF failed our release request - are we out of sync? Response status: %d\n",
  321. resp->hdr.status);
  322. rc = -EAGAIN;
  323. goto out;
  324. }
  325. out:
  326. bnx2x_vfpf_finalize(bp, &req->first_tlv);
  327. return rc;
  328. }
  329. /* Tell PF about SB addresses */
  330. int bnx2x_vfpf_init(struct bnx2x *bp)
  331. {
  332. struct vfpf_init_tlv *req = &bp->vf2pf_mbox->req.init;
  333. struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
  334. int rc, i;
  335. /* clear mailbox and prep first tlv */
  336. bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_INIT, sizeof(*req));
  337. /* status blocks */
  338. for_each_eth_queue(bp, i)
  339. req->sb_addr[i] = (dma_addr_t)bnx2x_fp(bp, i,
  340. status_blk_mapping);
  341. /* statistics - requests only supports single queue for now */
  342. req->stats_addr = bp->fw_stats_data_mapping +
  343. offsetof(struct bnx2x_fw_stats_data, queue_stats);
  344. req->stats_stride = sizeof(struct per_queue_stats);
  345. /* add list termination tlv */
  346. bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
  347. sizeof(struct channel_list_end_tlv));
  348. /* output tlvs list */
  349. bnx2x_dp_tlv_list(bp, req);
  350. rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
  351. if (rc)
  352. goto out;
  353. if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
  354. BNX2X_ERR("INIT VF failed: %d. Breaking...\n",
  355. resp->hdr.status);
  356. rc = -EAGAIN;
  357. goto out;
  358. }
  359. DP(BNX2X_MSG_SP, "INIT VF Succeeded\n");
  360. out:
  361. bnx2x_vfpf_finalize(bp, &req->first_tlv);
  362. return rc;
  363. }
  364. /* CLOSE VF - opposite to INIT_VF */
  365. void bnx2x_vfpf_close_vf(struct bnx2x *bp)
  366. {
  367. struct vfpf_close_tlv *req = &bp->vf2pf_mbox->req.close;
  368. struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
  369. int i, rc;
  370. u32 vf_id;
  371. /* If we haven't got a valid VF id, there is no sense to
  372. * continue with sending messages
  373. */
  374. if (bnx2x_get_vf_id(bp, &vf_id))
  375. goto free_irq;
  376. /* Close the queues */
  377. for_each_queue(bp, i)
  378. bnx2x_vfpf_teardown_queue(bp, i);
  379. /* remove mac */
  380. bnx2x_vfpf_config_mac(bp, bp->dev->dev_addr, bp->fp->index, false);
  381. /* clear mailbox and prep first tlv */
  382. bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_CLOSE, sizeof(*req));
  383. req->vf_id = vf_id;
  384. /* add list termination tlv */
  385. bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
  386. sizeof(struct channel_list_end_tlv));
  387. /* output tlvs list */
  388. bnx2x_dp_tlv_list(bp, req);
  389. rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
  390. if (rc)
  391. BNX2X_ERR("Sending CLOSE failed. rc was: %d\n", rc);
  392. else if (resp->hdr.status != PFVF_STATUS_SUCCESS)
  393. BNX2X_ERR("Sending CLOSE failed: pf response was %d\n",
  394. resp->hdr.status);
  395. bnx2x_vfpf_finalize(bp, &req->first_tlv);
  396. free_irq:
  397. /* Disable HW interrupts, NAPI */
  398. bnx2x_netif_stop(bp, 0);
  399. /* Delete all NAPI objects */
  400. bnx2x_del_all_napi(bp);
  401. /* Release IRQs */
  402. bnx2x_free_irq(bp);
  403. }
  404. static void bnx2x_leading_vfq_init(struct bnx2x *bp, struct bnx2x_virtf *vf,
  405. struct bnx2x_vf_queue *q)
  406. {
  407. u8 cl_id = vfq_cl_id(vf, q);
  408. u8 func_id = FW_VF_HANDLE(vf->abs_vfid);
  409. /* mac */
  410. bnx2x_init_mac_obj(bp, &q->mac_obj,
  411. cl_id, q->cid, func_id,
  412. bnx2x_vf_sp(bp, vf, mac_rdata),
  413. bnx2x_vf_sp_map(bp, vf, mac_rdata),
  414. BNX2X_FILTER_MAC_PENDING,
  415. &vf->filter_state,
  416. BNX2X_OBJ_TYPE_RX_TX,
  417. &bp->macs_pool);
  418. /* vlan */
  419. bnx2x_init_vlan_obj(bp, &q->vlan_obj,
  420. cl_id, q->cid, func_id,
  421. bnx2x_vf_sp(bp, vf, vlan_rdata),
  422. bnx2x_vf_sp_map(bp, vf, vlan_rdata),
  423. BNX2X_FILTER_VLAN_PENDING,
  424. &vf->filter_state,
  425. BNX2X_OBJ_TYPE_RX_TX,
  426. &bp->vlans_pool);
  427. /* mcast */
  428. bnx2x_init_mcast_obj(bp, &vf->mcast_obj, cl_id,
  429. q->cid, func_id, func_id,
  430. bnx2x_vf_sp(bp, vf, mcast_rdata),
  431. bnx2x_vf_sp_map(bp, vf, mcast_rdata),
  432. BNX2X_FILTER_MCAST_PENDING,
  433. &vf->filter_state,
  434. BNX2X_OBJ_TYPE_RX_TX);
  435. /* rss */
  436. bnx2x_init_rss_config_obj(bp, &vf->rss_conf_obj, cl_id, q->cid,
  437. func_id, func_id,
  438. bnx2x_vf_sp(bp, vf, rss_rdata),
  439. bnx2x_vf_sp_map(bp, vf, rss_rdata),
  440. BNX2X_FILTER_RSS_CONF_PENDING,
  441. &vf->filter_state,
  442. BNX2X_OBJ_TYPE_RX_TX);
  443. vf->leading_rss = cl_id;
  444. q->is_leading = true;
  445. }
  446. /* ask the pf to open a queue for the vf */
  447. int bnx2x_vfpf_setup_q(struct bnx2x *bp, struct bnx2x_fastpath *fp,
  448. bool is_leading)
  449. {
  450. struct vfpf_setup_q_tlv *req = &bp->vf2pf_mbox->req.setup_q;
  451. struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
  452. u8 fp_idx = fp->index;
  453. u16 tpa_agg_size = 0, flags = 0;
  454. int rc;
  455. /* clear mailbox and prep first tlv */
  456. bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_SETUP_Q, sizeof(*req));
  457. /* select tpa mode to request */
  458. if (!fp->disable_tpa) {
  459. flags |= VFPF_QUEUE_FLG_TPA;
  460. flags |= VFPF_QUEUE_FLG_TPA_IPV6;
  461. if (fp->mode == TPA_MODE_GRO)
  462. flags |= VFPF_QUEUE_FLG_TPA_GRO;
  463. tpa_agg_size = TPA_AGG_SIZE;
  464. }
  465. if (is_leading)
  466. flags |= VFPF_QUEUE_FLG_LEADING_RSS;
  467. /* calculate queue flags */
  468. flags |= VFPF_QUEUE_FLG_STATS;
  469. flags |= VFPF_QUEUE_FLG_CACHE_ALIGN;
  470. flags |= VFPF_QUEUE_FLG_VLAN;
  471. DP(NETIF_MSG_IFUP, "vlan removal enabled\n");
  472. /* Common */
  473. req->vf_qid = fp_idx;
  474. req->param_valid = VFPF_RXQ_VALID | VFPF_TXQ_VALID;
  475. /* Rx */
  476. req->rxq.rcq_addr = fp->rx_comp_mapping;
  477. req->rxq.rcq_np_addr = fp->rx_comp_mapping + BCM_PAGE_SIZE;
  478. req->rxq.rxq_addr = fp->rx_desc_mapping;
  479. req->rxq.sge_addr = fp->rx_sge_mapping;
  480. req->rxq.vf_sb = fp_idx;
  481. req->rxq.sb_index = HC_INDEX_ETH_RX_CQ_CONS;
  482. req->rxq.hc_rate = bp->rx_ticks ? 1000000/bp->rx_ticks : 0;
  483. req->rxq.mtu = bp->dev->mtu;
  484. req->rxq.buf_sz = fp->rx_buf_size;
  485. req->rxq.sge_buf_sz = BCM_PAGE_SIZE * PAGES_PER_SGE;
  486. req->rxq.tpa_agg_sz = tpa_agg_size;
  487. req->rxq.max_sge_pkt = SGE_PAGE_ALIGN(bp->dev->mtu) >> SGE_PAGE_SHIFT;
  488. req->rxq.max_sge_pkt = ((req->rxq.max_sge_pkt + PAGES_PER_SGE - 1) &
  489. (~(PAGES_PER_SGE-1))) >> PAGES_PER_SGE_SHIFT;
  490. req->rxq.flags = flags;
  491. req->rxq.drop_flags = 0;
  492. req->rxq.cache_line_log = BNX2X_RX_ALIGN_SHIFT;
  493. req->rxq.stat_id = -1; /* No stats at the moment */
  494. /* Tx */
  495. req->txq.txq_addr = fp->txdata_ptr[FIRST_TX_COS_INDEX]->tx_desc_mapping;
  496. req->txq.vf_sb = fp_idx;
  497. req->txq.sb_index = HC_INDEX_ETH_TX_CQ_CONS_COS0;
  498. req->txq.hc_rate = bp->tx_ticks ? 1000000/bp->tx_ticks : 0;
  499. req->txq.flags = flags;
  500. req->txq.traffic_type = LLFC_TRAFFIC_TYPE_NW;
  501. /* add list termination tlv */
  502. bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
  503. sizeof(struct channel_list_end_tlv));
  504. /* output tlvs list */
  505. bnx2x_dp_tlv_list(bp, req);
  506. rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
  507. if (rc)
  508. BNX2X_ERR("Sending SETUP_Q message for queue[%d] failed!\n",
  509. fp_idx);
  510. if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
  511. BNX2X_ERR("Status of SETUP_Q for queue[%d] is %d\n",
  512. fp_idx, resp->hdr.status);
  513. rc = -EINVAL;
  514. }
  515. bnx2x_vfpf_finalize(bp, &req->first_tlv);
  516. return rc;
  517. }
  518. int bnx2x_vfpf_teardown_queue(struct bnx2x *bp, int qidx)
  519. {
  520. struct vfpf_q_op_tlv *req = &bp->vf2pf_mbox->req.q_op;
  521. struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
  522. int rc;
  523. /* clear mailbox and prep first tlv */
  524. bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_TEARDOWN_Q,
  525. sizeof(*req));
  526. req->vf_qid = qidx;
  527. /* add list termination tlv */
  528. bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
  529. sizeof(struct channel_list_end_tlv));
  530. /* output tlvs list */
  531. bnx2x_dp_tlv_list(bp, req);
  532. rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
  533. if (rc) {
  534. BNX2X_ERR("Sending TEARDOWN for queue %d failed: %d\n", qidx,
  535. rc);
  536. goto out;
  537. }
  538. /* PF failed the transaction */
  539. if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
  540. BNX2X_ERR("TEARDOWN for queue %d failed: %d\n", qidx,
  541. resp->hdr.status);
  542. rc = -EINVAL;
  543. }
  544. out:
  545. bnx2x_vfpf_finalize(bp, &req->first_tlv);
  546. return rc;
  547. }
  548. /* request pf to add a mac for the vf */
  549. int bnx2x_vfpf_config_mac(struct bnx2x *bp, u8 *addr, u8 vf_qid, bool set)
  550. {
  551. struct vfpf_set_q_filters_tlv *req = &bp->vf2pf_mbox->req.set_q_filters;
  552. struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
  553. struct pf_vf_bulletin_content bulletin = bp->pf2vf_bulletin->content;
  554. int rc = 0;
  555. /* clear mailbox and prep first tlv */
  556. bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_SET_Q_FILTERS,
  557. sizeof(*req));
  558. req->flags = VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED;
  559. req->vf_qid = vf_qid;
  560. req->n_mac_vlan_filters = 1;
  561. req->filters[0].flags = VFPF_Q_FILTER_DEST_MAC_VALID;
  562. if (set)
  563. req->filters[0].flags |= VFPF_Q_FILTER_SET_MAC;
  564. /* sample bulletin board for new mac */
  565. bnx2x_sample_bulletin(bp);
  566. /* copy mac from device to request */
  567. memcpy(req->filters[0].mac, addr, ETH_ALEN);
  568. /* add list termination tlv */
  569. bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
  570. sizeof(struct channel_list_end_tlv));
  571. /* output tlvs list */
  572. bnx2x_dp_tlv_list(bp, req);
  573. /* send message to pf */
  574. rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
  575. if (rc) {
  576. BNX2X_ERR("failed to send message to pf. rc was %d\n", rc);
  577. goto out;
  578. }
  579. /* failure may mean PF was configured with a new mac for us */
  580. while (resp->hdr.status == PFVF_STATUS_FAILURE) {
  581. DP(BNX2X_MSG_IOV,
  582. "vfpf SET MAC failed. Check bulletin board for new posts\n");
  583. /* copy mac from bulletin to device */
  584. memcpy(bp->dev->dev_addr, bulletin.mac, ETH_ALEN);
  585. /* check if bulletin board was updated */
  586. if (bnx2x_sample_bulletin(bp) == PFVF_BULLETIN_UPDATED) {
  587. /* copy mac from device to request */
  588. memcpy(req->filters[0].mac, bp->dev->dev_addr,
  589. ETH_ALEN);
  590. /* send message to pf */
  591. rc = bnx2x_send_msg2pf(bp, &resp->hdr.status,
  592. bp->vf2pf_mbox_mapping);
  593. } else {
  594. /* no new info in bulletin */
  595. break;
  596. }
  597. }
  598. if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
  599. BNX2X_ERR("vfpf SET MAC failed: %d\n", resp->hdr.status);
  600. rc = -EINVAL;
  601. }
  602. out:
  603. bnx2x_vfpf_finalize(bp, &req->first_tlv);
  604. return 0;
  605. }
  606. /* request pf to config rss table for vf queues*/
  607. int bnx2x_vfpf_config_rss(struct bnx2x *bp,
  608. struct bnx2x_config_rss_params *params)
  609. {
  610. struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
  611. struct vfpf_rss_tlv *req = &bp->vf2pf_mbox->req.update_rss;
  612. int rc = 0;
  613. /* clear mailbox and prep first tlv */
  614. bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_UPDATE_RSS,
  615. sizeof(*req));
  616. /* add list termination tlv */
  617. bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
  618. sizeof(struct channel_list_end_tlv));
  619. memcpy(req->ind_table, params->ind_table, T_ETH_INDIRECTION_TABLE_SIZE);
  620. memcpy(req->rss_key, params->rss_key, sizeof(params->rss_key));
  621. req->ind_table_size = T_ETH_INDIRECTION_TABLE_SIZE;
  622. req->rss_key_size = T_ETH_RSS_KEY;
  623. req->rss_result_mask = params->rss_result_mask;
  624. /* flags handled individually for backward/forward compatability */
  625. if (params->rss_flags & (1 << BNX2X_RSS_MODE_DISABLED))
  626. req->rss_flags |= VFPF_RSS_MODE_DISABLED;
  627. if (params->rss_flags & (1 << BNX2X_RSS_MODE_REGULAR))
  628. req->rss_flags |= VFPF_RSS_MODE_REGULAR;
  629. if (params->rss_flags & (1 << BNX2X_RSS_SET_SRCH))
  630. req->rss_flags |= VFPF_RSS_SET_SRCH;
  631. if (params->rss_flags & (1 << BNX2X_RSS_IPV4))
  632. req->rss_flags |= VFPF_RSS_IPV4;
  633. if (params->rss_flags & (1 << BNX2X_RSS_IPV4_TCP))
  634. req->rss_flags |= VFPF_RSS_IPV4_TCP;
  635. if (params->rss_flags & (1 << BNX2X_RSS_IPV4_UDP))
  636. req->rss_flags |= VFPF_RSS_IPV4_UDP;
  637. if (params->rss_flags & (1 << BNX2X_RSS_IPV6))
  638. req->rss_flags |= VFPF_RSS_IPV6;
  639. if (params->rss_flags & (1 << BNX2X_RSS_IPV6_TCP))
  640. req->rss_flags |= VFPF_RSS_IPV6_TCP;
  641. if (params->rss_flags & (1 << BNX2X_RSS_IPV6_UDP))
  642. req->rss_flags |= VFPF_RSS_IPV6_UDP;
  643. DP(BNX2X_MSG_IOV, "rss flags %x\n", req->rss_flags);
  644. /* output tlvs list */
  645. bnx2x_dp_tlv_list(bp, req);
  646. /* send message to pf */
  647. rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
  648. if (rc) {
  649. BNX2X_ERR("failed to send message to pf. rc was %d\n", rc);
  650. goto out;
  651. }
  652. if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
  653. BNX2X_ERR("failed to send rss message to PF over Vf PF channel %d\n",
  654. resp->hdr.status);
  655. rc = -EINVAL;
  656. }
  657. out:
  658. bnx2x_vfpf_finalize(bp, &req->first_tlv);
  659. return 0;
  660. }
  661. int bnx2x_vfpf_set_mcast(struct net_device *dev)
  662. {
  663. struct bnx2x *bp = netdev_priv(dev);
  664. struct vfpf_set_q_filters_tlv *req = &bp->vf2pf_mbox->req.set_q_filters;
  665. struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
  666. int rc, i = 0;
  667. struct netdev_hw_addr *ha;
  668. if (bp->state != BNX2X_STATE_OPEN) {
  669. DP(NETIF_MSG_IFUP, "state is %x, returning\n", bp->state);
  670. return -EINVAL;
  671. }
  672. /* clear mailbox and prep first tlv */
  673. bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_SET_Q_FILTERS,
  674. sizeof(*req));
  675. /* Get Rx mode requested */
  676. DP(NETIF_MSG_IFUP, "dev->flags = %x\n", dev->flags);
  677. netdev_for_each_mc_addr(ha, dev) {
  678. DP(NETIF_MSG_IFUP, "Adding mcast MAC: %pM\n",
  679. bnx2x_mc_addr(ha));
  680. memcpy(req->multicast[i], bnx2x_mc_addr(ha), ETH_ALEN);
  681. i++;
  682. }
  683. /* We support four PFVF_MAX_MULTICAST_PER_VF mcast
  684. * addresses tops
  685. */
  686. if (i >= PFVF_MAX_MULTICAST_PER_VF) {
  687. DP(NETIF_MSG_IFUP,
  688. "VF supports not more than %d multicast MAC addresses\n",
  689. PFVF_MAX_MULTICAST_PER_VF);
  690. return -EINVAL;
  691. }
  692. req->n_multicast = i;
  693. req->flags |= VFPF_SET_Q_FILTERS_MULTICAST_CHANGED;
  694. req->vf_qid = 0;
  695. /* add list termination tlv */
  696. bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
  697. sizeof(struct channel_list_end_tlv));
  698. /* output tlvs list */
  699. bnx2x_dp_tlv_list(bp, req);
  700. rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
  701. if (rc) {
  702. BNX2X_ERR("Sending a message failed: %d\n", rc);
  703. goto out;
  704. }
  705. if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
  706. BNX2X_ERR("Set Rx mode/multicast failed: %d\n",
  707. resp->hdr.status);
  708. rc = -EINVAL;
  709. }
  710. out:
  711. bnx2x_vfpf_finalize(bp, &req->first_tlv);
  712. return 0;
  713. }
  714. int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp)
  715. {
  716. int mode = bp->rx_mode;
  717. struct vfpf_set_q_filters_tlv *req = &bp->vf2pf_mbox->req.set_q_filters;
  718. struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
  719. int rc;
  720. /* clear mailbox and prep first tlv */
  721. bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_SET_Q_FILTERS,
  722. sizeof(*req));
  723. DP(NETIF_MSG_IFUP, "Rx mode is %d\n", mode);
  724. switch (mode) {
  725. case BNX2X_RX_MODE_NONE: /* no Rx */
  726. req->rx_mask = VFPF_RX_MASK_ACCEPT_NONE;
  727. break;
  728. case BNX2X_RX_MODE_NORMAL:
  729. req->rx_mask = VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST;
  730. req->rx_mask |= VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST;
  731. req->rx_mask |= VFPF_RX_MASK_ACCEPT_BROADCAST;
  732. break;
  733. case BNX2X_RX_MODE_ALLMULTI:
  734. req->rx_mask = VFPF_RX_MASK_ACCEPT_ALL_MULTICAST;
  735. req->rx_mask |= VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST;
  736. req->rx_mask |= VFPF_RX_MASK_ACCEPT_BROADCAST;
  737. break;
  738. case BNX2X_RX_MODE_PROMISC:
  739. req->rx_mask = VFPF_RX_MASK_ACCEPT_ALL_UNICAST;
  740. req->rx_mask |= VFPF_RX_MASK_ACCEPT_ALL_MULTICAST;
  741. req->rx_mask |= VFPF_RX_MASK_ACCEPT_BROADCAST;
  742. break;
  743. default:
  744. BNX2X_ERR("BAD rx mode (%d)\n", mode);
  745. rc = -EINVAL;
  746. goto out;
  747. }
  748. req->flags |= VFPF_SET_Q_FILTERS_RX_MASK_CHANGED;
  749. req->vf_qid = 0;
  750. /* add list termination tlv */
  751. bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
  752. sizeof(struct channel_list_end_tlv));
  753. /* output tlvs list */
  754. bnx2x_dp_tlv_list(bp, req);
  755. rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
  756. if (rc)
  757. BNX2X_ERR("Sending a message failed: %d\n", rc);
  758. if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
  759. BNX2X_ERR("Set Rx mode failed: %d\n", resp->hdr.status);
  760. rc = -EINVAL;
  761. }
  762. out:
  763. bnx2x_vfpf_finalize(bp, &req->first_tlv);
  764. return rc;
  765. }
  766. /* General service functions */
  767. static void storm_memset_vf_mbx_ack(struct bnx2x *bp, u16 abs_fid)
  768. {
  769. u32 addr = BAR_CSTRORM_INTMEM +
  770. CSTORM_VF_PF_CHANNEL_STATE_OFFSET(abs_fid);
  771. REG_WR8(bp, addr, VF_PF_CHANNEL_STATE_READY);
  772. }
  773. static void storm_memset_vf_mbx_valid(struct bnx2x *bp, u16 abs_fid)
  774. {
  775. u32 addr = BAR_CSTRORM_INTMEM +
  776. CSTORM_VF_PF_CHANNEL_VALID_OFFSET(abs_fid);
  777. REG_WR8(bp, addr, 1);
  778. }
  779. static inline void bnx2x_set_vf_mbxs_valid(struct bnx2x *bp)
  780. {
  781. int i;
  782. for_each_vf(bp, i)
  783. storm_memset_vf_mbx_valid(bp, bnx2x_vf(bp, i, abs_vfid));
  784. }
  785. /* enable vf_pf mailbox (aka vf-pf-channel) */
  786. void bnx2x_vf_enable_mbx(struct bnx2x *bp, u8 abs_vfid)
  787. {
  788. bnx2x_vf_flr_clnup_epilog(bp, abs_vfid);
  789. /* enable the mailbox in the FW */
  790. storm_memset_vf_mbx_ack(bp, abs_vfid);
  791. storm_memset_vf_mbx_valid(bp, abs_vfid);
  792. /* enable the VF access to the mailbox */
  793. bnx2x_vf_enable_access(bp, abs_vfid);
  794. }
  795. /* this works only on !E1h */
  796. static int bnx2x_copy32_vf_dmae(struct bnx2x *bp, u8 from_vf,
  797. dma_addr_t pf_addr, u8 vfid, u32 vf_addr_hi,
  798. u32 vf_addr_lo, u32 len32)
  799. {
  800. struct dmae_command dmae;
  801. if (CHIP_IS_E1x(bp)) {
  802. BNX2X_ERR("Chip revision does not support VFs\n");
  803. return DMAE_NOT_RDY;
  804. }
  805. if (!bp->dmae_ready) {
  806. BNX2X_ERR("DMAE is not ready, can not copy\n");
  807. return DMAE_NOT_RDY;
  808. }
  809. /* set opcode and fixed command fields */
  810. bnx2x_prep_dmae_with_comp(bp, &dmae, DMAE_SRC_PCI, DMAE_DST_PCI);
  811. if (from_vf) {
  812. dmae.opcode_iov = (vfid << DMAE_COMMAND_SRC_VFID_SHIFT) |
  813. (DMAE_SRC_VF << DMAE_COMMAND_SRC_VFPF_SHIFT) |
  814. (DMAE_DST_PF << DMAE_COMMAND_DST_VFPF_SHIFT);
  815. dmae.opcode |= (DMAE_C_DST << DMAE_COMMAND_C_FUNC_SHIFT);
  816. dmae.src_addr_lo = vf_addr_lo;
  817. dmae.src_addr_hi = vf_addr_hi;
  818. dmae.dst_addr_lo = U64_LO(pf_addr);
  819. dmae.dst_addr_hi = U64_HI(pf_addr);
  820. } else {
  821. dmae.opcode_iov = (vfid << DMAE_COMMAND_DST_VFID_SHIFT) |
  822. (DMAE_DST_VF << DMAE_COMMAND_DST_VFPF_SHIFT) |
  823. (DMAE_SRC_PF << DMAE_COMMAND_SRC_VFPF_SHIFT);
  824. dmae.opcode |= (DMAE_C_SRC << DMAE_COMMAND_C_FUNC_SHIFT);
  825. dmae.src_addr_lo = U64_LO(pf_addr);
  826. dmae.src_addr_hi = U64_HI(pf_addr);
  827. dmae.dst_addr_lo = vf_addr_lo;
  828. dmae.dst_addr_hi = vf_addr_hi;
  829. }
  830. dmae.len = len32;
  831. /* issue the command and wait for completion */
  832. return bnx2x_issue_dmae_with_comp(bp, &dmae);
  833. }
  834. static void bnx2x_vf_mbx_resp_single_tlv(struct bnx2x *bp,
  835. struct bnx2x_virtf *vf)
  836. {
  837. struct bnx2x_vf_mbx *mbx = BP_VF_MBX(bp, vf->index);
  838. u16 length, type;
  839. /* prepare response */
  840. type = mbx->first_tlv.tl.type;
  841. length = type == CHANNEL_TLV_ACQUIRE ?
  842. sizeof(struct pfvf_acquire_resp_tlv) :
  843. sizeof(struct pfvf_general_resp_tlv);
  844. bnx2x_add_tlv(bp, &mbx->msg->resp, 0, type, length);
  845. bnx2x_add_tlv(bp, &mbx->msg->resp, length, CHANNEL_TLV_LIST_END,
  846. sizeof(struct channel_list_end_tlv));
  847. }
  848. static void bnx2x_vf_mbx_resp_send_msg(struct bnx2x *bp,
  849. struct bnx2x_virtf *vf)
  850. {
  851. struct bnx2x_vf_mbx *mbx = BP_VF_MBX(bp, vf->index);
  852. struct pfvf_general_resp_tlv *resp = &mbx->msg->resp.general_resp;
  853. dma_addr_t pf_addr;
  854. u64 vf_addr;
  855. int rc;
  856. bnx2x_dp_tlv_list(bp, resp);
  857. DP(BNX2X_MSG_IOV, "mailbox vf address hi 0x%x, lo 0x%x, offset 0x%x\n",
  858. mbx->vf_addr_hi, mbx->vf_addr_lo, mbx->first_tlv.resp_msg_offset);
  859. resp->hdr.status = bnx2x_pfvf_status_codes(vf->op_rc);
  860. /* send response */
  861. vf_addr = HILO_U64(mbx->vf_addr_hi, mbx->vf_addr_lo) +
  862. mbx->first_tlv.resp_msg_offset;
  863. pf_addr = mbx->msg_mapping +
  864. offsetof(struct bnx2x_vf_mbx_msg, resp);
  865. /* Copy the response buffer. The first u64 is written afterwards, as
  866. * the vf is sensitive to the header being written
  867. */
  868. vf_addr += sizeof(u64);
  869. pf_addr += sizeof(u64);
  870. rc = bnx2x_copy32_vf_dmae(bp, false, pf_addr, vf->abs_vfid,
  871. U64_HI(vf_addr),
  872. U64_LO(vf_addr),
  873. (sizeof(union pfvf_tlvs) - sizeof(u64))/4);
  874. if (rc) {
  875. BNX2X_ERR("Failed to copy response body to VF %d\n",
  876. vf->abs_vfid);
  877. goto mbx_error;
  878. }
  879. vf_addr -= sizeof(u64);
  880. pf_addr -= sizeof(u64);
  881. /* ack the FW */
  882. storm_memset_vf_mbx_ack(bp, vf->abs_vfid);
  883. mmiowb();
  884. /* initiate dmae to send the response */
  885. mbx->flags &= ~VF_MSG_INPROCESS;
  886. /* copy the response header including status-done field,
  887. * must be last dmae, must be after FW is acked
  888. */
  889. rc = bnx2x_copy32_vf_dmae(bp, false, pf_addr, vf->abs_vfid,
  890. U64_HI(vf_addr),
  891. U64_LO(vf_addr),
  892. sizeof(u64)/4);
  893. /* unlock channel mutex */
  894. bnx2x_unlock_vf_pf_channel(bp, vf, mbx->first_tlv.tl.type);
  895. if (rc) {
  896. BNX2X_ERR("Failed to copy response status to VF %d\n",
  897. vf->abs_vfid);
  898. goto mbx_error;
  899. }
  900. return;
  901. mbx_error:
  902. bnx2x_vf_release(bp, vf, false); /* non blocking */
  903. }
  904. static void bnx2x_vf_mbx_resp(struct bnx2x *bp,
  905. struct bnx2x_virtf *vf)
  906. {
  907. bnx2x_vf_mbx_resp_single_tlv(bp, vf);
  908. bnx2x_vf_mbx_resp_send_msg(bp, vf);
  909. }
  910. static void bnx2x_vf_mbx_resp_phys_port(struct bnx2x *bp,
  911. struct bnx2x_virtf *vf,
  912. void *buffer,
  913. u16 *offset)
  914. {
  915. struct vfpf_port_phys_id_resp_tlv *port_id;
  916. if (!(bp->flags & HAS_PHYS_PORT_ID))
  917. return;
  918. bnx2x_add_tlv(bp, buffer, *offset, CHANNEL_TLV_PHYS_PORT_ID,
  919. sizeof(struct vfpf_port_phys_id_resp_tlv));
  920. port_id = (struct vfpf_port_phys_id_resp_tlv *)
  921. (((u8 *)buffer) + *offset);
  922. memcpy(port_id->id, bp->phys_port_id, ETH_ALEN);
  923. /* Offset should continue representing the offset to the tail
  924. * of TLV data (outside this function scope)
  925. */
  926. *offset += sizeof(struct vfpf_port_phys_id_resp_tlv);
  927. }
  928. static void bnx2x_vf_mbx_acquire_resp(struct bnx2x *bp, struct bnx2x_virtf *vf,
  929. struct bnx2x_vf_mbx *mbx, int vfop_status)
  930. {
  931. int i;
  932. struct pfvf_acquire_resp_tlv *resp = &mbx->msg->resp.acquire_resp;
  933. struct pf_vf_resc *resc = &resp->resc;
  934. u8 status = bnx2x_pfvf_status_codes(vfop_status);
  935. u16 length;
  936. memset(resp, 0, sizeof(*resp));
  937. /* fill in pfdev info */
  938. resp->pfdev_info.chip_num = bp->common.chip_id;
  939. resp->pfdev_info.db_size = bp->db_size;
  940. resp->pfdev_info.indices_per_sb = HC_SB_MAX_INDICES_E2;
  941. resp->pfdev_info.pf_cap = (PFVF_CAP_RSS |
  942. /* PFVF_CAP_DHC |*/ PFVF_CAP_TPA);
  943. bnx2x_fill_fw_str(bp, resp->pfdev_info.fw_ver,
  944. sizeof(resp->pfdev_info.fw_ver));
  945. if (status == PFVF_STATUS_NO_RESOURCE ||
  946. status == PFVF_STATUS_SUCCESS) {
  947. /* set resources numbers, if status equals NO_RESOURCE these
  948. * are max possible numbers
  949. */
  950. resc->num_rxqs = vf_rxq_count(vf) ? :
  951. bnx2x_vf_max_queue_cnt(bp, vf);
  952. resc->num_txqs = vf_txq_count(vf) ? :
  953. bnx2x_vf_max_queue_cnt(bp, vf);
  954. resc->num_sbs = vf_sb_count(vf);
  955. resc->num_mac_filters = vf_mac_rules_cnt(vf);
  956. resc->num_vlan_filters = vf_vlan_rules_cnt(vf);
  957. resc->num_mc_filters = 0;
  958. if (status == PFVF_STATUS_SUCCESS) {
  959. /* fill in the allocated resources */
  960. struct pf_vf_bulletin_content *bulletin =
  961. BP_VF_BULLETIN(bp, vf->index);
  962. for_each_vfq(vf, i)
  963. resc->hw_qid[i] =
  964. vfq_qzone_id(vf, vfq_get(vf, i));
  965. for_each_vf_sb(vf, i) {
  966. resc->hw_sbs[i].hw_sb_id = vf_igu_sb(vf, i);
  967. resc->hw_sbs[i].sb_qid = vf_hc_qzone(vf, i);
  968. }
  969. /* if a mac has been set for this vf, supply it */
  970. if (bulletin->valid_bitmap & 1 << MAC_ADDR_VALID) {
  971. memcpy(resc->current_mac_addr, bulletin->mac,
  972. ETH_ALEN);
  973. }
  974. }
  975. }
  976. DP(BNX2X_MSG_IOV, "VF[%d] ACQUIRE_RESPONSE: pfdev_info- chip_num=0x%x, db_size=%d, idx_per_sb=%d, pf_cap=0x%x\n"
  977. "resources- n_rxq-%d, n_txq-%d, n_sbs-%d, n_macs-%d, n_vlans-%d, n_mcs-%d, fw_ver: '%s'\n",
  978. vf->abs_vfid,
  979. resp->pfdev_info.chip_num,
  980. resp->pfdev_info.db_size,
  981. resp->pfdev_info.indices_per_sb,
  982. resp->pfdev_info.pf_cap,
  983. resc->num_rxqs,
  984. resc->num_txqs,
  985. resc->num_sbs,
  986. resc->num_mac_filters,
  987. resc->num_vlan_filters,
  988. resc->num_mc_filters,
  989. resp->pfdev_info.fw_ver);
  990. DP_CONT(BNX2X_MSG_IOV, "hw_qids- [ ");
  991. for (i = 0; i < vf_rxq_count(vf); i++)
  992. DP_CONT(BNX2X_MSG_IOV, "%d ", resc->hw_qid[i]);
  993. DP_CONT(BNX2X_MSG_IOV, "], sb_info- [ ");
  994. for (i = 0; i < vf_sb_count(vf); i++)
  995. DP_CONT(BNX2X_MSG_IOV, "%d:%d ",
  996. resc->hw_sbs[i].hw_sb_id,
  997. resc->hw_sbs[i].sb_qid);
  998. DP_CONT(BNX2X_MSG_IOV, "]\n");
  999. /* prepare response */
  1000. length = sizeof(struct pfvf_acquire_resp_tlv);
  1001. bnx2x_add_tlv(bp, &mbx->msg->resp, 0, CHANNEL_TLV_ACQUIRE, length);
  1002. /* Handle possible VF requests for physical port identifiers.
  1003. * 'length' should continue to indicate the offset of the first empty
  1004. * place in the buffer (i.e., where next TLV should be inserted)
  1005. */
  1006. if (bnx2x_search_tlv_list(bp, &mbx->msg->req,
  1007. CHANNEL_TLV_PHYS_PORT_ID))
  1008. bnx2x_vf_mbx_resp_phys_port(bp, vf, &mbx->msg->resp, &length);
  1009. bnx2x_add_tlv(bp, &mbx->msg->resp, length, CHANNEL_TLV_LIST_END,
  1010. sizeof(struct channel_list_end_tlv));
  1011. /* send the response */
  1012. vf->op_rc = vfop_status;
  1013. bnx2x_vf_mbx_resp_send_msg(bp, vf);
  1014. }
  1015. static void bnx2x_vf_mbx_acquire(struct bnx2x *bp, struct bnx2x_virtf *vf,
  1016. struct bnx2x_vf_mbx *mbx)
  1017. {
  1018. int rc;
  1019. struct vfpf_acquire_tlv *acquire = &mbx->msg->req.acquire;
  1020. /* log vfdef info */
  1021. DP(BNX2X_MSG_IOV,
  1022. "VF[%d] ACQUIRE: vfdev_info- vf_id %d, vf_os %d resources- n_rxq-%d, n_txq-%d, n_sbs-%d, n_macs-%d, n_vlans-%d, n_mcs-%d\n",
  1023. vf->abs_vfid, acquire->vfdev_info.vf_id, acquire->vfdev_info.vf_os,
  1024. acquire->resc_request.num_rxqs, acquire->resc_request.num_txqs,
  1025. acquire->resc_request.num_sbs, acquire->resc_request.num_mac_filters,
  1026. acquire->resc_request.num_vlan_filters,
  1027. acquire->resc_request.num_mc_filters);
  1028. /* acquire the resources */
  1029. rc = bnx2x_vf_acquire(bp, vf, &acquire->resc_request);
  1030. /* store address of vf's bulletin board */
  1031. vf->bulletin_map = acquire->bulletin_addr;
  1032. /* response */
  1033. bnx2x_vf_mbx_acquire_resp(bp, vf, mbx, rc);
  1034. }
  1035. static void bnx2x_vf_mbx_init_vf(struct bnx2x *bp, struct bnx2x_virtf *vf,
  1036. struct bnx2x_vf_mbx *mbx)
  1037. {
  1038. struct vfpf_init_tlv *init = &mbx->msg->req.init;
  1039. /* record ghost addresses from vf message */
  1040. vf->spq_map = init->spq_addr;
  1041. vf->fw_stat_map = init->stats_addr;
  1042. vf->stats_stride = init->stats_stride;
  1043. vf->op_rc = bnx2x_vf_init(bp, vf, (dma_addr_t *)init->sb_addr);
  1044. /* set VF multiqueue statistics collection mode */
  1045. if (init->flags & VFPF_INIT_FLG_STATS_COALESCE)
  1046. vf->cfg_flags |= VF_CFG_STATS_COALESCE;
  1047. /* response */
  1048. bnx2x_vf_mbx_resp(bp, vf);
  1049. }
  1050. /* convert MBX queue-flags to standard SP queue-flags */
  1051. static void bnx2x_vf_mbx_set_q_flags(struct bnx2x *bp, u32 mbx_q_flags,
  1052. unsigned long *sp_q_flags)
  1053. {
  1054. if (mbx_q_flags & VFPF_QUEUE_FLG_TPA)
  1055. __set_bit(BNX2X_Q_FLG_TPA, sp_q_flags);
  1056. if (mbx_q_flags & VFPF_QUEUE_FLG_TPA_IPV6)
  1057. __set_bit(BNX2X_Q_FLG_TPA_IPV6, sp_q_flags);
  1058. if (mbx_q_flags & VFPF_QUEUE_FLG_TPA_GRO)
  1059. __set_bit(BNX2X_Q_FLG_TPA_GRO, sp_q_flags);
  1060. if (mbx_q_flags & VFPF_QUEUE_FLG_STATS)
  1061. __set_bit(BNX2X_Q_FLG_STATS, sp_q_flags);
  1062. if (mbx_q_flags & VFPF_QUEUE_FLG_VLAN)
  1063. __set_bit(BNX2X_Q_FLG_VLAN, sp_q_flags);
  1064. if (mbx_q_flags & VFPF_QUEUE_FLG_COS)
  1065. __set_bit(BNX2X_Q_FLG_COS, sp_q_flags);
  1066. if (mbx_q_flags & VFPF_QUEUE_FLG_HC)
  1067. __set_bit(BNX2X_Q_FLG_HC, sp_q_flags);
  1068. if (mbx_q_flags & VFPF_QUEUE_FLG_DHC)
  1069. __set_bit(BNX2X_Q_FLG_DHC, sp_q_flags);
  1070. if (mbx_q_flags & VFPF_QUEUE_FLG_LEADING_RSS)
  1071. __set_bit(BNX2X_Q_FLG_LEADING_RSS, sp_q_flags);
  1072. /* outer vlan removal is set according to PF's multi function mode */
  1073. if (IS_MF_SD(bp))
  1074. __set_bit(BNX2X_Q_FLG_OV, sp_q_flags);
  1075. }
  1076. static void bnx2x_vf_mbx_setup_q(struct bnx2x *bp, struct bnx2x_virtf *vf,
  1077. struct bnx2x_vf_mbx *mbx)
  1078. {
  1079. struct vfpf_setup_q_tlv *setup_q = &mbx->msg->req.setup_q;
  1080. struct bnx2x_vfop_cmd cmd = {
  1081. .done = bnx2x_vf_mbx_resp,
  1082. .block = false,
  1083. };
  1084. /* verify vf_qid */
  1085. if (setup_q->vf_qid >= vf_rxq_count(vf)) {
  1086. BNX2X_ERR("vf_qid %d invalid, max queue count is %d\n",
  1087. setup_q->vf_qid, vf_rxq_count(vf));
  1088. vf->op_rc = -EINVAL;
  1089. goto response;
  1090. }
  1091. /* tx queues must be setup alongside rx queues thus if the rx queue
  1092. * is not marked as valid there's nothing to do.
  1093. */
  1094. if (setup_q->param_valid & (VFPF_RXQ_VALID|VFPF_TXQ_VALID)) {
  1095. struct bnx2x_vf_queue *q = vfq_get(vf, setup_q->vf_qid);
  1096. unsigned long q_type = 0;
  1097. struct bnx2x_queue_init_params *init_p;
  1098. struct bnx2x_queue_setup_params *setup_p;
  1099. if (bnx2x_vfq_is_leading(q))
  1100. bnx2x_leading_vfq_init(bp, vf, q);
  1101. /* re-init the VF operation context */
  1102. memset(&vf->op_params.qctor, 0 , sizeof(vf->op_params.qctor));
  1103. setup_p = &vf->op_params.qctor.prep_qsetup;
  1104. init_p = &vf->op_params.qctor.qstate.params.init;
  1105. /* activate immediately */
  1106. __set_bit(BNX2X_Q_FLG_ACTIVE, &setup_p->flags);
  1107. if (setup_q->param_valid & VFPF_TXQ_VALID) {
  1108. struct bnx2x_txq_setup_params *txq_params =
  1109. &setup_p->txq_params;
  1110. __set_bit(BNX2X_Q_TYPE_HAS_TX, &q_type);
  1111. /* save sb resource index */
  1112. q->sb_idx = setup_q->txq.vf_sb;
  1113. /* tx init */
  1114. init_p->tx.hc_rate = setup_q->txq.hc_rate;
  1115. init_p->tx.sb_cq_index = setup_q->txq.sb_index;
  1116. bnx2x_vf_mbx_set_q_flags(bp, setup_q->txq.flags,
  1117. &init_p->tx.flags);
  1118. /* tx setup - flags */
  1119. bnx2x_vf_mbx_set_q_flags(bp, setup_q->txq.flags,
  1120. &setup_p->flags);
  1121. /* tx setup - general, nothing */
  1122. /* tx setup - tx */
  1123. txq_params->dscr_map = setup_q->txq.txq_addr;
  1124. txq_params->sb_cq_index = setup_q->txq.sb_index;
  1125. txq_params->traffic_type = setup_q->txq.traffic_type;
  1126. bnx2x_vfop_qctor_dump_tx(bp, vf, init_p, setup_p,
  1127. q->index, q->sb_idx);
  1128. }
  1129. if (setup_q->param_valid & VFPF_RXQ_VALID) {
  1130. struct bnx2x_rxq_setup_params *rxq_params =
  1131. &setup_p->rxq_params;
  1132. __set_bit(BNX2X_Q_TYPE_HAS_RX, &q_type);
  1133. /* Note: there is no support for different SBs
  1134. * for TX and RX
  1135. */
  1136. q->sb_idx = setup_q->rxq.vf_sb;
  1137. /* rx init */
  1138. init_p->rx.hc_rate = setup_q->rxq.hc_rate;
  1139. init_p->rx.sb_cq_index = setup_q->rxq.sb_index;
  1140. bnx2x_vf_mbx_set_q_flags(bp, setup_q->rxq.flags,
  1141. &init_p->rx.flags);
  1142. /* rx setup - flags */
  1143. bnx2x_vf_mbx_set_q_flags(bp, setup_q->rxq.flags,
  1144. &setup_p->flags);
  1145. /* rx setup - general */
  1146. setup_p->gen_params.mtu = setup_q->rxq.mtu;
  1147. /* rx setup - rx */
  1148. rxq_params->drop_flags = setup_q->rxq.drop_flags;
  1149. rxq_params->dscr_map = setup_q->rxq.rxq_addr;
  1150. rxq_params->sge_map = setup_q->rxq.sge_addr;
  1151. rxq_params->rcq_map = setup_q->rxq.rcq_addr;
  1152. rxq_params->rcq_np_map = setup_q->rxq.rcq_np_addr;
  1153. rxq_params->buf_sz = setup_q->rxq.buf_sz;
  1154. rxq_params->tpa_agg_sz = setup_q->rxq.tpa_agg_sz;
  1155. rxq_params->max_sges_pkt = setup_q->rxq.max_sge_pkt;
  1156. rxq_params->sge_buf_sz = setup_q->rxq.sge_buf_sz;
  1157. rxq_params->cache_line_log =
  1158. setup_q->rxq.cache_line_log;
  1159. rxq_params->sb_cq_index = setup_q->rxq.sb_index;
  1160. bnx2x_vfop_qctor_dump_rx(bp, vf, init_p, setup_p,
  1161. q->index, q->sb_idx);
  1162. }
  1163. /* complete the preparations */
  1164. bnx2x_vfop_qctor_prep(bp, vf, q, &vf->op_params.qctor, q_type);
  1165. vf->op_rc = bnx2x_vfop_qsetup_cmd(bp, vf, &cmd, q->index);
  1166. if (vf->op_rc)
  1167. goto response;
  1168. return;
  1169. }
  1170. response:
  1171. bnx2x_vf_mbx_resp(bp, vf);
  1172. }
  1173. enum bnx2x_vfop_filters_state {
  1174. BNX2X_VFOP_MBX_Q_FILTERS_MACS,
  1175. BNX2X_VFOP_MBX_Q_FILTERS_VLANS,
  1176. BNX2X_VFOP_MBX_Q_FILTERS_RXMODE,
  1177. BNX2X_VFOP_MBX_Q_FILTERS_MCAST,
  1178. BNX2X_VFOP_MBX_Q_FILTERS_DONE
  1179. };
  1180. static int bnx2x_vf_mbx_macvlan_list(struct bnx2x *bp,
  1181. struct bnx2x_virtf *vf,
  1182. struct vfpf_set_q_filters_tlv *tlv,
  1183. struct bnx2x_vfop_filters **pfl,
  1184. u32 type_flag)
  1185. {
  1186. int i, j;
  1187. struct bnx2x_vfop_filters *fl = NULL;
  1188. size_t fsz;
  1189. fsz = tlv->n_mac_vlan_filters * sizeof(struct bnx2x_vfop_filter) +
  1190. sizeof(struct bnx2x_vfop_filters);
  1191. fl = kzalloc(fsz, GFP_KERNEL);
  1192. if (!fl)
  1193. return -ENOMEM;
  1194. INIT_LIST_HEAD(&fl->head);
  1195. for (i = 0, j = 0; i < tlv->n_mac_vlan_filters; i++) {
  1196. struct vfpf_q_mac_vlan_filter *msg_filter = &tlv->filters[i];
  1197. if ((msg_filter->flags & type_flag) != type_flag)
  1198. continue;
  1199. if (type_flag == VFPF_Q_FILTER_DEST_MAC_VALID) {
  1200. fl->filters[j].mac = msg_filter->mac;
  1201. fl->filters[j].type = BNX2X_VFOP_FILTER_MAC;
  1202. } else {
  1203. fl->filters[j].vid = msg_filter->vlan_tag;
  1204. fl->filters[j].type = BNX2X_VFOP_FILTER_VLAN;
  1205. }
  1206. fl->filters[j].add =
  1207. (msg_filter->flags & VFPF_Q_FILTER_SET_MAC) ?
  1208. true : false;
  1209. list_add_tail(&fl->filters[j++].link, &fl->head);
  1210. }
  1211. if (list_empty(&fl->head))
  1212. kfree(fl);
  1213. else
  1214. *pfl = fl;
  1215. return 0;
  1216. }
  1217. static void bnx2x_vf_mbx_dp_q_filter(struct bnx2x *bp, int msglvl, int idx,
  1218. struct vfpf_q_mac_vlan_filter *filter)
  1219. {
  1220. DP(msglvl, "MAC-VLAN[%d] -- flags=0x%x\n", idx, filter->flags);
  1221. if (filter->flags & VFPF_Q_FILTER_VLAN_TAG_VALID)
  1222. DP_CONT(msglvl, ", vlan=%d", filter->vlan_tag);
  1223. if (filter->flags & VFPF_Q_FILTER_DEST_MAC_VALID)
  1224. DP_CONT(msglvl, ", MAC=%pM", filter->mac);
  1225. DP_CONT(msglvl, "\n");
  1226. }
  1227. static void bnx2x_vf_mbx_dp_q_filters(struct bnx2x *bp, int msglvl,
  1228. struct vfpf_set_q_filters_tlv *filters)
  1229. {
  1230. int i;
  1231. if (filters->flags & VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED)
  1232. for (i = 0; i < filters->n_mac_vlan_filters; i++)
  1233. bnx2x_vf_mbx_dp_q_filter(bp, msglvl, i,
  1234. &filters->filters[i]);
  1235. if (filters->flags & VFPF_SET_Q_FILTERS_RX_MASK_CHANGED)
  1236. DP(msglvl, "RX-MASK=0x%x\n", filters->rx_mask);
  1237. if (filters->flags & VFPF_SET_Q_FILTERS_MULTICAST_CHANGED)
  1238. for (i = 0; i < filters->n_multicast; i++)
  1239. DP(msglvl, "MULTICAST=%pM\n", filters->multicast[i]);
  1240. }
  1241. #define VFPF_MAC_FILTER VFPF_Q_FILTER_DEST_MAC_VALID
  1242. #define VFPF_VLAN_FILTER VFPF_Q_FILTER_VLAN_TAG_VALID
  1243. static void bnx2x_vfop_mbx_qfilters(struct bnx2x *bp, struct bnx2x_virtf *vf)
  1244. {
  1245. int rc;
  1246. struct vfpf_set_q_filters_tlv *msg =
  1247. &BP_VF_MBX(bp, vf->index)->msg->req.set_q_filters;
  1248. struct bnx2x_vfop *vfop = bnx2x_vfop_cur(bp, vf);
  1249. enum bnx2x_vfop_filters_state state = vfop->state;
  1250. struct bnx2x_vfop_cmd cmd = {
  1251. .done = bnx2x_vfop_mbx_qfilters,
  1252. .block = false,
  1253. };
  1254. DP(BNX2X_MSG_IOV, "STATE: %d\n", state);
  1255. if (vfop->rc < 0)
  1256. goto op_err;
  1257. switch (state) {
  1258. case BNX2X_VFOP_MBX_Q_FILTERS_MACS:
  1259. /* next state */
  1260. vfop->state = BNX2X_VFOP_MBX_Q_FILTERS_VLANS;
  1261. /* check for any vlan/mac changes */
  1262. if (msg->flags & VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED) {
  1263. /* build mac list */
  1264. struct bnx2x_vfop_filters *fl = NULL;
  1265. vfop->rc = bnx2x_vf_mbx_macvlan_list(bp, vf, msg, &fl,
  1266. VFPF_MAC_FILTER);
  1267. if (vfop->rc)
  1268. goto op_err;
  1269. if (fl) {
  1270. /* set mac list */
  1271. rc = bnx2x_vfop_mac_list_cmd(bp, vf, &cmd, fl,
  1272. msg->vf_qid,
  1273. false);
  1274. if (rc) {
  1275. vfop->rc = rc;
  1276. goto op_err;
  1277. }
  1278. return;
  1279. }
  1280. }
  1281. /* fall through */
  1282. case BNX2X_VFOP_MBX_Q_FILTERS_VLANS:
  1283. /* next state */
  1284. vfop->state = BNX2X_VFOP_MBX_Q_FILTERS_RXMODE;
  1285. /* check for any vlan/mac changes */
  1286. if (msg->flags & VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED) {
  1287. /* build vlan list */
  1288. struct bnx2x_vfop_filters *fl = NULL;
  1289. vfop->rc = bnx2x_vf_mbx_macvlan_list(bp, vf, msg, &fl,
  1290. VFPF_VLAN_FILTER);
  1291. if (vfop->rc)
  1292. goto op_err;
  1293. if (fl) {
  1294. /* set vlan list */
  1295. rc = bnx2x_vfop_vlan_list_cmd(bp, vf, &cmd, fl,
  1296. msg->vf_qid,
  1297. false);
  1298. if (rc) {
  1299. vfop->rc = rc;
  1300. goto op_err;
  1301. }
  1302. return;
  1303. }
  1304. }
  1305. /* fall through */
  1306. case BNX2X_VFOP_MBX_Q_FILTERS_RXMODE:
  1307. /* next state */
  1308. vfop->state = BNX2X_VFOP_MBX_Q_FILTERS_MCAST;
  1309. if (msg->flags & VFPF_SET_Q_FILTERS_RX_MASK_CHANGED) {
  1310. unsigned long accept = 0;
  1311. /* covert VF-PF if mask to bnx2x accept flags */
  1312. if (msg->rx_mask & VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST)
  1313. __set_bit(BNX2X_ACCEPT_UNICAST, &accept);
  1314. if (msg->rx_mask &
  1315. VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST)
  1316. __set_bit(BNX2X_ACCEPT_MULTICAST, &accept);
  1317. if (msg->rx_mask & VFPF_RX_MASK_ACCEPT_ALL_UNICAST)
  1318. __set_bit(BNX2X_ACCEPT_ALL_UNICAST, &accept);
  1319. if (msg->rx_mask & VFPF_RX_MASK_ACCEPT_ALL_MULTICAST)
  1320. __set_bit(BNX2X_ACCEPT_ALL_MULTICAST, &accept);
  1321. if (msg->rx_mask & VFPF_RX_MASK_ACCEPT_BROADCAST)
  1322. __set_bit(BNX2X_ACCEPT_BROADCAST, &accept);
  1323. /* A packet arriving the vf's mac should be accepted
  1324. * with any vlan
  1325. */
  1326. __set_bit(BNX2X_ACCEPT_ANY_VLAN, &accept);
  1327. /* set rx-mode */
  1328. rc = bnx2x_vfop_rxmode_cmd(bp, vf, &cmd,
  1329. msg->vf_qid, accept);
  1330. if (rc) {
  1331. vfop->rc = rc;
  1332. goto op_err;
  1333. }
  1334. return;
  1335. }
  1336. /* fall through */
  1337. case BNX2X_VFOP_MBX_Q_FILTERS_MCAST:
  1338. /* next state */
  1339. vfop->state = BNX2X_VFOP_MBX_Q_FILTERS_DONE;
  1340. if (msg->flags & VFPF_SET_Q_FILTERS_MULTICAST_CHANGED) {
  1341. /* set mcasts */
  1342. rc = bnx2x_vfop_mcast_cmd(bp, vf, &cmd, msg->multicast,
  1343. msg->n_multicast, false);
  1344. if (rc) {
  1345. vfop->rc = rc;
  1346. goto op_err;
  1347. }
  1348. return;
  1349. }
  1350. /* fall through */
  1351. op_done:
  1352. case BNX2X_VFOP_MBX_Q_FILTERS_DONE:
  1353. bnx2x_vfop_end(bp, vf, vfop);
  1354. return;
  1355. op_err:
  1356. BNX2X_ERR("QFILTERS[%d:%d] error: rc %d\n",
  1357. vf->abs_vfid, msg->vf_qid, vfop->rc);
  1358. goto op_done;
  1359. default:
  1360. bnx2x_vfop_default(state);
  1361. }
  1362. }
  1363. static int bnx2x_vfop_mbx_qfilters_cmd(struct bnx2x *bp,
  1364. struct bnx2x_virtf *vf,
  1365. struct bnx2x_vfop_cmd *cmd)
  1366. {
  1367. struct bnx2x_vfop *vfop = bnx2x_vfop_add(bp, vf);
  1368. if (vfop) {
  1369. bnx2x_vfop_opset(BNX2X_VFOP_MBX_Q_FILTERS_MACS,
  1370. bnx2x_vfop_mbx_qfilters, cmd->done);
  1371. return bnx2x_vfop_transition(bp, vf, bnx2x_vfop_mbx_qfilters,
  1372. cmd->block);
  1373. }
  1374. return -ENOMEM;
  1375. }
  1376. static void bnx2x_vf_mbx_set_q_filters(struct bnx2x *bp,
  1377. struct bnx2x_virtf *vf,
  1378. struct bnx2x_vf_mbx *mbx)
  1379. {
  1380. struct vfpf_set_q_filters_tlv *filters = &mbx->msg->req.set_q_filters;
  1381. struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vf->index);
  1382. struct bnx2x_vfop_cmd cmd = {
  1383. .done = bnx2x_vf_mbx_resp,
  1384. .block = false,
  1385. };
  1386. /* if a mac was already set for this VF via the set vf mac ndo, we only
  1387. * accept mac configurations of that mac. Why accept them at all?
  1388. * because PF may have been unable to configure the mac at the time
  1389. * since queue was not set up.
  1390. */
  1391. if (bulletin->valid_bitmap & 1 << MAC_ADDR_VALID) {
  1392. /* once a mac was set by ndo can only accept a single mac... */
  1393. if (filters->n_mac_vlan_filters > 1) {
  1394. BNX2X_ERR("VF[%d] requested the addition of multiple macs after set_vf_mac ndo was called\n",
  1395. vf->abs_vfid);
  1396. vf->op_rc = -EPERM;
  1397. goto response;
  1398. }
  1399. /* ...and only the mac set by the ndo */
  1400. if (filters->n_mac_vlan_filters == 1 &&
  1401. memcmp(filters->filters->mac, bulletin->mac, ETH_ALEN)) {
  1402. BNX2X_ERR("VF[%d] requested the addition of a mac address not matching the one configured by set_vf_mac ndo\n",
  1403. vf->abs_vfid);
  1404. vf->op_rc = -EPERM;
  1405. goto response;
  1406. }
  1407. }
  1408. /* verify vf_qid */
  1409. if (filters->vf_qid > vf_rxq_count(vf))
  1410. goto response;
  1411. DP(BNX2X_MSG_IOV, "VF[%d] Q_FILTERS: queue[%d]\n",
  1412. vf->abs_vfid,
  1413. filters->vf_qid);
  1414. /* print q_filter message */
  1415. bnx2x_vf_mbx_dp_q_filters(bp, BNX2X_MSG_IOV, filters);
  1416. vf->op_rc = bnx2x_vfop_mbx_qfilters_cmd(bp, vf, &cmd);
  1417. if (vf->op_rc)
  1418. goto response;
  1419. return;
  1420. response:
  1421. bnx2x_vf_mbx_resp(bp, vf);
  1422. }
  1423. static void bnx2x_vf_mbx_teardown_q(struct bnx2x *bp, struct bnx2x_virtf *vf,
  1424. struct bnx2x_vf_mbx *mbx)
  1425. {
  1426. int qid = mbx->msg->req.q_op.vf_qid;
  1427. struct bnx2x_vfop_cmd cmd = {
  1428. .done = bnx2x_vf_mbx_resp,
  1429. .block = false,
  1430. };
  1431. DP(BNX2X_MSG_IOV, "VF[%d] Q_TEARDOWN: vf_qid=%d\n",
  1432. vf->abs_vfid, qid);
  1433. vf->op_rc = bnx2x_vfop_qdown_cmd(bp, vf, &cmd, qid);
  1434. if (vf->op_rc)
  1435. bnx2x_vf_mbx_resp(bp, vf);
  1436. }
  1437. static void bnx2x_vf_mbx_close_vf(struct bnx2x *bp, struct bnx2x_virtf *vf,
  1438. struct bnx2x_vf_mbx *mbx)
  1439. {
  1440. struct bnx2x_vfop_cmd cmd = {
  1441. .done = bnx2x_vf_mbx_resp,
  1442. .block = false,
  1443. };
  1444. DP(BNX2X_MSG_IOV, "VF[%d] VF_CLOSE\n", vf->abs_vfid);
  1445. vf->op_rc = bnx2x_vfop_close_cmd(bp, vf, &cmd);
  1446. if (vf->op_rc)
  1447. bnx2x_vf_mbx_resp(bp, vf);
  1448. }
  1449. static void bnx2x_vf_mbx_release_vf(struct bnx2x *bp, struct bnx2x_virtf *vf,
  1450. struct bnx2x_vf_mbx *mbx)
  1451. {
  1452. struct bnx2x_vfop_cmd cmd = {
  1453. .done = bnx2x_vf_mbx_resp,
  1454. .block = false,
  1455. };
  1456. DP(BNX2X_MSG_IOV, "VF[%d] VF_RELEASE\n", vf->abs_vfid);
  1457. vf->op_rc = bnx2x_vfop_release_cmd(bp, vf, &cmd);
  1458. if (vf->op_rc)
  1459. bnx2x_vf_mbx_resp(bp, vf);
  1460. }
  1461. static void bnx2x_vf_mbx_update_rss(struct bnx2x *bp, struct bnx2x_virtf *vf,
  1462. struct bnx2x_vf_mbx *mbx)
  1463. {
  1464. struct bnx2x_vfop_cmd cmd = {
  1465. .done = bnx2x_vf_mbx_resp,
  1466. .block = false,
  1467. };
  1468. struct bnx2x_config_rss_params *vf_op_params = &vf->op_params.rss;
  1469. struct vfpf_rss_tlv *rss_tlv = &mbx->msg->req.update_rss;
  1470. if (rss_tlv->ind_table_size != T_ETH_INDIRECTION_TABLE_SIZE ||
  1471. rss_tlv->rss_key_size != T_ETH_RSS_KEY) {
  1472. BNX2X_ERR("failing rss configuration of vf %d due to size mismatch\n",
  1473. vf->index);
  1474. vf->op_rc = -EINVAL;
  1475. goto mbx_resp;
  1476. }
  1477. /* set vfop params according to rss tlv */
  1478. memcpy(vf_op_params->ind_table, rss_tlv->ind_table,
  1479. T_ETH_INDIRECTION_TABLE_SIZE);
  1480. memcpy(vf_op_params->rss_key, rss_tlv->rss_key,
  1481. sizeof(rss_tlv->rss_key));
  1482. vf_op_params->rss_obj = &vf->rss_conf_obj;
  1483. vf_op_params->rss_result_mask = rss_tlv->rss_result_mask;
  1484. /* flags handled individually for backward/forward compatability */
  1485. if (rss_tlv->rss_flags & VFPF_RSS_MODE_DISABLED)
  1486. __set_bit(BNX2X_RSS_MODE_DISABLED, &vf_op_params->rss_flags);
  1487. if (rss_tlv->rss_flags & VFPF_RSS_MODE_REGULAR)
  1488. __set_bit(BNX2X_RSS_MODE_REGULAR, &vf_op_params->rss_flags);
  1489. if (rss_tlv->rss_flags & VFPF_RSS_SET_SRCH)
  1490. __set_bit(BNX2X_RSS_SET_SRCH, &vf_op_params->rss_flags);
  1491. if (rss_tlv->rss_flags & VFPF_RSS_IPV4)
  1492. __set_bit(BNX2X_RSS_IPV4, &vf_op_params->rss_flags);
  1493. if (rss_tlv->rss_flags & VFPF_RSS_IPV4_TCP)
  1494. __set_bit(BNX2X_RSS_IPV4_TCP, &vf_op_params->rss_flags);
  1495. if (rss_tlv->rss_flags & VFPF_RSS_IPV4_UDP)
  1496. __set_bit(BNX2X_RSS_IPV4_UDP, &vf_op_params->rss_flags);
  1497. if (rss_tlv->rss_flags & VFPF_RSS_IPV6)
  1498. __set_bit(BNX2X_RSS_IPV6, &vf_op_params->rss_flags);
  1499. if (rss_tlv->rss_flags & VFPF_RSS_IPV6_TCP)
  1500. __set_bit(BNX2X_RSS_IPV6_TCP, &vf_op_params->rss_flags);
  1501. if (rss_tlv->rss_flags & VFPF_RSS_IPV6_UDP)
  1502. __set_bit(BNX2X_RSS_IPV6_UDP, &vf_op_params->rss_flags);
  1503. if ((!(rss_tlv->rss_flags & VFPF_RSS_IPV4_TCP) &&
  1504. rss_tlv->rss_flags & VFPF_RSS_IPV4_UDP) ||
  1505. (!(rss_tlv->rss_flags & VFPF_RSS_IPV6_TCP) &&
  1506. rss_tlv->rss_flags & VFPF_RSS_IPV6_UDP)) {
  1507. BNX2X_ERR("about to hit a FW assert. aborting...\n");
  1508. vf->op_rc = -EINVAL;
  1509. goto mbx_resp;
  1510. }
  1511. vf->op_rc = bnx2x_vfop_rss_cmd(bp, vf, &cmd);
  1512. mbx_resp:
  1513. if (vf->op_rc)
  1514. bnx2x_vf_mbx_resp(bp, vf);
  1515. }
  1516. /* dispatch request */
  1517. static void bnx2x_vf_mbx_request(struct bnx2x *bp, struct bnx2x_virtf *vf,
  1518. struct bnx2x_vf_mbx *mbx)
  1519. {
  1520. int i;
  1521. /* check if tlv type is known */
  1522. if (bnx2x_tlv_supported(mbx->first_tlv.tl.type)) {
  1523. /* Lock the per vf op mutex and note the locker's identity.
  1524. * The unlock will take place in mbx response.
  1525. */
  1526. bnx2x_lock_vf_pf_channel(bp, vf, mbx->first_tlv.tl.type);
  1527. /* switch on the opcode */
  1528. switch (mbx->first_tlv.tl.type) {
  1529. case CHANNEL_TLV_ACQUIRE:
  1530. bnx2x_vf_mbx_acquire(bp, vf, mbx);
  1531. return;
  1532. case CHANNEL_TLV_INIT:
  1533. bnx2x_vf_mbx_init_vf(bp, vf, mbx);
  1534. return;
  1535. case CHANNEL_TLV_SETUP_Q:
  1536. bnx2x_vf_mbx_setup_q(bp, vf, mbx);
  1537. return;
  1538. case CHANNEL_TLV_SET_Q_FILTERS:
  1539. bnx2x_vf_mbx_set_q_filters(bp, vf, mbx);
  1540. return;
  1541. case CHANNEL_TLV_TEARDOWN_Q:
  1542. bnx2x_vf_mbx_teardown_q(bp, vf, mbx);
  1543. return;
  1544. case CHANNEL_TLV_CLOSE:
  1545. bnx2x_vf_mbx_close_vf(bp, vf, mbx);
  1546. return;
  1547. case CHANNEL_TLV_RELEASE:
  1548. bnx2x_vf_mbx_release_vf(bp, vf, mbx);
  1549. return;
  1550. case CHANNEL_TLV_UPDATE_RSS:
  1551. bnx2x_vf_mbx_update_rss(bp, vf, mbx);
  1552. return;
  1553. }
  1554. } else {
  1555. /* unknown TLV - this may belong to a VF driver from the future
  1556. * - a version written after this PF driver was written, which
  1557. * supports features unknown as of yet. Too bad since we don't
  1558. * support them. Or this may be because someone wrote a crappy
  1559. * VF driver and is sending garbage over the channel.
  1560. */
  1561. BNX2X_ERR("unknown TLV. type %d length %d vf->state was %d. first 20 bytes of mailbox buffer:\n",
  1562. mbx->first_tlv.tl.type, mbx->first_tlv.tl.length,
  1563. vf->state);
  1564. for (i = 0; i < 20; i++)
  1565. DP_CONT(BNX2X_MSG_IOV, "%x ",
  1566. mbx->msg->req.tlv_buf_size.tlv_buffer[i]);
  1567. }
  1568. /* can we respond to VF (do we have an address for it?) */
  1569. if (vf->state == VF_ACQUIRED || vf->state == VF_ENABLED) {
  1570. /* mbx_resp uses the op_rc of the VF */
  1571. vf->op_rc = PFVF_STATUS_NOT_SUPPORTED;
  1572. /* notify the VF that we do not support this request */
  1573. bnx2x_vf_mbx_resp(bp, vf);
  1574. } else {
  1575. /* can't send a response since this VF is unknown to us
  1576. * just ack the FW to release the mailbox and unlock
  1577. * the channel.
  1578. */
  1579. storm_memset_vf_mbx_ack(bp, vf->abs_vfid);
  1580. /* Firmware ack should be written before unlocking channel */
  1581. mmiowb();
  1582. bnx2x_unlock_vf_pf_channel(bp, vf, mbx->first_tlv.tl.type);
  1583. }
  1584. }
  1585. /* handle new vf-pf message */
  1586. void bnx2x_vf_mbx(struct bnx2x *bp, struct vf_pf_event_data *vfpf_event)
  1587. {
  1588. struct bnx2x_virtf *vf;
  1589. struct bnx2x_vf_mbx *mbx;
  1590. u8 vf_idx;
  1591. int rc;
  1592. DP(BNX2X_MSG_IOV,
  1593. "vf pf event received: vfid %d, address_hi %x, address lo %x",
  1594. vfpf_event->vf_id, vfpf_event->msg_addr_hi, vfpf_event->msg_addr_lo);
  1595. /* Sanity checks consider removing later */
  1596. /* check if the vf_id is valid */
  1597. if (vfpf_event->vf_id - BP_VFDB(bp)->sriov.first_vf_in_pf >
  1598. BNX2X_NR_VIRTFN(bp)) {
  1599. BNX2X_ERR("Illegal vf_id %d max allowed: %d\n",
  1600. vfpf_event->vf_id, BNX2X_NR_VIRTFN(bp));
  1601. goto mbx_done;
  1602. }
  1603. vf_idx = bnx2x_vf_idx_by_abs_fid(bp, vfpf_event->vf_id);
  1604. mbx = BP_VF_MBX(bp, vf_idx);
  1605. /* verify an event is not currently being processed -
  1606. * debug failsafe only
  1607. */
  1608. if (mbx->flags & VF_MSG_INPROCESS) {
  1609. BNX2X_ERR("Previous message is still being processed, vf_id %d\n",
  1610. vfpf_event->vf_id);
  1611. goto mbx_done;
  1612. }
  1613. vf = BP_VF(bp, vf_idx);
  1614. /* save the VF message address */
  1615. mbx->vf_addr_hi = vfpf_event->msg_addr_hi;
  1616. mbx->vf_addr_lo = vfpf_event->msg_addr_lo;
  1617. DP(BNX2X_MSG_IOV, "mailbox vf address hi 0x%x, lo 0x%x, offset 0x%x\n",
  1618. mbx->vf_addr_hi, mbx->vf_addr_lo, mbx->first_tlv.resp_msg_offset);
  1619. /* dmae to get the VF request */
  1620. rc = bnx2x_copy32_vf_dmae(bp, true, mbx->msg_mapping, vf->abs_vfid,
  1621. mbx->vf_addr_hi, mbx->vf_addr_lo,
  1622. sizeof(union vfpf_tlvs)/4);
  1623. if (rc) {
  1624. BNX2X_ERR("Failed to copy request VF %d\n", vf->abs_vfid);
  1625. goto mbx_error;
  1626. }
  1627. /* process the VF message header */
  1628. mbx->first_tlv = mbx->msg->req.first_tlv;
  1629. /* Clean response buffer to refrain from falsely seeing chains */
  1630. memset(&mbx->msg->resp, 0, sizeof(union pfvf_tlvs));
  1631. /* dispatch the request (will prepare the response) */
  1632. bnx2x_vf_mbx_request(bp, vf, mbx);
  1633. goto mbx_done;
  1634. mbx_error:
  1635. bnx2x_vf_release(bp, vf, false); /* non blocking */
  1636. mbx_done:
  1637. return;
  1638. }
  1639. /* propagate local bulletin board to vf */
  1640. int bnx2x_post_vf_bulletin(struct bnx2x *bp, int vf)
  1641. {
  1642. struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vf);
  1643. dma_addr_t pf_addr = BP_VF_BULLETIN_DMA(bp)->mapping +
  1644. vf * BULLETIN_CONTENT_SIZE;
  1645. dma_addr_t vf_addr = bnx2x_vf(bp, vf, bulletin_map);
  1646. int rc;
  1647. /* can only update vf after init took place */
  1648. if (bnx2x_vf(bp, vf, state) != VF_ENABLED &&
  1649. bnx2x_vf(bp, vf, state) != VF_ACQUIRED)
  1650. return 0;
  1651. /* increment bulletin board version and compute crc */
  1652. bulletin->version++;
  1653. bulletin->length = BULLETIN_CONTENT_SIZE;
  1654. bulletin->crc = bnx2x_crc_vf_bulletin(bp, bulletin);
  1655. /* propagate bulletin board via dmae to vm memory */
  1656. rc = bnx2x_copy32_vf_dmae(bp, false, pf_addr,
  1657. bnx2x_vf(bp, vf, abs_vfid), U64_HI(vf_addr),
  1658. U64_LO(vf_addr), bulletin->length / 4);
  1659. return rc;
  1660. }