12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282 |
- // SPDX-License-Identifier: GPL-2.0
- /* Copyright (c) 2018, Intel Corporation. */
- #include "ice_switch.h"
- #define ICE_ETH_DA_OFFSET 0
- #define ICE_ETH_ETHTYPE_OFFSET 12
- #define ICE_ETH_VLAN_TCI_OFFSET 14
- #define ICE_MAX_VLAN_ID 0xFFF
- /* Dummy ethernet header needed in the ice_aqc_sw_rules_elem
- * struct to configure any switch filter rules.
- * {DA (6 bytes), SA(6 bytes),
- * Ether type (2 bytes for header without VLAN tag) OR
- * VLAN tag (4 bytes for header with VLAN tag) }
- *
- * Word on Hardcoded values
- * byte 0 = 0x2: to identify it as locally administered DA MAC
- * byte 6 = 0x2: to identify it as locally administered SA MAC
- * byte 12 = 0x81 & byte 13 = 0x00:
- * In case of VLAN filter first two bytes defines ether type (0x8100)
- * and remaining two bytes are placeholder for programming a given VLAN id
- * In case of Ether type filter it is treated as header without VLAN tag
- * and byte 12 and 13 is used to program a given Ether type instead
- */
- #define DUMMY_ETH_HDR_LEN 16
- static const u8 dummy_eth_header[DUMMY_ETH_HDR_LEN] = { 0x2, 0, 0, 0, 0, 0,
- 0x2, 0, 0, 0, 0, 0,
- 0x81, 0, 0, 0};
- #define ICE_SW_RULE_RX_TX_ETH_HDR_SIZE \
- (sizeof(struct ice_aqc_sw_rules_elem) - \
- sizeof(((struct ice_aqc_sw_rules_elem *)0)->pdata) + \
- sizeof(struct ice_sw_rule_lkup_rx_tx) + DUMMY_ETH_HDR_LEN - 1)
- #define ICE_SW_RULE_RX_TX_NO_HDR_SIZE \
- (sizeof(struct ice_aqc_sw_rules_elem) - \
- sizeof(((struct ice_aqc_sw_rules_elem *)0)->pdata) + \
- sizeof(struct ice_sw_rule_lkup_rx_tx) - 1)
- #define ICE_SW_RULE_LG_ACT_SIZE(n) \
- (sizeof(struct ice_aqc_sw_rules_elem) - \
- sizeof(((struct ice_aqc_sw_rules_elem *)0)->pdata) + \
- sizeof(struct ice_sw_rule_lg_act) - \
- sizeof(((struct ice_sw_rule_lg_act *)0)->act) + \
- ((n) * sizeof(((struct ice_sw_rule_lg_act *)0)->act)))
- #define ICE_SW_RULE_VSI_LIST_SIZE(n) \
- (sizeof(struct ice_aqc_sw_rules_elem) - \
- sizeof(((struct ice_aqc_sw_rules_elem *)0)->pdata) + \
- sizeof(struct ice_sw_rule_vsi_list) - \
- sizeof(((struct ice_sw_rule_vsi_list *)0)->vsi) + \
- ((n) * sizeof(((struct ice_sw_rule_vsi_list *)0)->vsi)))
- /**
- * ice_aq_alloc_free_res - command to allocate/free resources
- * @hw: pointer to the hw struct
- * @num_entries: number of resource entries in buffer
- * @buf: Indirect buffer to hold data parameters and response
- * @buf_size: size of buffer for indirect commands
- * @opc: pass in the command opcode
- * @cd: pointer to command details structure or NULL
- *
- * Helper function to allocate/free resources using the admin queue commands
- */
- static enum ice_status
- ice_aq_alloc_free_res(struct ice_hw *hw, u16 num_entries,
- struct ice_aqc_alloc_free_res_elem *buf, u16 buf_size,
- enum ice_adminq_opc opc, struct ice_sq_cd *cd)
- {
- struct ice_aqc_alloc_free_res_cmd *cmd;
- struct ice_aq_desc desc;
- cmd = &desc.params.sw_res_ctrl;
- if (!buf)
- return ICE_ERR_PARAM;
- if (buf_size < (num_entries * sizeof(buf->elem[0])))
- return ICE_ERR_PARAM;
- ice_fill_dflt_direct_cmd_desc(&desc, opc);
- desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
- cmd->num_entries = cpu_to_le16(num_entries);
- return ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
- }
- /**
- * ice_init_def_sw_recp - initialize the recipe book keeping tables
- * @hw: pointer to the hw struct
- *
- * Allocate memory for the entire recipe table and initialize the structures/
- * entries corresponding to basic recipes.
- */
- enum ice_status
- ice_init_def_sw_recp(struct ice_hw *hw)
- {
- struct ice_sw_recipe *recps;
- u8 i;
- recps = devm_kcalloc(ice_hw_to_dev(hw), ICE_MAX_NUM_RECIPES,
- sizeof(struct ice_sw_recipe), GFP_KERNEL);
- if (!recps)
- return ICE_ERR_NO_MEMORY;
- for (i = 0; i < ICE_SW_LKUP_LAST; i++) {
- recps[i].root_rid = i;
- INIT_LIST_HEAD(&recps[i].filt_rules);
- mutex_init(&recps[i].filt_rule_lock);
- }
- hw->switch_info->recp_list = recps;
- return 0;
- }
- /**
- * ice_aq_get_sw_cfg - get switch configuration
- * @hw: pointer to the hardware structure
- * @buf: pointer to the result buffer
- * @buf_size: length of the buffer available for response
- * @req_desc: pointer to requested descriptor
- * @num_elems: pointer to number of elements
- * @cd: pointer to command details structure or NULL
- *
- * Get switch configuration (0x0200) to be placed in 'buff'.
- * This admin command returns information such as initial VSI/port number
- * and switch ID it belongs to.
- *
- * NOTE: *req_desc is both an input/output parameter.
- * The caller of this function first calls this function with *request_desc set
- * to 0. If the response from f/w has *req_desc set to 0, all the switch
- * configuration information has been returned; if non-zero (meaning not all
- * the information was returned), the caller should call this function again
- * with *req_desc set to the previous value returned by f/w to get the
- * next block of switch configuration information.
- *
- * *num_elems is output only parameter. This reflects the number of elements
- * in response buffer. The caller of this function to use *num_elems while
- * parsing the response buffer.
- */
- static enum ice_status
- ice_aq_get_sw_cfg(struct ice_hw *hw, struct ice_aqc_get_sw_cfg_resp *buf,
- u16 buf_size, u16 *req_desc, u16 *num_elems,
- struct ice_sq_cd *cd)
- {
- struct ice_aqc_get_sw_cfg *cmd;
- enum ice_status status;
- struct ice_aq_desc desc;
- ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_sw_cfg);
- cmd = &desc.params.get_sw_conf;
- cmd->element = cpu_to_le16(*req_desc);
- status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
- if (!status) {
- *req_desc = le16_to_cpu(cmd->element);
- *num_elems = le16_to_cpu(cmd->num_elems);
- }
- return status;
- }
- /**
- * ice_aq_add_vsi
- * @hw: pointer to the hw struct
- * @vsi_ctx: pointer to a VSI context struct
- * @cd: pointer to command details structure or NULL
- *
- * Add a VSI context to the hardware (0x0210)
- */
- static enum ice_status
- ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
- struct ice_sq_cd *cd)
- {
- struct ice_aqc_add_update_free_vsi_resp *res;
- struct ice_aqc_add_get_update_free_vsi *cmd;
- struct ice_aq_desc desc;
- enum ice_status status;
- cmd = &desc.params.vsi_cmd;
- res = &desc.params.add_update_free_vsi_res;
- ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_add_vsi);
- if (!vsi_ctx->alloc_from_pool)
- cmd->vsi_num = cpu_to_le16(vsi_ctx->vsi_num |
- ICE_AQ_VSI_IS_VALID);
- cmd->vsi_flags = cpu_to_le16(vsi_ctx->flags);
- desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
- status = ice_aq_send_cmd(hw, &desc, &vsi_ctx->info,
- sizeof(vsi_ctx->info), cd);
- if (!status) {
- vsi_ctx->vsi_num = le16_to_cpu(res->vsi_num) & ICE_AQ_VSI_NUM_M;
- vsi_ctx->vsis_allocd = le16_to_cpu(res->vsi_used);
- vsi_ctx->vsis_unallocated = le16_to_cpu(res->vsi_free);
- }
- return status;
- }
- /**
- * ice_aq_free_vsi
- * @hw: pointer to the hw struct
- * @vsi_ctx: pointer to a VSI context struct
- * @keep_vsi_alloc: keep VSI allocation as part of this PF's resources
- * @cd: pointer to command details structure or NULL
- *
- * Free VSI context info from hardware (0x0213)
- */
- static enum ice_status
- ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
- bool keep_vsi_alloc, struct ice_sq_cd *cd)
- {
- struct ice_aqc_add_update_free_vsi_resp *resp;
- struct ice_aqc_add_get_update_free_vsi *cmd;
- struct ice_aq_desc desc;
- enum ice_status status;
- cmd = &desc.params.vsi_cmd;
- resp = &desc.params.add_update_free_vsi_res;
- ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_free_vsi);
- cmd->vsi_num = cpu_to_le16(vsi_ctx->vsi_num | ICE_AQ_VSI_IS_VALID);
- if (keep_vsi_alloc)
- cmd->cmd_flags = cpu_to_le16(ICE_AQ_VSI_KEEP_ALLOC);
- status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
- if (!status) {
- vsi_ctx->vsis_allocd = le16_to_cpu(resp->vsi_used);
- vsi_ctx->vsis_unallocated = le16_to_cpu(resp->vsi_free);
- }
- return status;
- }
- /**
- * ice_aq_update_vsi
- * @hw: pointer to the hw struct
- * @vsi_ctx: pointer to a VSI context struct
- * @cd: pointer to command details structure or NULL
- *
- * Update VSI context in the hardware (0x0211)
- */
- static enum ice_status
- ice_aq_update_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
- struct ice_sq_cd *cd)
- {
- struct ice_aqc_add_update_free_vsi_resp *resp;
- struct ice_aqc_add_get_update_free_vsi *cmd;
- struct ice_aq_desc desc;
- enum ice_status status;
- cmd = &desc.params.vsi_cmd;
- resp = &desc.params.add_update_free_vsi_res;
- ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_update_vsi);
- cmd->vsi_num = cpu_to_le16(vsi_ctx->vsi_num | ICE_AQ_VSI_IS_VALID);
- desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
- status = ice_aq_send_cmd(hw, &desc, &vsi_ctx->info,
- sizeof(vsi_ctx->info), cd);
- if (!status) {
- vsi_ctx->vsis_allocd = le16_to_cpu(resp->vsi_used);
- vsi_ctx->vsis_unallocated = le16_to_cpu(resp->vsi_free);
- }
- return status;
- }
- /**
- * ice_is_vsi_valid - check whether the VSI is valid or not
- * @hw: pointer to the hw struct
- * @vsi_handle: VSI handle
- *
- * check whether the VSI is valid or not
- */
- bool ice_is_vsi_valid(struct ice_hw *hw, u16 vsi_handle)
- {
- return vsi_handle < ICE_MAX_VSI && hw->vsi_ctx[vsi_handle];
- }
- /**
- * ice_get_hw_vsi_num - return the hw VSI number
- * @hw: pointer to the hw struct
- * @vsi_handle: VSI handle
- *
- * return the hw VSI number
- * Caution: call this function only if VSI is valid (ice_is_vsi_valid)
- */
- u16 ice_get_hw_vsi_num(struct ice_hw *hw, u16 vsi_handle)
- {
- return hw->vsi_ctx[vsi_handle]->vsi_num;
- }
- /**
- * ice_get_vsi_ctx - return the VSI context entry for a given VSI handle
- * @hw: pointer to the hw struct
- * @vsi_handle: VSI handle
- *
- * return the VSI context entry for a given VSI handle
- */
- struct ice_vsi_ctx *ice_get_vsi_ctx(struct ice_hw *hw, u16 vsi_handle)
- {
- return (vsi_handle >= ICE_MAX_VSI) ? NULL : hw->vsi_ctx[vsi_handle];
- }
- /**
- * ice_save_vsi_ctx - save the VSI context for a given VSI handle
- * @hw: pointer to the hw struct
- * @vsi_handle: VSI handle
- * @vsi: VSI context pointer
- *
- * save the VSI context entry for a given VSI handle
- */
- static void ice_save_vsi_ctx(struct ice_hw *hw, u16 vsi_handle,
- struct ice_vsi_ctx *vsi)
- {
- hw->vsi_ctx[vsi_handle] = vsi;
- }
- /**
- * ice_clear_vsi_ctx - clear the VSI context entry
- * @hw: pointer to the hw struct
- * @vsi_handle: VSI handle
- *
- * clear the VSI context entry
- */
- static void ice_clear_vsi_ctx(struct ice_hw *hw, u16 vsi_handle)
- {
- struct ice_vsi_ctx *vsi;
- vsi = ice_get_vsi_ctx(hw, vsi_handle);
- if (vsi) {
- devm_kfree(ice_hw_to_dev(hw), vsi);
- hw->vsi_ctx[vsi_handle] = NULL;
- }
- }
- /**
- * ice_add_vsi - add VSI context to the hardware and VSI handle list
- * @hw: pointer to the hw struct
- * @vsi_handle: unique VSI handle provided by drivers
- * @vsi_ctx: pointer to a VSI context struct
- * @cd: pointer to command details structure or NULL
- *
- * Add a VSI context to the hardware also add it into the VSI handle list.
- * If this function gets called after reset for existing VSIs then update
- * with the new HW VSI number in the corresponding VSI handle list entry.
- */
- enum ice_status
- ice_add_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
- struct ice_sq_cd *cd)
- {
- struct ice_vsi_ctx *tmp_vsi_ctx;
- enum ice_status status;
- if (vsi_handle >= ICE_MAX_VSI)
- return ICE_ERR_PARAM;
- status = ice_aq_add_vsi(hw, vsi_ctx, cd);
- if (status)
- return status;
- tmp_vsi_ctx = ice_get_vsi_ctx(hw, vsi_handle);
- if (!tmp_vsi_ctx) {
- /* Create a new vsi context */
- tmp_vsi_ctx = devm_kzalloc(ice_hw_to_dev(hw),
- sizeof(*tmp_vsi_ctx), GFP_KERNEL);
- if (!tmp_vsi_ctx) {
- ice_aq_free_vsi(hw, vsi_ctx, false, cd);
- return ICE_ERR_NO_MEMORY;
- }
- *tmp_vsi_ctx = *vsi_ctx;
- ice_save_vsi_ctx(hw, vsi_handle, tmp_vsi_ctx);
- } else {
- /* update with new HW VSI num */
- if (tmp_vsi_ctx->vsi_num != vsi_ctx->vsi_num)
- tmp_vsi_ctx->vsi_num = vsi_ctx->vsi_num;
- }
- return status;
- }
- /**
- * ice_free_vsi- free VSI context from hardware and VSI handle list
- * @hw: pointer to the hw struct
- * @vsi_handle: unique VSI handle
- * @vsi_ctx: pointer to a VSI context struct
- * @keep_vsi_alloc: keep VSI allocation as part of this PF's resources
- * @cd: pointer to command details structure or NULL
- *
- * Free VSI context info from hardware as well as from VSI handle list
- */
- enum ice_status
- ice_free_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
- bool keep_vsi_alloc, struct ice_sq_cd *cd)
- {
- enum ice_status status;
- if (!ice_is_vsi_valid(hw, vsi_handle))
- return ICE_ERR_PARAM;
- vsi_ctx->vsi_num = ice_get_hw_vsi_num(hw, vsi_handle);
- status = ice_aq_free_vsi(hw, vsi_ctx, keep_vsi_alloc, cd);
- if (!status)
- ice_clear_vsi_ctx(hw, vsi_handle);
- return status;
- }
- /**
- * ice_update_vsi
- * @hw: pointer to the hw struct
- * @vsi_handle: unique VSI handle
- * @vsi_ctx: pointer to a VSI context struct
- * @cd: pointer to command details structure or NULL
- *
- * Update VSI context in the hardware
- */
- enum ice_status
- ice_update_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
- struct ice_sq_cd *cd)
- {
- if (!ice_is_vsi_valid(hw, vsi_handle))
- return ICE_ERR_PARAM;
- vsi_ctx->vsi_num = ice_get_hw_vsi_num(hw, vsi_handle);
- return ice_aq_update_vsi(hw, vsi_ctx, cd);
- }
- /**
- * ice_aq_alloc_free_vsi_list
- * @hw: pointer to the hw struct
- * @vsi_list_id: VSI list id returned or used for lookup
- * @lkup_type: switch rule filter lookup type
- * @opc: switch rules population command type - pass in the command opcode
- *
- * allocates or free a VSI list resource
- */
- static enum ice_status
- ice_aq_alloc_free_vsi_list(struct ice_hw *hw, u16 *vsi_list_id,
- enum ice_sw_lkup_type lkup_type,
- enum ice_adminq_opc opc)
- {
- struct ice_aqc_alloc_free_res_elem *sw_buf;
- struct ice_aqc_res_elem *vsi_ele;
- enum ice_status status;
- u16 buf_len;
- buf_len = sizeof(*sw_buf);
- sw_buf = devm_kzalloc(ice_hw_to_dev(hw), buf_len, GFP_KERNEL);
- if (!sw_buf)
- return ICE_ERR_NO_MEMORY;
- sw_buf->num_elems = cpu_to_le16(1);
- if (lkup_type == ICE_SW_LKUP_MAC ||
- lkup_type == ICE_SW_LKUP_MAC_VLAN ||
- lkup_type == ICE_SW_LKUP_ETHERTYPE ||
- lkup_type == ICE_SW_LKUP_ETHERTYPE_MAC ||
- lkup_type == ICE_SW_LKUP_PROMISC ||
- lkup_type == ICE_SW_LKUP_PROMISC_VLAN) {
- sw_buf->res_type = cpu_to_le16(ICE_AQC_RES_TYPE_VSI_LIST_REP);
- } else if (lkup_type == ICE_SW_LKUP_VLAN) {
- sw_buf->res_type =
- cpu_to_le16(ICE_AQC_RES_TYPE_VSI_LIST_PRUNE);
- } else {
- status = ICE_ERR_PARAM;
- goto ice_aq_alloc_free_vsi_list_exit;
- }
- if (opc == ice_aqc_opc_free_res)
- sw_buf->elem[0].e.sw_resp = cpu_to_le16(*vsi_list_id);
- status = ice_aq_alloc_free_res(hw, 1, sw_buf, buf_len, opc, NULL);
- if (status)
- goto ice_aq_alloc_free_vsi_list_exit;
- if (opc == ice_aqc_opc_alloc_res) {
- vsi_ele = &sw_buf->elem[0];
- *vsi_list_id = le16_to_cpu(vsi_ele->e.sw_resp);
- }
- ice_aq_alloc_free_vsi_list_exit:
- devm_kfree(ice_hw_to_dev(hw), sw_buf);
- return status;
- }
- /**
- * ice_aq_sw_rules - add/update/remove switch rules
- * @hw: pointer to the hw struct
- * @rule_list: pointer to switch rule population list
- * @rule_list_sz: total size of the rule list in bytes
- * @num_rules: number of switch rules in the rule_list
- * @opc: switch rules population command type - pass in the command opcode
- * @cd: pointer to command details structure or NULL
- *
- * Add(0x02a0)/Update(0x02a1)/Remove(0x02a2) switch rules commands to firmware
- */
- static enum ice_status
- ice_aq_sw_rules(struct ice_hw *hw, void *rule_list, u16 rule_list_sz,
- u8 num_rules, enum ice_adminq_opc opc, struct ice_sq_cd *cd)
- {
- struct ice_aq_desc desc;
- if (opc != ice_aqc_opc_add_sw_rules &&
- opc != ice_aqc_opc_update_sw_rules &&
- opc != ice_aqc_opc_remove_sw_rules)
- return ICE_ERR_PARAM;
- ice_fill_dflt_direct_cmd_desc(&desc, opc);
- desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
- desc.params.sw_rules.num_rules_fltr_entry_index =
- cpu_to_le16(num_rules);
- return ice_aq_send_cmd(hw, &desc, rule_list, rule_list_sz, cd);
- }
- /* ice_init_port_info - Initialize port_info with switch configuration data
- * @pi: pointer to port_info
- * @vsi_port_num: VSI number or port number
- * @type: Type of switch element (port or VSI)
- * @swid: switch ID of the switch the element is attached to
- * @pf_vf_num: PF or VF number
- * @is_vf: true if the element is a VF, false otherwise
- */
- static void
- ice_init_port_info(struct ice_port_info *pi, u16 vsi_port_num, u8 type,
- u16 swid, u16 pf_vf_num, bool is_vf)
- {
- switch (type) {
- case ICE_AQC_GET_SW_CONF_RESP_PHYS_PORT:
- pi->lport = (u8)(vsi_port_num & ICE_LPORT_MASK);
- pi->sw_id = swid;
- pi->pf_vf_num = pf_vf_num;
- pi->is_vf = is_vf;
- pi->dflt_tx_vsi_num = ICE_DFLT_VSI_INVAL;
- pi->dflt_rx_vsi_num = ICE_DFLT_VSI_INVAL;
- break;
- default:
- ice_debug(pi->hw, ICE_DBG_SW,
- "incorrect VSI/port type received\n");
- break;
- }
- }
- /* ice_get_initial_sw_cfg - Get initial port and default VSI data
- * @hw: pointer to the hardware structure
- */
- enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw)
- {
- struct ice_aqc_get_sw_cfg_resp *rbuf;
- enum ice_status status;
- u16 req_desc = 0;
- u16 num_elems;
- u16 i;
- rbuf = devm_kzalloc(ice_hw_to_dev(hw), ICE_SW_CFG_MAX_BUF_LEN,
- GFP_KERNEL);
- if (!rbuf)
- return ICE_ERR_NO_MEMORY;
- /* Multiple calls to ice_aq_get_sw_cfg may be required
- * to get all the switch configuration information. The need
- * for additional calls is indicated by ice_aq_get_sw_cfg
- * writing a non-zero value in req_desc
- */
- do {
- status = ice_aq_get_sw_cfg(hw, rbuf, ICE_SW_CFG_MAX_BUF_LEN,
- &req_desc, &num_elems, NULL);
- if (status)
- break;
- for (i = 0; i < num_elems; i++) {
- struct ice_aqc_get_sw_cfg_resp_elem *ele;
- u16 pf_vf_num, swid, vsi_port_num;
- bool is_vf = false;
- u8 type;
- ele = rbuf[i].elements;
- vsi_port_num = le16_to_cpu(ele->vsi_port_num) &
- ICE_AQC_GET_SW_CONF_RESP_VSI_PORT_NUM_M;
- pf_vf_num = le16_to_cpu(ele->pf_vf_num) &
- ICE_AQC_GET_SW_CONF_RESP_FUNC_NUM_M;
- swid = le16_to_cpu(ele->swid);
- if (le16_to_cpu(ele->pf_vf_num) &
- ICE_AQC_GET_SW_CONF_RESP_IS_VF)
- is_vf = true;
- type = le16_to_cpu(ele->vsi_port_num) >>
- ICE_AQC_GET_SW_CONF_RESP_TYPE_S;
- if (type == ICE_AQC_GET_SW_CONF_RESP_VSI) {
- /* FW VSI is not needed. Just continue. */
- continue;
- }
- ice_init_port_info(hw->port_info, vsi_port_num,
- type, swid, pf_vf_num, is_vf);
- }
- } while (req_desc && !status);
- devm_kfree(ice_hw_to_dev(hw), (void *)rbuf);
- return status;
- }
- /**
- * ice_fill_sw_info - Helper function to populate lb_en and lan_en
- * @hw: pointer to the hardware structure
- * @f_info: filter info structure to fill/update
- *
- * This helper function populates the lb_en and lan_en elements of the provided
- * ice_fltr_info struct using the switch's type and characteristics of the
- * switch rule being configured.
- */
- static void ice_fill_sw_info(struct ice_hw *hw, struct ice_fltr_info *f_info)
- {
- f_info->lb_en = false;
- f_info->lan_en = false;
- if ((f_info->flag & ICE_FLTR_TX) &&
- (f_info->fltr_act == ICE_FWD_TO_VSI ||
- f_info->fltr_act == ICE_FWD_TO_VSI_LIST ||
- f_info->fltr_act == ICE_FWD_TO_Q ||
- f_info->fltr_act == ICE_FWD_TO_QGRP)) {
- f_info->lb_en = true;
- if (!(hw->evb_veb && f_info->lkup_type == ICE_SW_LKUP_MAC &&
- is_unicast_ether_addr(f_info->l_data.mac.mac_addr)))
- f_info->lan_en = true;
- }
- }
- /**
- * ice_fill_sw_rule - Helper function to fill switch rule structure
- * @hw: pointer to the hardware structure
- * @f_info: entry containing packet forwarding information
- * @s_rule: switch rule structure to be filled in based on mac_entry
- * @opc: switch rules population command type - pass in the command opcode
- */
- static void
- ice_fill_sw_rule(struct ice_hw *hw, struct ice_fltr_info *f_info,
- struct ice_aqc_sw_rules_elem *s_rule, enum ice_adminq_opc opc)
- {
- u16 vlan_id = ICE_MAX_VLAN_ID + 1;
- void *daddr = NULL;
- u16 eth_hdr_sz;
- u8 *eth_hdr;
- u32 act = 0;
- __be16 *off;
- if (opc == ice_aqc_opc_remove_sw_rules) {
- s_rule->pdata.lkup_tx_rx.act = 0;
- s_rule->pdata.lkup_tx_rx.index =
- cpu_to_le16(f_info->fltr_rule_id);
- s_rule->pdata.lkup_tx_rx.hdr_len = 0;
- return;
- }
- eth_hdr_sz = sizeof(dummy_eth_header);
- eth_hdr = s_rule->pdata.lkup_tx_rx.hdr;
- /* initialize the ether header with a dummy header */
- memcpy(eth_hdr, dummy_eth_header, eth_hdr_sz);
- ice_fill_sw_info(hw, f_info);
- switch (f_info->fltr_act) {
- case ICE_FWD_TO_VSI:
- act |= (f_info->fwd_id.hw_vsi_id << ICE_SINGLE_ACT_VSI_ID_S) &
- ICE_SINGLE_ACT_VSI_ID_M;
- if (f_info->lkup_type != ICE_SW_LKUP_VLAN)
- act |= ICE_SINGLE_ACT_VSI_FORWARDING |
- ICE_SINGLE_ACT_VALID_BIT;
- break;
- case ICE_FWD_TO_VSI_LIST:
- act |= ICE_SINGLE_ACT_VSI_LIST;
- act |= (f_info->fwd_id.vsi_list_id <<
- ICE_SINGLE_ACT_VSI_LIST_ID_S) &
- ICE_SINGLE_ACT_VSI_LIST_ID_M;
- if (f_info->lkup_type != ICE_SW_LKUP_VLAN)
- act |= ICE_SINGLE_ACT_VSI_FORWARDING |
- ICE_SINGLE_ACT_VALID_BIT;
- break;
- case ICE_FWD_TO_Q:
- act |= ICE_SINGLE_ACT_TO_Q;
- act |= (f_info->fwd_id.q_id << ICE_SINGLE_ACT_Q_INDEX_S) &
- ICE_SINGLE_ACT_Q_INDEX_M;
- break;
- case ICE_FWD_TO_QGRP:
- act |= ICE_SINGLE_ACT_TO_Q;
- act |= (f_info->qgrp_size << ICE_SINGLE_ACT_Q_REGION_S) &
- ICE_SINGLE_ACT_Q_REGION_M;
- break;
- case ICE_DROP_PACKET:
- act |= ICE_SINGLE_ACT_VSI_FORWARDING | ICE_SINGLE_ACT_DROP;
- break;
- default:
- return;
- }
- if (f_info->lb_en)
- act |= ICE_SINGLE_ACT_LB_ENABLE;
- if (f_info->lan_en)
- act |= ICE_SINGLE_ACT_LAN_ENABLE;
- switch (f_info->lkup_type) {
- case ICE_SW_LKUP_MAC:
- daddr = f_info->l_data.mac.mac_addr;
- break;
- case ICE_SW_LKUP_VLAN:
- vlan_id = f_info->l_data.vlan.vlan_id;
- if (f_info->fltr_act == ICE_FWD_TO_VSI ||
- f_info->fltr_act == ICE_FWD_TO_VSI_LIST) {
- act |= ICE_SINGLE_ACT_PRUNE;
- act |= ICE_SINGLE_ACT_EGRESS | ICE_SINGLE_ACT_INGRESS;
- }
- break;
- case ICE_SW_LKUP_ETHERTYPE_MAC:
- daddr = f_info->l_data.ethertype_mac.mac_addr;
- /* fall-through */
- case ICE_SW_LKUP_ETHERTYPE:
- off = (__be16 *)(eth_hdr + ICE_ETH_ETHTYPE_OFFSET);
- *off = cpu_to_be16(f_info->l_data.ethertype_mac.ethertype);
- break;
- case ICE_SW_LKUP_MAC_VLAN:
- daddr = f_info->l_data.mac_vlan.mac_addr;
- vlan_id = f_info->l_data.mac_vlan.vlan_id;
- break;
- case ICE_SW_LKUP_PROMISC_VLAN:
- vlan_id = f_info->l_data.mac_vlan.vlan_id;
- /* fall-through */
- case ICE_SW_LKUP_PROMISC:
- daddr = f_info->l_data.mac_vlan.mac_addr;
- break;
- default:
- break;
- }
- s_rule->type = (f_info->flag & ICE_FLTR_RX) ?
- cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX) :
- cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_TX);
- /* Recipe set depending on lookup type */
- s_rule->pdata.lkup_tx_rx.recipe_id = cpu_to_le16(f_info->lkup_type);
- s_rule->pdata.lkup_tx_rx.src = cpu_to_le16(f_info->src);
- s_rule->pdata.lkup_tx_rx.act = cpu_to_le32(act);
- if (daddr)
- ether_addr_copy(eth_hdr + ICE_ETH_DA_OFFSET, daddr);
- if (!(vlan_id > ICE_MAX_VLAN_ID)) {
- off = (__be16 *)(eth_hdr + ICE_ETH_VLAN_TCI_OFFSET);
- *off = cpu_to_be16(vlan_id);
- }
- /* Create the switch rule with the final dummy Ethernet header */
- if (opc != ice_aqc_opc_update_sw_rules)
- s_rule->pdata.lkup_tx_rx.hdr_len = cpu_to_le16(eth_hdr_sz);
- }
- /**
- * ice_add_marker_act
- * @hw: pointer to the hardware structure
- * @m_ent: the management entry for which sw marker needs to be added
- * @sw_marker: sw marker to tag the Rx descriptor with
- * @l_id: large action resource id
- *
- * Create a large action to hold software marker and update the switch rule
- * entry pointed by m_ent with newly created large action
- */
- static enum ice_status
- ice_add_marker_act(struct ice_hw *hw, struct ice_fltr_mgmt_list_entry *m_ent,
- u16 sw_marker, u16 l_id)
- {
- struct ice_aqc_sw_rules_elem *lg_act, *rx_tx;
- /* For software marker we need 3 large actions
- * 1. FWD action: FWD TO VSI or VSI LIST
- * 2. GENERIC VALUE action to hold the profile id
- * 3. GENERIC VALUE action to hold the software marker id
- */
- const u16 num_lg_acts = 3;
- enum ice_status status;
- u16 lg_act_size;
- u16 rules_size;
- u32 act;
- u16 id;
- if (m_ent->fltr_info.lkup_type != ICE_SW_LKUP_MAC)
- return ICE_ERR_PARAM;
- /* Create two back-to-back switch rules and submit them to the HW using
- * one memory buffer:
- * 1. Large Action
- * 2. Look up tx rx
- */
- lg_act_size = (u16)ICE_SW_RULE_LG_ACT_SIZE(num_lg_acts);
- rules_size = lg_act_size + ICE_SW_RULE_RX_TX_ETH_HDR_SIZE;
- lg_act = devm_kzalloc(ice_hw_to_dev(hw), rules_size, GFP_KERNEL);
- if (!lg_act)
- return ICE_ERR_NO_MEMORY;
- rx_tx = (struct ice_aqc_sw_rules_elem *)((u8 *)lg_act + lg_act_size);
- /* Fill in the first switch rule i.e. large action */
- lg_act->type = cpu_to_le16(ICE_AQC_SW_RULES_T_LG_ACT);
- lg_act->pdata.lg_act.index = cpu_to_le16(l_id);
- lg_act->pdata.lg_act.size = cpu_to_le16(num_lg_acts);
- /* First action VSI forwarding or VSI list forwarding depending on how
- * many VSIs
- */
- id = (m_ent->vsi_count > 1) ? m_ent->fltr_info.fwd_id.vsi_list_id :
- m_ent->fltr_info.fwd_id.hw_vsi_id;
- act = ICE_LG_ACT_VSI_FORWARDING | ICE_LG_ACT_VALID_BIT;
- act |= (id << ICE_LG_ACT_VSI_LIST_ID_S) &
- ICE_LG_ACT_VSI_LIST_ID_M;
- if (m_ent->vsi_count > 1)
- act |= ICE_LG_ACT_VSI_LIST;
- lg_act->pdata.lg_act.act[0] = cpu_to_le32(act);
- /* Second action descriptor type */
- act = ICE_LG_ACT_GENERIC;
- act |= (1 << ICE_LG_ACT_GENERIC_VALUE_S) & ICE_LG_ACT_GENERIC_VALUE_M;
- lg_act->pdata.lg_act.act[1] = cpu_to_le32(act);
- act = (ICE_LG_ACT_GENERIC_OFF_RX_DESC_PROF_IDX <<
- ICE_LG_ACT_GENERIC_OFFSET_S) & ICE_LG_ACT_GENERIC_OFFSET_M;
- /* Third action Marker value */
- act |= ICE_LG_ACT_GENERIC;
- act |= (sw_marker << ICE_LG_ACT_GENERIC_VALUE_S) &
- ICE_LG_ACT_GENERIC_VALUE_M;
- lg_act->pdata.lg_act.act[2] = cpu_to_le32(act);
- /* call the fill switch rule to fill the lookup tx rx structure */
- ice_fill_sw_rule(hw, &m_ent->fltr_info, rx_tx,
- ice_aqc_opc_update_sw_rules);
- /* Update the action to point to the large action id */
- rx_tx->pdata.lkup_tx_rx.act =
- cpu_to_le32(ICE_SINGLE_ACT_PTR |
- ((l_id << ICE_SINGLE_ACT_PTR_VAL_S) &
- ICE_SINGLE_ACT_PTR_VAL_M));
- /* Use the filter rule id of the previously created rule with single
- * act. Once the update happens, hardware will treat this as large
- * action
- */
- rx_tx->pdata.lkup_tx_rx.index =
- cpu_to_le16(m_ent->fltr_info.fltr_rule_id);
- status = ice_aq_sw_rules(hw, lg_act, rules_size, 2,
- ice_aqc_opc_update_sw_rules, NULL);
- if (!status) {
- m_ent->lg_act_idx = l_id;
- m_ent->sw_marker_id = sw_marker;
- }
- devm_kfree(ice_hw_to_dev(hw), lg_act);
- return status;
- }
- /**
- * ice_create_vsi_list_map
- * @hw: pointer to the hardware structure
- * @vsi_handle_arr: array of VSI handles to set in the VSI mapping
- * @num_vsi: number of VSI handles in the array
- * @vsi_list_id: VSI list id generated as part of allocate resource
- *
- * Helper function to create a new entry of VSI list id to VSI mapping
- * using the given VSI list id
- */
- static struct ice_vsi_list_map_info *
- ice_create_vsi_list_map(struct ice_hw *hw, u16 *vsi_handle_arr, u16 num_vsi,
- u16 vsi_list_id)
- {
- struct ice_switch_info *sw = hw->switch_info;
- struct ice_vsi_list_map_info *v_map;
- int i;
- v_map = devm_kcalloc(ice_hw_to_dev(hw), 1, sizeof(*v_map), GFP_KERNEL);
- if (!v_map)
- return NULL;
- v_map->vsi_list_id = vsi_list_id;
- v_map->ref_cnt = 1;
- for (i = 0; i < num_vsi; i++)
- set_bit(vsi_handle_arr[i], v_map->vsi_map);
- list_add(&v_map->list_entry, &sw->vsi_list_map_head);
- return v_map;
- }
- /**
- * ice_update_vsi_list_rule
- * @hw: pointer to the hardware structure
- * @vsi_handle_arr: array of VSI handles to form a VSI list
- * @num_vsi: number of VSI handles in the array
- * @vsi_list_id: VSI list id generated as part of allocate resource
- * @remove: Boolean value to indicate if this is a remove action
- * @opc: switch rules population command type - pass in the command opcode
- * @lkup_type: lookup type of the filter
- *
- * Call AQ command to add a new switch rule or update existing switch rule
- * using the given VSI list id
- */
- static enum ice_status
- ice_update_vsi_list_rule(struct ice_hw *hw, u16 *vsi_handle_arr, u16 num_vsi,
- u16 vsi_list_id, bool remove, enum ice_adminq_opc opc,
- enum ice_sw_lkup_type lkup_type)
- {
- struct ice_aqc_sw_rules_elem *s_rule;
- enum ice_status status;
- u16 s_rule_size;
- u16 type;
- int i;
- if (!num_vsi)
- return ICE_ERR_PARAM;
- if (lkup_type == ICE_SW_LKUP_MAC ||
- lkup_type == ICE_SW_LKUP_MAC_VLAN ||
- lkup_type == ICE_SW_LKUP_ETHERTYPE ||
- lkup_type == ICE_SW_LKUP_ETHERTYPE_MAC ||
- lkup_type == ICE_SW_LKUP_PROMISC ||
- lkup_type == ICE_SW_LKUP_PROMISC_VLAN)
- type = remove ? ICE_AQC_SW_RULES_T_VSI_LIST_CLEAR :
- ICE_AQC_SW_RULES_T_VSI_LIST_SET;
- else if (lkup_type == ICE_SW_LKUP_VLAN)
- type = remove ? ICE_AQC_SW_RULES_T_PRUNE_LIST_CLEAR :
- ICE_AQC_SW_RULES_T_PRUNE_LIST_SET;
- else
- return ICE_ERR_PARAM;
- s_rule_size = (u16)ICE_SW_RULE_VSI_LIST_SIZE(num_vsi);
- s_rule = devm_kzalloc(ice_hw_to_dev(hw), s_rule_size, GFP_KERNEL);
- if (!s_rule)
- return ICE_ERR_NO_MEMORY;
- for (i = 0; i < num_vsi; i++) {
- if (!ice_is_vsi_valid(hw, vsi_handle_arr[i])) {
- status = ICE_ERR_PARAM;
- goto exit;
- }
- /* AQ call requires hw_vsi_id(s) */
- s_rule->pdata.vsi_list.vsi[i] =
- cpu_to_le16(ice_get_hw_vsi_num(hw, vsi_handle_arr[i]));
- }
- s_rule->type = cpu_to_le16(type);
- s_rule->pdata.vsi_list.number_vsi = cpu_to_le16(num_vsi);
- s_rule->pdata.vsi_list.index = cpu_to_le16(vsi_list_id);
- status = ice_aq_sw_rules(hw, s_rule, s_rule_size, 1, opc, NULL);
- exit:
- devm_kfree(ice_hw_to_dev(hw), s_rule);
- return status;
- }
- /**
- * ice_create_vsi_list_rule - Creates and populates a VSI list rule
- * @hw: pointer to the hw struct
- * @vsi_handle_arr: array of VSI handles to form a VSI list
- * @num_vsi: number of VSI handles in the array
- * @vsi_list_id: stores the ID of the VSI list to be created
- * @lkup_type: switch rule filter's lookup type
- */
- static enum ice_status
- ice_create_vsi_list_rule(struct ice_hw *hw, u16 *vsi_handle_arr, u16 num_vsi,
- u16 *vsi_list_id, enum ice_sw_lkup_type lkup_type)
- {
- enum ice_status status;
- status = ice_aq_alloc_free_vsi_list(hw, vsi_list_id, lkup_type,
- ice_aqc_opc_alloc_res);
- if (status)
- return status;
- /* Update the newly created VSI list to include the specified VSIs */
- return ice_update_vsi_list_rule(hw, vsi_handle_arr, num_vsi,
- *vsi_list_id, false,
- ice_aqc_opc_add_sw_rules, lkup_type);
- }
- /**
- * ice_create_pkt_fwd_rule
- * @hw: pointer to the hardware structure
- * @f_entry: entry containing packet forwarding information
- *
- * Create switch rule with given filter information and add an entry
- * to the corresponding filter management list to track this switch rule
- * and VSI mapping
- */
- static enum ice_status
- ice_create_pkt_fwd_rule(struct ice_hw *hw,
- struct ice_fltr_list_entry *f_entry)
- {
- struct ice_fltr_mgmt_list_entry *fm_entry;
- struct ice_aqc_sw_rules_elem *s_rule;
- enum ice_sw_lkup_type l_type;
- struct ice_sw_recipe *recp;
- enum ice_status status;
- s_rule = devm_kzalloc(ice_hw_to_dev(hw),
- ICE_SW_RULE_RX_TX_ETH_HDR_SIZE, GFP_KERNEL);
- if (!s_rule)
- return ICE_ERR_NO_MEMORY;
- fm_entry = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*fm_entry),
- GFP_KERNEL);
- if (!fm_entry) {
- status = ICE_ERR_NO_MEMORY;
- goto ice_create_pkt_fwd_rule_exit;
- }
- fm_entry->fltr_info = f_entry->fltr_info;
- /* Initialize all the fields for the management entry */
- fm_entry->vsi_count = 1;
- fm_entry->lg_act_idx = ICE_INVAL_LG_ACT_INDEX;
- fm_entry->sw_marker_id = ICE_INVAL_SW_MARKER_ID;
- fm_entry->counter_index = ICE_INVAL_COUNTER_ID;
- ice_fill_sw_rule(hw, &fm_entry->fltr_info, s_rule,
- ice_aqc_opc_add_sw_rules);
- status = ice_aq_sw_rules(hw, s_rule, ICE_SW_RULE_RX_TX_ETH_HDR_SIZE, 1,
- ice_aqc_opc_add_sw_rules, NULL);
- if (status) {
- devm_kfree(ice_hw_to_dev(hw), fm_entry);
- goto ice_create_pkt_fwd_rule_exit;
- }
- f_entry->fltr_info.fltr_rule_id =
- le16_to_cpu(s_rule->pdata.lkup_tx_rx.index);
- fm_entry->fltr_info.fltr_rule_id =
- le16_to_cpu(s_rule->pdata.lkup_tx_rx.index);
- /* The book keeping entries will get removed when base driver
- * calls remove filter AQ command
- */
- l_type = fm_entry->fltr_info.lkup_type;
- recp = &hw->switch_info->recp_list[l_type];
- list_add(&fm_entry->list_entry, &recp->filt_rules);
- ice_create_pkt_fwd_rule_exit:
- devm_kfree(ice_hw_to_dev(hw), s_rule);
- return status;
- }
- /**
- * ice_update_pkt_fwd_rule
- * @hw: pointer to the hardware structure
- * @f_info: filter information for switch rule
- *
- * Call AQ command to update a previously created switch rule with a
- * VSI list id
- */
- static enum ice_status
- ice_update_pkt_fwd_rule(struct ice_hw *hw, struct ice_fltr_info *f_info)
- {
- struct ice_aqc_sw_rules_elem *s_rule;
- enum ice_status status;
- s_rule = devm_kzalloc(ice_hw_to_dev(hw),
- ICE_SW_RULE_RX_TX_ETH_HDR_SIZE, GFP_KERNEL);
- if (!s_rule)
- return ICE_ERR_NO_MEMORY;
- ice_fill_sw_rule(hw, f_info, s_rule, ice_aqc_opc_update_sw_rules);
- s_rule->pdata.lkup_tx_rx.index = cpu_to_le16(f_info->fltr_rule_id);
- /* Update switch rule with new rule set to forward VSI list */
- status = ice_aq_sw_rules(hw, s_rule, ICE_SW_RULE_RX_TX_ETH_HDR_SIZE, 1,
- ice_aqc_opc_update_sw_rules, NULL);
- devm_kfree(ice_hw_to_dev(hw), s_rule);
- return status;
- }
- /**
- * ice_update_sw_rule_bridge_mode
- * @hw: pointer to the hw struct
- *
- * Updates unicast switch filter rules based on VEB/VEPA mode
- */
- enum ice_status ice_update_sw_rule_bridge_mode(struct ice_hw *hw)
- {
- struct ice_switch_info *sw = hw->switch_info;
- struct ice_fltr_mgmt_list_entry *fm_entry;
- enum ice_status status = 0;
- struct list_head *rule_head;
- struct mutex *rule_lock; /* Lock to protect filter rule list */
- rule_lock = &sw->recp_list[ICE_SW_LKUP_MAC].filt_rule_lock;
- rule_head = &sw->recp_list[ICE_SW_LKUP_MAC].filt_rules;
- mutex_lock(rule_lock);
- list_for_each_entry(fm_entry, rule_head, list_entry) {
- struct ice_fltr_info *fi = &fm_entry->fltr_info;
- u8 *addr = fi->l_data.mac.mac_addr;
- /* Update unicast Tx rules to reflect the selected
- * VEB/VEPA mode
- */
- if ((fi->flag & ICE_FLTR_TX) && is_unicast_ether_addr(addr) &&
- (fi->fltr_act == ICE_FWD_TO_VSI ||
- fi->fltr_act == ICE_FWD_TO_VSI_LIST ||
- fi->fltr_act == ICE_FWD_TO_Q ||
- fi->fltr_act == ICE_FWD_TO_QGRP)) {
- status = ice_update_pkt_fwd_rule(hw, fi);
- if (status)
- break;
- }
- }
- mutex_unlock(rule_lock);
- return status;
- }
- /**
- * ice_add_update_vsi_list
- * @hw: pointer to the hardware structure
- * @m_entry: pointer to current filter management list entry
- * @cur_fltr: filter information from the book keeping entry
- * @new_fltr: filter information with the new VSI to be added
- *
- * Call AQ command to add or update previously created VSI list with new VSI.
- *
- * Helper function to do book keeping associated with adding filter information
- * The algorithm to do the booking keeping is described below :
- * When a VSI needs to subscribe to a given filter( MAC/VLAN/Ethtype etc.)
- * if only one VSI has been added till now
- * Allocate a new VSI list and add two VSIs
- * to this list using switch rule command
- * Update the previously created switch rule with the
- * newly created VSI list id
- * if a VSI list was previously created
- * Add the new VSI to the previously created VSI list set
- * using the update switch rule command
- */
- static enum ice_status
- ice_add_update_vsi_list(struct ice_hw *hw,
- struct ice_fltr_mgmt_list_entry *m_entry,
- struct ice_fltr_info *cur_fltr,
- struct ice_fltr_info *new_fltr)
- {
- enum ice_status status = 0;
- u16 vsi_list_id = 0;
- if ((cur_fltr->fltr_act == ICE_FWD_TO_Q ||
- cur_fltr->fltr_act == ICE_FWD_TO_QGRP))
- return ICE_ERR_NOT_IMPL;
- if ((new_fltr->fltr_act == ICE_FWD_TO_Q ||
- new_fltr->fltr_act == ICE_FWD_TO_QGRP) &&
- (cur_fltr->fltr_act == ICE_FWD_TO_VSI ||
- cur_fltr->fltr_act == ICE_FWD_TO_VSI_LIST))
- return ICE_ERR_NOT_IMPL;
- if (m_entry->vsi_count < 2 && !m_entry->vsi_list_info) {
- /* Only one entry existed in the mapping and it was not already
- * a part of a VSI list. So, create a VSI list with the old and
- * new VSIs.
- */
- struct ice_fltr_info tmp_fltr;
- u16 vsi_handle_arr[2];
- /* A rule already exists with the new VSI being added */
- if (cur_fltr->fwd_id.hw_vsi_id == new_fltr->fwd_id.hw_vsi_id)
- return ICE_ERR_ALREADY_EXISTS;
- vsi_handle_arr[0] = cur_fltr->vsi_handle;
- vsi_handle_arr[1] = new_fltr->vsi_handle;
- status = ice_create_vsi_list_rule(hw, &vsi_handle_arr[0], 2,
- &vsi_list_id,
- new_fltr->lkup_type);
- if (status)
- return status;
- tmp_fltr = *new_fltr;
- tmp_fltr.fltr_rule_id = cur_fltr->fltr_rule_id;
- tmp_fltr.fltr_act = ICE_FWD_TO_VSI_LIST;
- tmp_fltr.fwd_id.vsi_list_id = vsi_list_id;
- /* Update the previous switch rule of "MAC forward to VSI" to
- * "MAC fwd to VSI list"
- */
- status = ice_update_pkt_fwd_rule(hw, &tmp_fltr);
- if (status)
- return status;
- cur_fltr->fwd_id.vsi_list_id = vsi_list_id;
- cur_fltr->fltr_act = ICE_FWD_TO_VSI_LIST;
- m_entry->vsi_list_info =
- ice_create_vsi_list_map(hw, &vsi_handle_arr[0], 2,
- vsi_list_id);
- /* If this entry was large action then the large action needs
- * to be updated to point to FWD to VSI list
- */
- if (m_entry->sw_marker_id != ICE_INVAL_SW_MARKER_ID)
- status =
- ice_add_marker_act(hw, m_entry,
- m_entry->sw_marker_id,
- m_entry->lg_act_idx);
- } else {
- u16 vsi_handle = new_fltr->vsi_handle;
- enum ice_adminq_opc opcode;
- /* A rule already exists with the new VSI being added */
- if (test_bit(vsi_handle, m_entry->vsi_list_info->vsi_map))
- return 0;
- /* Update the previously created VSI list set with
- * the new VSI id passed in
- */
- vsi_list_id = cur_fltr->fwd_id.vsi_list_id;
- opcode = ice_aqc_opc_update_sw_rules;
- status = ice_update_vsi_list_rule(hw, &vsi_handle, 1,
- vsi_list_id, false, opcode,
- new_fltr->lkup_type);
- /* update VSI list mapping info with new VSI id */
- if (!status)
- set_bit(vsi_handle, m_entry->vsi_list_info->vsi_map);
- }
- if (!status)
- m_entry->vsi_count++;
- return status;
- }
- /**
- * ice_find_rule_entry - Search a rule entry
- * @hw: pointer to the hardware structure
- * @recp_id: lookup type for which the specified rule needs to be searched
- * @f_info: rule information
- *
- * Helper function to search for a given rule entry
- * Returns pointer to entry storing the rule if found
- */
- static struct ice_fltr_mgmt_list_entry *
- ice_find_rule_entry(struct ice_hw *hw, u8 recp_id, struct ice_fltr_info *f_info)
- {
- struct ice_fltr_mgmt_list_entry *list_itr, *ret = NULL;
- struct ice_switch_info *sw = hw->switch_info;
- struct list_head *list_head;
- list_head = &sw->recp_list[recp_id].filt_rules;
- list_for_each_entry(list_itr, list_head, list_entry) {
- if (!memcmp(&f_info->l_data, &list_itr->fltr_info.l_data,
- sizeof(f_info->l_data)) &&
- f_info->flag == list_itr->fltr_info.flag) {
- ret = list_itr;
- break;
- }
- }
- return ret;
- }
- /**
- * ice_find_vsi_list_entry - Search VSI list map with VSI count 1
- * @hw: pointer to the hardware structure
- * @recp_id: lookup type for which VSI lists needs to be searched
- * @vsi_handle: VSI handle to be found in VSI list
- * @vsi_list_id: VSI list id found containing vsi_handle
- *
- * Helper function to search a VSI list with single entry containing given VSI
- * handle element. This can be extended further to search VSI list with more
- * than 1 vsi_count. Returns pointer to VSI list entry if found.
- */
- static struct ice_vsi_list_map_info *
- ice_find_vsi_list_entry(struct ice_hw *hw, u8 recp_id, u16 vsi_handle,
- u16 *vsi_list_id)
- {
- struct ice_vsi_list_map_info *map_info = NULL;
- struct ice_switch_info *sw = hw->switch_info;
- struct ice_fltr_mgmt_list_entry *list_itr;
- struct list_head *list_head;
- list_head = &sw->recp_list[recp_id].filt_rules;
- list_for_each_entry(list_itr, list_head, list_entry) {
- if (list_itr->vsi_count == 1 && list_itr->vsi_list_info) {
- map_info = list_itr->vsi_list_info;
- if (test_bit(vsi_handle, map_info->vsi_map)) {
- *vsi_list_id = map_info->vsi_list_id;
- return map_info;
- }
- }
- }
- return NULL;
- }
- /**
- * ice_add_rule_internal - add rule for a given lookup type
- * @hw: pointer to the hardware structure
- * @recp_id: lookup type (recipe id) for which rule has to be added
- * @f_entry: structure containing MAC forwarding information
- *
- * Adds or updates the rule lists for a given recipe
- */
- static enum ice_status
- ice_add_rule_internal(struct ice_hw *hw, u8 recp_id,
- struct ice_fltr_list_entry *f_entry)
- {
- struct ice_switch_info *sw = hw->switch_info;
- struct ice_fltr_info *new_fltr, *cur_fltr;
- struct ice_fltr_mgmt_list_entry *m_entry;
- struct mutex *rule_lock; /* Lock to protect filter rule list */
- enum ice_status status = 0;
- if (!ice_is_vsi_valid(hw, f_entry->fltr_info.vsi_handle))
- return ICE_ERR_PARAM;
- f_entry->fltr_info.fwd_id.hw_vsi_id =
- ice_get_hw_vsi_num(hw, f_entry->fltr_info.vsi_handle);
- rule_lock = &sw->recp_list[recp_id].filt_rule_lock;
- mutex_lock(rule_lock);
- new_fltr = &f_entry->fltr_info;
- if (new_fltr->flag & ICE_FLTR_RX)
- new_fltr->src = hw->port_info->lport;
- else if (new_fltr->flag & ICE_FLTR_TX)
- new_fltr->src = f_entry->fltr_info.fwd_id.hw_vsi_id;
- m_entry = ice_find_rule_entry(hw, recp_id, new_fltr);
- if (!m_entry) {
- mutex_unlock(rule_lock);
- return ice_create_pkt_fwd_rule(hw, f_entry);
- }
- cur_fltr = &m_entry->fltr_info;
- status = ice_add_update_vsi_list(hw, m_entry, cur_fltr, new_fltr);
- mutex_unlock(rule_lock);
- return status;
- }
- /**
- * ice_remove_vsi_list_rule
- * @hw: pointer to the hardware structure
- * @vsi_list_id: VSI list id generated as part of allocate resource
- * @lkup_type: switch rule filter lookup type
- *
- * The VSI list should be emptied before this function is called to remove the
- * VSI list.
- */
- static enum ice_status
- ice_remove_vsi_list_rule(struct ice_hw *hw, u16 vsi_list_id,
- enum ice_sw_lkup_type lkup_type)
- {
- struct ice_aqc_sw_rules_elem *s_rule;
- enum ice_status status;
- u16 s_rule_size;
- s_rule_size = (u16)ICE_SW_RULE_VSI_LIST_SIZE(0);
- s_rule = devm_kzalloc(ice_hw_to_dev(hw), s_rule_size, GFP_KERNEL);
- if (!s_rule)
- return ICE_ERR_NO_MEMORY;
- s_rule->type = cpu_to_le16(ICE_AQC_SW_RULES_T_VSI_LIST_CLEAR);
- s_rule->pdata.vsi_list.index = cpu_to_le16(vsi_list_id);
- /* Free the vsi_list resource that we allocated. It is assumed that the
- * list is empty at this point.
- */
- status = ice_aq_alloc_free_vsi_list(hw, &vsi_list_id, lkup_type,
- ice_aqc_opc_free_res);
- devm_kfree(ice_hw_to_dev(hw), s_rule);
- return status;
- }
- /**
- * ice_rem_update_vsi_list
- * @hw: pointer to the hardware structure
- * @vsi_handle: VSI handle of the VSI to remove
- * @fm_list: filter management entry for which the VSI list management needs to
- * be done
- */
- static enum ice_status
- ice_rem_update_vsi_list(struct ice_hw *hw, u16 vsi_handle,
- struct ice_fltr_mgmt_list_entry *fm_list)
- {
- enum ice_sw_lkup_type lkup_type;
- enum ice_status status = 0;
- u16 vsi_list_id;
- if (fm_list->fltr_info.fltr_act != ICE_FWD_TO_VSI_LIST ||
- fm_list->vsi_count == 0)
- return ICE_ERR_PARAM;
- /* A rule with the VSI being removed does not exist */
- if (!test_bit(vsi_handle, fm_list->vsi_list_info->vsi_map))
- return ICE_ERR_DOES_NOT_EXIST;
- lkup_type = fm_list->fltr_info.lkup_type;
- vsi_list_id = fm_list->fltr_info.fwd_id.vsi_list_id;
- status = ice_update_vsi_list_rule(hw, &vsi_handle, 1, vsi_list_id, true,
- ice_aqc_opc_update_sw_rules,
- lkup_type);
- if (status)
- return status;
- fm_list->vsi_count--;
- clear_bit(vsi_handle, fm_list->vsi_list_info->vsi_map);
- if ((fm_list->vsi_count == 1 && lkup_type != ICE_SW_LKUP_VLAN) ||
- (fm_list->vsi_count == 0 && lkup_type == ICE_SW_LKUP_VLAN)) {
- struct ice_vsi_list_map_info *vsi_list_info =
- fm_list->vsi_list_info;
- u16 rem_vsi_handle;
- rem_vsi_handle = find_first_bit(vsi_list_info->vsi_map,
- ICE_MAX_VSI);
- if (!ice_is_vsi_valid(hw, rem_vsi_handle))
- return ICE_ERR_OUT_OF_RANGE;
- status = ice_update_vsi_list_rule(hw, &rem_vsi_handle, 1,
- vsi_list_id, true,
- ice_aqc_opc_update_sw_rules,
- lkup_type);
- if (status)
- return status;
- /* Remove the VSI list since it is no longer used */
- status = ice_remove_vsi_list_rule(hw, vsi_list_id, lkup_type);
- if (status)
- return status;
- /* Change the list entry action from VSI_LIST to VSI */
- fm_list->fltr_info.fltr_act = ICE_FWD_TO_VSI;
- fm_list->fltr_info.fwd_id.hw_vsi_id =
- ice_get_hw_vsi_num(hw, rem_vsi_handle);
- fm_list->fltr_info.vsi_handle = rem_vsi_handle;
- list_del(&vsi_list_info->list_entry);
- devm_kfree(ice_hw_to_dev(hw), vsi_list_info);
- fm_list->vsi_list_info = NULL;
- }
- return status;
- }
- /**
- * ice_remove_rule_internal - Remove a filter rule of a given type
- * @hw: pointer to the hardware structure
- * @recp_id: recipe id for which the rule needs to removed
- * @f_entry: rule entry containing filter information
- */
- static enum ice_status
- ice_remove_rule_internal(struct ice_hw *hw, u8 recp_id,
- struct ice_fltr_list_entry *f_entry)
- {
- struct ice_switch_info *sw = hw->switch_info;
- struct ice_fltr_mgmt_list_entry *list_elem;
- struct mutex *rule_lock; /* Lock to protect filter rule list */
- enum ice_status status = 0;
- bool remove_rule = false;
- u16 vsi_handle;
- if (!ice_is_vsi_valid(hw, f_entry->fltr_info.vsi_handle))
- return ICE_ERR_PARAM;
- f_entry->fltr_info.fwd_id.hw_vsi_id =
- ice_get_hw_vsi_num(hw, f_entry->fltr_info.vsi_handle);
- rule_lock = &sw->recp_list[recp_id].filt_rule_lock;
- mutex_lock(rule_lock);
- list_elem = ice_find_rule_entry(hw, recp_id, &f_entry->fltr_info);
- if (!list_elem) {
- status = ICE_ERR_DOES_NOT_EXIST;
- goto exit;
- }
- if (list_elem->fltr_info.fltr_act != ICE_FWD_TO_VSI_LIST) {
- remove_rule = true;
- } else if (!list_elem->vsi_list_info) {
- status = ICE_ERR_DOES_NOT_EXIST;
- goto exit;
- } else {
- if (list_elem->vsi_list_info->ref_cnt > 1)
- list_elem->vsi_list_info->ref_cnt--;
- vsi_handle = f_entry->fltr_info.vsi_handle;
- status = ice_rem_update_vsi_list(hw, vsi_handle, list_elem);
- if (status)
- goto exit;
- /* if vsi count goes to zero after updating the vsi list */
- if (list_elem->vsi_count == 0)
- remove_rule = true;
- }
- if (remove_rule) {
- /* Remove the lookup rule */
- struct ice_aqc_sw_rules_elem *s_rule;
- s_rule = devm_kzalloc(ice_hw_to_dev(hw),
- ICE_SW_RULE_RX_TX_NO_HDR_SIZE,
- GFP_KERNEL);
- if (!s_rule) {
- status = ICE_ERR_NO_MEMORY;
- goto exit;
- }
- ice_fill_sw_rule(hw, &list_elem->fltr_info, s_rule,
- ice_aqc_opc_remove_sw_rules);
- status = ice_aq_sw_rules(hw, s_rule,
- ICE_SW_RULE_RX_TX_NO_HDR_SIZE, 1,
- ice_aqc_opc_remove_sw_rules, NULL);
- if (status)
- goto exit;
- /* Remove a book keeping from the list */
- devm_kfree(ice_hw_to_dev(hw), s_rule);
- list_del(&list_elem->list_entry);
- devm_kfree(ice_hw_to_dev(hw), list_elem);
- }
- exit:
- mutex_unlock(rule_lock);
- return status;
- }
- /**
- * ice_add_mac - Add a MAC address based filter rule
- * @hw: pointer to the hardware structure
- * @m_list: list of MAC addresses and forwarding information
- *
- * IMPORTANT: When the ucast_shared flag is set to false and m_list has
- * multiple unicast addresses, the function assumes that all the
- * addresses are unique in a given add_mac call. It doesn't
- * check for duplicates in this case, removing duplicates from a given
- * list should be taken care of in the caller of this function.
- */
- enum ice_status
- ice_add_mac(struct ice_hw *hw, struct list_head *m_list)
- {
- struct ice_aqc_sw_rules_elem *s_rule, *r_iter;
- struct ice_fltr_list_entry *m_list_itr;
- struct list_head *rule_head;
- u16 elem_sent, total_elem_left;
- struct ice_switch_info *sw;
- struct mutex *rule_lock; /* Lock to protect filter rule list */
- enum ice_status status = 0;
- u16 num_unicast = 0;
- u16 s_rule_size;
- if (!m_list || !hw)
- return ICE_ERR_PARAM;
- s_rule = NULL;
- sw = hw->switch_info;
- rule_lock = &sw->recp_list[ICE_SW_LKUP_MAC].filt_rule_lock;
- list_for_each_entry(m_list_itr, m_list, list_entry) {
- u8 *add = &m_list_itr->fltr_info.l_data.mac.mac_addr[0];
- u16 vsi_handle;
- u16 hw_vsi_id;
- m_list_itr->fltr_info.flag = ICE_FLTR_TX;
- vsi_handle = m_list_itr->fltr_info.vsi_handle;
- if (!ice_is_vsi_valid(hw, vsi_handle))
- return ICE_ERR_PARAM;
- hw_vsi_id = ice_get_hw_vsi_num(hw, vsi_handle);
- m_list_itr->fltr_info.fwd_id.hw_vsi_id = hw_vsi_id;
- /* update the src in case it is vsi num */
- if (m_list_itr->fltr_info.src_id != ICE_SRC_ID_VSI)
- return ICE_ERR_PARAM;
- m_list_itr->fltr_info.src = hw_vsi_id;
- if (m_list_itr->fltr_info.lkup_type != ICE_SW_LKUP_MAC ||
- is_zero_ether_addr(add))
- return ICE_ERR_PARAM;
- if (is_unicast_ether_addr(add) && !hw->ucast_shared) {
- /* Don't overwrite the unicast address */
- mutex_lock(rule_lock);
- if (ice_find_rule_entry(hw, ICE_SW_LKUP_MAC,
- &m_list_itr->fltr_info)) {
- mutex_unlock(rule_lock);
- return ICE_ERR_ALREADY_EXISTS;
- }
- mutex_unlock(rule_lock);
- num_unicast++;
- } else if (is_multicast_ether_addr(add) ||
- (is_unicast_ether_addr(add) && hw->ucast_shared)) {
- m_list_itr->status =
- ice_add_rule_internal(hw, ICE_SW_LKUP_MAC,
- m_list_itr);
- if (m_list_itr->status)
- return m_list_itr->status;
- }
- }
- mutex_lock(rule_lock);
- /* Exit if no suitable entries were found for adding bulk switch rule */
- if (!num_unicast) {
- status = 0;
- goto ice_add_mac_exit;
- }
- rule_head = &sw->recp_list[ICE_SW_LKUP_MAC].filt_rules;
- /* Allocate switch rule buffer for the bulk update for unicast */
- s_rule_size = ICE_SW_RULE_RX_TX_ETH_HDR_SIZE;
- s_rule = devm_kcalloc(ice_hw_to_dev(hw), num_unicast, s_rule_size,
- GFP_KERNEL);
- if (!s_rule) {
- status = ICE_ERR_NO_MEMORY;
- goto ice_add_mac_exit;
- }
- r_iter = s_rule;
- list_for_each_entry(m_list_itr, m_list, list_entry) {
- struct ice_fltr_info *f_info = &m_list_itr->fltr_info;
- u8 *mac_addr = &f_info->l_data.mac.mac_addr[0];
- if (is_unicast_ether_addr(mac_addr)) {
- ice_fill_sw_rule(hw, &m_list_itr->fltr_info, r_iter,
- ice_aqc_opc_add_sw_rules);
- r_iter = (struct ice_aqc_sw_rules_elem *)
- ((u8 *)r_iter + s_rule_size);
- }
- }
- /* Call AQ bulk switch rule update for all unicast addresses */
- r_iter = s_rule;
- /* Call AQ switch rule in AQ_MAX chunk */
- for (total_elem_left = num_unicast; total_elem_left > 0;
- total_elem_left -= elem_sent) {
- struct ice_aqc_sw_rules_elem *entry = r_iter;
- elem_sent = min(total_elem_left,
- (u16)(ICE_AQ_MAX_BUF_LEN / s_rule_size));
- status = ice_aq_sw_rules(hw, entry, elem_sent * s_rule_size,
- elem_sent, ice_aqc_opc_add_sw_rules,
- NULL);
- if (status)
- goto ice_add_mac_exit;
- r_iter = (struct ice_aqc_sw_rules_elem *)
- ((u8 *)r_iter + (elem_sent * s_rule_size));
- }
- /* Fill up rule id based on the value returned from FW */
- r_iter = s_rule;
- list_for_each_entry(m_list_itr, m_list, list_entry) {
- struct ice_fltr_info *f_info = &m_list_itr->fltr_info;
- u8 *mac_addr = &f_info->l_data.mac.mac_addr[0];
- struct ice_fltr_mgmt_list_entry *fm_entry;
- if (is_unicast_ether_addr(mac_addr)) {
- f_info->fltr_rule_id =
- le16_to_cpu(r_iter->pdata.lkup_tx_rx.index);
- f_info->fltr_act = ICE_FWD_TO_VSI;
- /* Create an entry to track this MAC address */
- fm_entry = devm_kzalloc(ice_hw_to_dev(hw),
- sizeof(*fm_entry), GFP_KERNEL);
- if (!fm_entry) {
- status = ICE_ERR_NO_MEMORY;
- goto ice_add_mac_exit;
- }
- fm_entry->fltr_info = *f_info;
- fm_entry->vsi_count = 1;
- /* The book keeping entries will get removed when
- * base driver calls remove filter AQ command
- */
- list_add(&fm_entry->list_entry, rule_head);
- r_iter = (struct ice_aqc_sw_rules_elem *)
- ((u8 *)r_iter + s_rule_size);
- }
- }
- ice_add_mac_exit:
- mutex_unlock(rule_lock);
- if (s_rule)
- devm_kfree(ice_hw_to_dev(hw), s_rule);
- return status;
- }
- /**
- * ice_add_vlan_internal - Add one VLAN based filter rule
- * @hw: pointer to the hardware structure
- * @f_entry: filter entry containing one VLAN information
- */
- static enum ice_status
- ice_add_vlan_internal(struct ice_hw *hw, struct ice_fltr_list_entry *f_entry)
- {
- struct ice_switch_info *sw = hw->switch_info;
- struct ice_fltr_mgmt_list_entry *v_list_itr;
- struct ice_fltr_info *new_fltr, *cur_fltr;
- enum ice_sw_lkup_type lkup_type;
- u16 vsi_list_id = 0, vsi_handle;
- struct mutex *rule_lock; /* Lock to protect filter rule list */
- enum ice_status status = 0;
- if (!ice_is_vsi_valid(hw, f_entry->fltr_info.vsi_handle))
- return ICE_ERR_PARAM;
- f_entry->fltr_info.fwd_id.hw_vsi_id =
- ice_get_hw_vsi_num(hw, f_entry->fltr_info.vsi_handle);
- new_fltr = &f_entry->fltr_info;
- /* VLAN id should only be 12 bits */
- if (new_fltr->l_data.vlan.vlan_id > ICE_MAX_VLAN_ID)
- return ICE_ERR_PARAM;
- if (new_fltr->src_id != ICE_SRC_ID_VSI)
- return ICE_ERR_PARAM;
- new_fltr->src = new_fltr->fwd_id.hw_vsi_id;
- lkup_type = new_fltr->lkup_type;
- vsi_handle = new_fltr->vsi_handle;
- rule_lock = &sw->recp_list[ICE_SW_LKUP_VLAN].filt_rule_lock;
- mutex_lock(rule_lock);
- v_list_itr = ice_find_rule_entry(hw, ICE_SW_LKUP_VLAN, new_fltr);
- if (!v_list_itr) {
- struct ice_vsi_list_map_info *map_info = NULL;
- if (new_fltr->fltr_act == ICE_FWD_TO_VSI) {
- /* All VLAN pruning rules use a VSI list. Check if
- * there is already a VSI list containing VSI that we
- * want to add. If found, use the same vsi_list_id for
- * this new VLAN rule or else create a new list.
- */
- map_info = ice_find_vsi_list_entry(hw, ICE_SW_LKUP_VLAN,
- vsi_handle,
- &vsi_list_id);
- if (!map_info) {
- status = ice_create_vsi_list_rule(hw,
- &vsi_handle,
- 1,
- &vsi_list_id,
- lkup_type);
- if (status)
- goto exit;
- }
- /* Convert the action to forwarding to a VSI list. */
- new_fltr->fltr_act = ICE_FWD_TO_VSI_LIST;
- new_fltr->fwd_id.vsi_list_id = vsi_list_id;
- }
- status = ice_create_pkt_fwd_rule(hw, f_entry);
- if (!status) {
- v_list_itr = ice_find_rule_entry(hw, ICE_SW_LKUP_VLAN,
- new_fltr);
- if (!v_list_itr) {
- status = ICE_ERR_DOES_NOT_EXIST;
- goto exit;
- }
- /* reuse VSI list for new rule and increment ref_cnt */
- if (map_info) {
- v_list_itr->vsi_list_info = map_info;
- map_info->ref_cnt++;
- } else {
- v_list_itr->vsi_list_info =
- ice_create_vsi_list_map(hw, &vsi_handle,
- 1, vsi_list_id);
- }
- }
- } else if (v_list_itr->vsi_list_info->ref_cnt == 1) {
- /* Update existing VSI list to add new VSI id only if it used
- * by one VLAN rule.
- */
- cur_fltr = &v_list_itr->fltr_info;
- status = ice_add_update_vsi_list(hw, v_list_itr, cur_fltr,
- new_fltr);
- } else {
- /* If VLAN rule exists and VSI list being used by this rule is
- * referenced by more than 1 VLAN rule. Then create a new VSI
- * list appending previous VSI with new VSI and update existing
- * VLAN rule to point to new VSI list id
- */
- struct ice_fltr_info tmp_fltr;
- u16 vsi_handle_arr[2];
- u16 cur_handle;
- /* Current implementation only supports reusing VSI list with
- * one VSI count. We should never hit below condition
- */
- if (v_list_itr->vsi_count > 1 &&
- v_list_itr->vsi_list_info->ref_cnt > 1) {
- ice_debug(hw, ICE_DBG_SW,
- "Invalid configuration: Optimization to reuse VSI list with more than one VSI is not being done yet\n");
- status = ICE_ERR_CFG;
- goto exit;
- }
- cur_handle =
- find_first_bit(v_list_itr->vsi_list_info->vsi_map,
- ICE_MAX_VSI);
- /* A rule already exists with the new VSI being added */
- if (cur_handle == vsi_handle) {
- status = ICE_ERR_ALREADY_EXISTS;
- goto exit;
- }
- vsi_handle_arr[0] = cur_handle;
- vsi_handle_arr[1] = vsi_handle;
- status = ice_create_vsi_list_rule(hw, &vsi_handle_arr[0], 2,
- &vsi_list_id, lkup_type);
- if (status)
- goto exit;
- tmp_fltr = v_list_itr->fltr_info;
- tmp_fltr.fltr_rule_id = v_list_itr->fltr_info.fltr_rule_id;
- tmp_fltr.fwd_id.vsi_list_id = vsi_list_id;
- tmp_fltr.fltr_act = ICE_FWD_TO_VSI_LIST;
- /* Update the previous switch rule to a new VSI list which
- * includes current VSI thats requested
- */
- status = ice_update_pkt_fwd_rule(hw, &tmp_fltr);
- if (status)
- goto exit;
- /* before overriding VSI list map info. decrement ref_cnt of
- * previous VSI list
- */
- v_list_itr->vsi_list_info->ref_cnt--;
- /* now update to newly created list */
- v_list_itr->fltr_info.fwd_id.vsi_list_id = vsi_list_id;
- v_list_itr->vsi_list_info =
- ice_create_vsi_list_map(hw, &vsi_handle_arr[0], 2,
- vsi_list_id);
- v_list_itr->vsi_count++;
- }
- exit:
- mutex_unlock(rule_lock);
- return status;
- }
- /**
- * ice_add_vlan - Add VLAN based filter rule
- * @hw: pointer to the hardware structure
- * @v_list: list of VLAN entries and forwarding information
- */
- enum ice_status
- ice_add_vlan(struct ice_hw *hw, struct list_head *v_list)
- {
- struct ice_fltr_list_entry *v_list_itr;
- if (!v_list || !hw)
- return ICE_ERR_PARAM;
- list_for_each_entry(v_list_itr, v_list, list_entry) {
- if (v_list_itr->fltr_info.lkup_type != ICE_SW_LKUP_VLAN)
- return ICE_ERR_PARAM;
- v_list_itr->fltr_info.flag = ICE_FLTR_TX;
- v_list_itr->status = ice_add_vlan_internal(hw, v_list_itr);
- if (v_list_itr->status)
- return v_list_itr->status;
- }
- return 0;
- }
- /**
- * ice_rem_sw_rule_info
- * @hw: pointer to the hardware structure
- * @rule_head: pointer to the switch list structure that we want to delete
- */
- static void
- ice_rem_sw_rule_info(struct ice_hw *hw, struct list_head *rule_head)
- {
- if (!list_empty(rule_head)) {
- struct ice_fltr_mgmt_list_entry *entry;
- struct ice_fltr_mgmt_list_entry *tmp;
- list_for_each_entry_safe(entry, tmp, rule_head, list_entry) {
- list_del(&entry->list_entry);
- devm_kfree(ice_hw_to_dev(hw), entry);
- }
- }
- }
- /**
- * ice_cfg_dflt_vsi - change state of VSI to set/clear default
- * @hw: pointer to the hardware structure
- * @vsi_handle: VSI handle to set as default
- * @set: true to add the above mentioned switch rule, false to remove it
- * @direction: ICE_FLTR_RX or ICE_FLTR_TX
- *
- * add filter rule to set/unset given VSI as default VSI for the switch
- * (represented by swid)
- */
- enum ice_status
- ice_cfg_dflt_vsi(struct ice_hw *hw, u16 vsi_handle, bool set, u8 direction)
- {
- struct ice_aqc_sw_rules_elem *s_rule;
- struct ice_fltr_info f_info;
- enum ice_adminq_opc opcode;
- enum ice_status status;
- u16 s_rule_size;
- u16 hw_vsi_id;
- if (!ice_is_vsi_valid(hw, vsi_handle))
- return ICE_ERR_PARAM;
- hw_vsi_id = ice_get_hw_vsi_num(hw, vsi_handle);
- s_rule_size = set ? ICE_SW_RULE_RX_TX_ETH_HDR_SIZE :
- ICE_SW_RULE_RX_TX_NO_HDR_SIZE;
- s_rule = devm_kzalloc(ice_hw_to_dev(hw), s_rule_size, GFP_KERNEL);
- if (!s_rule)
- return ICE_ERR_NO_MEMORY;
- memset(&f_info, 0, sizeof(f_info));
- f_info.lkup_type = ICE_SW_LKUP_DFLT;
- f_info.flag = direction;
- f_info.fltr_act = ICE_FWD_TO_VSI;
- f_info.fwd_id.hw_vsi_id = hw_vsi_id;
- if (f_info.flag & ICE_FLTR_RX) {
- f_info.src = hw->port_info->lport;
- f_info.src_id = ICE_SRC_ID_LPORT;
- if (!set)
- f_info.fltr_rule_id =
- hw->port_info->dflt_rx_vsi_rule_id;
- } else if (f_info.flag & ICE_FLTR_TX) {
- f_info.src_id = ICE_SRC_ID_VSI;
- f_info.src = hw_vsi_id;
- if (!set)
- f_info.fltr_rule_id =
- hw->port_info->dflt_tx_vsi_rule_id;
- }
- if (set)
- opcode = ice_aqc_opc_add_sw_rules;
- else
- opcode = ice_aqc_opc_remove_sw_rules;
- ice_fill_sw_rule(hw, &f_info, s_rule, opcode);
- status = ice_aq_sw_rules(hw, s_rule, s_rule_size, 1, opcode, NULL);
- if (status || !(f_info.flag & ICE_FLTR_TX_RX))
- goto out;
- if (set) {
- u16 index = le16_to_cpu(s_rule->pdata.lkup_tx_rx.index);
- if (f_info.flag & ICE_FLTR_TX) {
- hw->port_info->dflt_tx_vsi_num = hw_vsi_id;
- hw->port_info->dflt_tx_vsi_rule_id = index;
- } else if (f_info.flag & ICE_FLTR_RX) {
- hw->port_info->dflt_rx_vsi_num = hw_vsi_id;
- hw->port_info->dflt_rx_vsi_rule_id = index;
- }
- } else {
- if (f_info.flag & ICE_FLTR_TX) {
- hw->port_info->dflt_tx_vsi_num = ICE_DFLT_VSI_INVAL;
- hw->port_info->dflt_tx_vsi_rule_id = ICE_INVAL_ACT;
- } else if (f_info.flag & ICE_FLTR_RX) {
- hw->port_info->dflt_rx_vsi_num = ICE_DFLT_VSI_INVAL;
- hw->port_info->dflt_rx_vsi_rule_id = ICE_INVAL_ACT;
- }
- }
- out:
- devm_kfree(ice_hw_to_dev(hw), s_rule);
- return status;
- }
- /**
- * ice_remove_mac - remove a MAC address based filter rule
- * @hw: pointer to the hardware structure
- * @m_list: list of MAC addresses and forwarding information
- *
- * This function removes either a MAC filter rule or a specific VSI from a
- * VSI list for a multicast MAC address.
- *
- * Returns ICE_ERR_DOES_NOT_EXIST if a given entry was not added by
- * ice_add_mac. Caller should be aware that this call will only work if all
- * the entries passed into m_list were added previously. It will not attempt to
- * do a partial remove of entries that were found.
- */
- enum ice_status
- ice_remove_mac(struct ice_hw *hw, struct list_head *m_list)
- {
- struct ice_fltr_list_entry *list_itr;
- if (!m_list)
- return ICE_ERR_PARAM;
- list_for_each_entry(list_itr, m_list, list_entry) {
- enum ice_sw_lkup_type l_type = list_itr->fltr_info.lkup_type;
- if (l_type != ICE_SW_LKUP_MAC)
- return ICE_ERR_PARAM;
- list_itr->status = ice_remove_rule_internal(hw,
- ICE_SW_LKUP_MAC,
- list_itr);
- if (list_itr->status)
- return list_itr->status;
- }
- return 0;
- }
- /**
- * ice_remove_vlan - Remove VLAN based filter rule
- * @hw: pointer to the hardware structure
- * @v_list: list of VLAN entries and forwarding information
- */
- enum ice_status
- ice_remove_vlan(struct ice_hw *hw, struct list_head *v_list)
- {
- struct ice_fltr_list_entry *v_list_itr;
- if (!v_list || !hw)
- return ICE_ERR_PARAM;
- list_for_each_entry(v_list_itr, v_list, list_entry) {
- enum ice_sw_lkup_type l_type = v_list_itr->fltr_info.lkup_type;
- if (l_type != ICE_SW_LKUP_VLAN)
- return ICE_ERR_PARAM;
- v_list_itr->status = ice_remove_rule_internal(hw,
- ICE_SW_LKUP_VLAN,
- v_list_itr);
- if (v_list_itr->status)
- return v_list_itr->status;
- }
- return 0;
- }
- /**
- * ice_vsi_uses_fltr - Determine if given VSI uses specified filter
- * @fm_entry: filter entry to inspect
- * @vsi_handle: VSI handle to compare with filter info
- */
- static bool
- ice_vsi_uses_fltr(struct ice_fltr_mgmt_list_entry *fm_entry, u16 vsi_handle)
- {
- return ((fm_entry->fltr_info.fltr_act == ICE_FWD_TO_VSI &&
- fm_entry->fltr_info.vsi_handle == vsi_handle) ||
- (fm_entry->fltr_info.fltr_act == ICE_FWD_TO_VSI_LIST &&
- (test_bit(vsi_handle, fm_entry->vsi_list_info->vsi_map))));
- }
- /**
- * ice_add_entry_to_vsi_fltr_list - Add copy of fltr_list_entry to remove list
- * @hw: pointer to the hardware structure
- * @vsi_handle: VSI handle to remove filters from
- * @vsi_list_head: pointer to the list to add entry to
- * @fi: pointer to fltr_info of filter entry to copy & add
- *
- * Helper function, used when creating a list of filters to remove from
- * a specific VSI. The entry added to vsi_list_head is a COPY of the
- * original filter entry, with the exception of fltr_info.fltr_act and
- * fltr_info.fwd_id fields. These are set such that later logic can
- * extract which VSI to remove the fltr from, and pass on that information.
- */
- static enum ice_status
- ice_add_entry_to_vsi_fltr_list(struct ice_hw *hw, u16 vsi_handle,
- struct list_head *vsi_list_head,
- struct ice_fltr_info *fi)
- {
- struct ice_fltr_list_entry *tmp;
- /* this memory is freed up in the caller function
- * once filters for this VSI are removed
- */
- tmp = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*tmp), GFP_KERNEL);
- if (!tmp)
- return ICE_ERR_NO_MEMORY;
- tmp->fltr_info = *fi;
- /* Overwrite these fields to indicate which VSI to remove filter from,
- * so find and remove logic can extract the information from the
- * list entries. Note that original entries will still have proper
- * values.
- */
- tmp->fltr_info.fltr_act = ICE_FWD_TO_VSI;
- tmp->fltr_info.vsi_handle = vsi_handle;
- tmp->fltr_info.fwd_id.hw_vsi_id = ice_get_hw_vsi_num(hw, vsi_handle);
- list_add(&tmp->list_entry, vsi_list_head);
- return 0;
- }
- /**
- * ice_add_to_vsi_fltr_list - Add VSI filters to the list
- * @hw: pointer to the hardware structure
- * @vsi_handle: VSI handle to remove filters from
- * @lkup_list_head: pointer to the list that has certain lookup type filters
- * @vsi_list_head: pointer to the list pertaining to VSI with vsi_handle
- *
- * Locates all filters in lkup_list_head that are used by the given VSI,
- * and adds COPIES of those entries to vsi_list_head (intended to be used
- * to remove the listed filters).
- * Note that this means all entries in vsi_list_head must be explicitly
- * deallocated by the caller when done with list.
- */
- static enum ice_status
- ice_add_to_vsi_fltr_list(struct ice_hw *hw, u16 vsi_handle,
- struct list_head *lkup_list_head,
- struct list_head *vsi_list_head)
- {
- struct ice_fltr_mgmt_list_entry *fm_entry;
- enum ice_status status = 0;
- /* check to make sure VSI id is valid and within boundary */
- if (!ice_is_vsi_valid(hw, vsi_handle))
- return ICE_ERR_PARAM;
- list_for_each_entry(fm_entry, lkup_list_head, list_entry) {
- struct ice_fltr_info *fi;
- fi = &fm_entry->fltr_info;
- if (!ice_vsi_uses_fltr(fm_entry, vsi_handle))
- continue;
- status = ice_add_entry_to_vsi_fltr_list(hw, vsi_handle,
- vsi_list_head, fi);
- if (status)
- return status;
- }
- return status;
- }
- /**
- * ice_remove_vsi_lkup_fltr - Remove lookup type filters for a VSI
- * @hw: pointer to the hardware structure
- * @vsi_handle: VSI handle to remove filters from
- * @lkup: switch rule filter lookup type
- */
- static void
- ice_remove_vsi_lkup_fltr(struct ice_hw *hw, u16 vsi_handle,
- enum ice_sw_lkup_type lkup)
- {
- struct ice_switch_info *sw = hw->switch_info;
- struct ice_fltr_list_entry *fm_entry;
- struct list_head remove_list_head;
- struct list_head *rule_head;
- struct ice_fltr_list_entry *tmp;
- struct mutex *rule_lock; /* Lock to protect filter rule list */
- enum ice_status status;
- INIT_LIST_HEAD(&remove_list_head);
- rule_lock = &sw->recp_list[lkup].filt_rule_lock;
- rule_head = &sw->recp_list[lkup].filt_rules;
- mutex_lock(rule_lock);
- status = ice_add_to_vsi_fltr_list(hw, vsi_handle, rule_head,
- &remove_list_head);
- mutex_unlock(rule_lock);
- if (status)
- return;
- switch (lkup) {
- case ICE_SW_LKUP_MAC:
- ice_remove_mac(hw, &remove_list_head);
- break;
- case ICE_SW_LKUP_VLAN:
- ice_remove_vlan(hw, &remove_list_head);
- break;
- case ICE_SW_LKUP_MAC_VLAN:
- case ICE_SW_LKUP_ETHERTYPE:
- case ICE_SW_LKUP_ETHERTYPE_MAC:
- case ICE_SW_LKUP_PROMISC:
- case ICE_SW_LKUP_DFLT:
- case ICE_SW_LKUP_PROMISC_VLAN:
- case ICE_SW_LKUP_LAST:
- default:
- ice_debug(hw, ICE_DBG_SW, "Unsupported lookup type %d\n", lkup);
- break;
- }
- list_for_each_entry_safe(fm_entry, tmp, &remove_list_head, list_entry) {
- list_del(&fm_entry->list_entry);
- devm_kfree(ice_hw_to_dev(hw), fm_entry);
- }
- }
- /**
- * ice_remove_vsi_fltr - Remove all filters for a VSI
- * @hw: pointer to the hardware structure
- * @vsi_handle: VSI handle to remove filters from
- */
- void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_handle)
- {
- ice_remove_vsi_lkup_fltr(hw, vsi_handle, ICE_SW_LKUP_MAC);
- ice_remove_vsi_lkup_fltr(hw, vsi_handle, ICE_SW_LKUP_MAC_VLAN);
- ice_remove_vsi_lkup_fltr(hw, vsi_handle, ICE_SW_LKUP_PROMISC);
- ice_remove_vsi_lkup_fltr(hw, vsi_handle, ICE_SW_LKUP_VLAN);
- ice_remove_vsi_lkup_fltr(hw, vsi_handle, ICE_SW_LKUP_DFLT);
- ice_remove_vsi_lkup_fltr(hw, vsi_handle, ICE_SW_LKUP_ETHERTYPE);
- ice_remove_vsi_lkup_fltr(hw, vsi_handle, ICE_SW_LKUP_ETHERTYPE_MAC);
- ice_remove_vsi_lkup_fltr(hw, vsi_handle, ICE_SW_LKUP_PROMISC_VLAN);
- }
- /**
- * ice_replay_fltr - Replay all the filters stored by a specific list head
- * @hw: pointer to the hardware structure
- * @list_head: list for which filters needs to be replayed
- * @recp_id: Recipe id for which rules need to be replayed
- */
- static enum ice_status
- ice_replay_fltr(struct ice_hw *hw, u8 recp_id, struct list_head *list_head)
- {
- struct ice_fltr_mgmt_list_entry *itr;
- struct list_head l_head;
- enum ice_status status = 0;
- if (list_empty(list_head))
- return status;
- /* Move entries from the given list_head to a temporary l_head so that
- * they can be replayed. Otherwise when trying to re-add the same
- * filter, the function will return already exists
- */
- list_replace_init(list_head, &l_head);
- /* Mark the given list_head empty by reinitializing it so filters
- * could be added again by *handler
- */
- list_for_each_entry(itr, &l_head, list_entry) {
- struct ice_fltr_list_entry f_entry;
- f_entry.fltr_info = itr->fltr_info;
- if (itr->vsi_count < 2 && recp_id != ICE_SW_LKUP_VLAN) {
- status = ice_add_rule_internal(hw, recp_id, &f_entry);
- if (status)
- goto end;
- continue;
- }
- /* Add a filter per vsi separately */
- while (1) {
- u16 vsi;
- vsi = find_first_bit(itr->vsi_list_info->vsi_map,
- ICE_MAX_VSI);
- if (vsi == ICE_MAX_VSI)
- break;
- clear_bit(vsi, itr->vsi_list_info->vsi_map);
- f_entry.fltr_info.fwd_id.hw_vsi_id = vsi;
- f_entry.fltr_info.fltr_act = ICE_FWD_TO_VSI;
- if (recp_id == ICE_SW_LKUP_VLAN)
- status = ice_add_vlan_internal(hw, &f_entry);
- else
- status = ice_add_rule_internal(hw, recp_id,
- &f_entry);
- if (status)
- goto end;
- }
- }
- end:
- /* Clear the filter management list */
- ice_rem_sw_rule_info(hw, &l_head);
- return status;
- }
- /**
- * ice_replay_all_fltr - replay all filters stored in bookkeeping lists
- * @hw: pointer to the hardware structure
- *
- * NOTE: This function does not clean up partially added filters on error.
- * It is up to caller of the function to issue a reset or fail early.
- */
- enum ice_status ice_replay_all_fltr(struct ice_hw *hw)
- {
- struct ice_switch_info *sw = hw->switch_info;
- enum ice_status status = 0;
- u8 i;
- for (i = 0; i < ICE_SW_LKUP_LAST; i++) {
- struct list_head *head = &sw->recp_list[i].filt_rules;
- status = ice_replay_fltr(hw, i, head);
- if (status)
- return status;
- }
- return status;
- }
|