+static void
+ice_rss_config_xor_word(struct ice_hw *hw, u8 prof_id, u8 src, u8 dst)
+{
+ u32 s = ((src % 4) << 3); /* byte shift */
+ u32 v = dst | 0x80; /* value to program */
+ u8 i = src / 4; /* register index */
+ u32 reg;
+
+ reg = rd32(hw, GLQF_HSYMM(prof_id, i));
+ reg = (reg & ~(0xff << s)) | (v << s);
+ wr32(hw, GLQF_HSYMM(prof_id, i), reg);
+}
+
+static void
+ice_rss_config_xor(struct ice_hw *hw, u8 prof_id, u8 src, u8 dst, u8 len)
+{
+ int fv_last_word =
+ ICE_FLOW_SW_FIELD_VECTOR_MAX / ICE_FLOW_FV_EXTRACT_SZ - 1;
+ int i;
+
+ for (i = 0; i < len; i++) {
+ ice_rss_config_xor_word(hw, prof_id,
+ /* Yes, field vector in GLQF_HSYMM and
+ * GLQF_HINSET is inversed!
+ */
+ fv_last_word - (src + i),
+ fv_last_word - (dst + i));
+ ice_rss_config_xor_word(hw, prof_id,
+ fv_last_word - (dst + i),
+ fv_last_word - (src + i));
+ }
+}
+
+static void
+ice_rss_update_symm(struct ice_hw *hw,
+ struct ice_flow_prof *prof)
+{
+ struct ice_prof_map *map;
+ u8 prof_id, m;
+
+ map = ice_search_prof_id(hw, ICE_BLK_RSS, prof->id);
+ prof_id = map->prof_id;
+
+ /* clear to default */
+ for (m = 0; m < 6; m++)
+ wr32(hw, GLQF_HSYMM(prof_id, m), 0);
+ if (prof->cfg.symm) {
+ struct ice_flow_seg_info *seg =
+ &prof->segs[prof->segs_cnt - 1];
+
+ struct ice_flow_seg_xtrct *ipv4_src =
+ &seg->fields[ICE_FLOW_FIELD_IDX_IPV4_SA].xtrct;
+ struct ice_flow_seg_xtrct *ipv4_dst =
+ &seg->fields[ICE_FLOW_FIELD_IDX_IPV4_DA].xtrct;
+ struct ice_flow_seg_xtrct *ipv6_src =
+ &seg->fields[ICE_FLOW_FIELD_IDX_IPV6_SA].xtrct;
+ struct ice_flow_seg_xtrct *ipv6_dst =
+ &seg->fields[ICE_FLOW_FIELD_IDX_IPV6_DA].xtrct;
+
+ struct ice_flow_seg_xtrct *tcp_src =
+ &seg->fields[ICE_FLOW_FIELD_IDX_TCP_SRC_PORT].xtrct;
+ struct ice_flow_seg_xtrct *tcp_dst =
+ &seg->fields[ICE_FLOW_FIELD_IDX_TCP_DST_PORT].xtrct;
+
+ struct ice_flow_seg_xtrct *udp_src =
+ &seg->fields[ICE_FLOW_FIELD_IDX_UDP_SRC_PORT].xtrct;
+ struct ice_flow_seg_xtrct *udp_dst =
+ &seg->fields[ICE_FLOW_FIELD_IDX_UDP_DST_PORT].xtrct;
+
+ struct ice_flow_seg_xtrct *sctp_src =
+ &seg->fields[ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT].xtrct;
+ struct ice_flow_seg_xtrct *sctp_dst =
+ &seg->fields[ICE_FLOW_FIELD_IDX_SCTP_DST_PORT].xtrct;
+
+ /* xor IPv4 */
+ if (ipv4_src->prot_id != 0 && ipv4_dst->prot_id != 0)
+ ice_rss_config_xor(hw, prof_id,
+ ipv4_src->idx, ipv4_dst->idx, 2);
+
+ /* xor IPv6 */
+ if (ipv6_src->prot_id != 0 && ipv6_dst->prot_id != 0)
+ ice_rss_config_xor(hw, prof_id,
+ ipv6_src->idx, ipv6_dst->idx, 8);
+
+ /* xor TCP */
+ if (tcp_src->prot_id != 0 && tcp_dst->prot_id != 0)
+ ice_rss_config_xor(hw, prof_id,
+ tcp_src->idx, tcp_dst->idx, 1);
+
+ /* xor UDP */
+ if (udp_src->prot_id != 0 && udp_dst->prot_id != 0)
+ ice_rss_config_xor(hw, prof_id,
+ udp_src->idx, udp_dst->idx, 1);
+
+ /* xor SCTP */
+ if (sctp_src->prot_id != 0 && sctp_dst->prot_id != 0)
+ ice_rss_config_xor(hw, prof_id,
+ sctp_src->idx, sctp_dst->idx, 1);
+ }
+}
+