Lines Matching +full:entry +full:- +full:address
1 // SPDX-License-Identifier: GPL-2.0
8 * - Matching Rules: These registers define the criteria for matching incoming
13 * - Action Rules: These registers define how the ACL should modify the packet's
18 * - Processing Rules: These registers control the overall behavior of the ACL,
23 * +----------------------+
24 * +----------------------+ | (optional) |
27 * +----------------------+ +----------------------+
31 * +----------------------+
35 * +----------------------+
38 * +----------------------+
43 * +----------------------+
117 * ksz9477_dump_acl_index - Print the ACL entry at the specified index
120 * @acle: Pointer to the ACL entry array.
121 * @index: The index of the ACL entry to print.
123 * This function prints the details of an ACL entry, located at a particular
127 * Return: 1 if the entry is non-empty and printed, 0 otherwise.
134 u8 *entry; in ksz9477_dump_acl_index() local
137 entry = &acle[index].entry[0]; in ksz9477_dump_acl_index()
139 if (entry[i]) in ksz9477_dump_acl_index()
142 sprintf(buf + (i * 3), "%02x ", entry[i]); in ksz9477_dump_acl_index()
149 dev_err(dev->dev, " Entry %02d, prio: %02d : %s", index, in ksz9477_dump_acl_index()
156 * ksz9477_dump_acl - Print ACL entries
159 * @acle: Pointer to the ACL entry array.
170 if (count != KSZ9477_ACL_MAX_ENTRIES - 1) in ksz9477_dump_acl()
171 dev_err(dev->dev, " Empty ACL entries were skipped\n"); in ksz9477_dump_acl()
175 * ksz9477_acl_is_valid_matching_rule - Check if an ACL entry contains a valid
178 * @entry: Pointer to ACL entry buffer
180 * This function checks if the given ACL entry buffer contains a valid
185 static bool ksz9477_acl_is_valid_matching_rule(u8 *entry) in ksz9477_acl_is_valid_matching_rule() argument
189 val1 = entry[KSZ9477_ACL_PORT_ACCESS_1]; in ksz9477_acl_is_valid_matching_rule()
206 * ksz9477_acl_get_cont_entr - Get count of contiguous ACL entries and validate
210 * @index: Index of the starting ACL entry.
213 * in an ACL entry indicates which entries contain Matching rules linked to it.
216 * an entry containing a Matching rule for this RuleSet.
219 * entry links multiple Matching rules, forming what's termed a 'complex rule',
227 * - 0 if the entry is empty and can be safely overwritten
228 * - 1 if the entry represents a simple rule
229 * - The number of contiguous entries if it is the root entry of a complex
231 * - -ENOTEMPTY if the entry is part of a complex rule but not the root
232 * entry
233 * - -EINVAL if the validation fails
238 struct ksz9477_acl_priv *acl = dev->ports[port].acl_priv; in ksz9477_acl_get_cont_entr()
239 struct ksz9477_acl_entries *acles = &acl->acles; in ksz9477_acl_get_cont_entr()
243 u8 *entry; in ksz9477_acl_get_cont_entr() local
246 entry = &acles->entries[index].entry[0]; in ksz9477_acl_get_cont_entr()
247 vale = entry[KSZ9477_ACL_PORT_ACCESS_E]; in ksz9477_acl_get_cont_entr()
248 valf = entry[KSZ9477_ACL_PORT_ACCESS_F]; in ksz9477_acl_get_cont_entr()
254 if (ksz9477_acl_is_valid_matching_rule(entry)) { in ksz9477_acl_get_cont_entr()
257 * when we are trying to find a free or starting entry. in ksz9477_acl_get_cont_entr()
259 …dev_dbg(dev->dev, "ACL: entry %d starting with a valid matching rule, but no bits set in RuleSet\n… in ksz9477_acl_get_cont_entr()
261 return -ENOTEMPTY; in ksz9477_acl_get_cont_entr()
264 /* This entry does not contain a valid matching rule */ in ksz9477_acl_get_cont_entr()
272 contiguous_count = end_idx - start_idx + 1; in ksz9477_acl_get_cont_entr()
279 dev_err(dev->dev, "ACL: number of bits set in RuleSet does not match calculated count\n"); in ksz9477_acl_get_cont_entr()
280 return -EINVAL; in ksz9477_acl_get_cont_entr()
285 u8 *current_entry = &acles->entries[i].entry[0]; in ksz9477_acl_get_cont_entr()
291 dev_err(dev->dev, "ACL: entry %d does not contain a valid matching rule\n", in ksz9477_acl_get_cont_entr()
293 return -EINVAL; in ksz9477_acl_get_cont_entr()
299 /* Following entry should have empty linkage list */ in ksz9477_acl_get_cont_entr()
301 dev_err(dev->dev, "ACL: entry %d has non-empty RuleSet linkage\n", in ksz9477_acl_get_cont_entr()
303 return -EINVAL; in ksz9477_acl_get_cont_entr()
312 * ksz9477_acl_update_linkage - Update the RuleSet linkage for an ACL entry
316 * @entry: Pointer to the ACL entry array.
317 * @old_idx: The original index of the ACL entry before moving.
318 * @new_idx: The new index of the ACL entry after moving.
320 * This function updates the RuleSet linkage bits for an ACL entry when
322 * linkage is represented by two 8-bit registers, which are combined
323 * into a 16-bit value for easier manipulation. The linkage bits are shifted
330 * Returns: 0 on success, or -EINVAL if any RuleSet linkage bits are lost
333 static int ksz9477_acl_update_linkage(struct ksz_device *dev, u8 *entry, in ksz9477_acl_update_linkage() argument
341 val0 = entry[KSZ9477_ACL_PORT_ACCESS_0]; in ksz9477_acl_update_linkage()
342 vale = entry[KSZ9477_ACL_PORT_ACCESS_E]; in ksz9477_acl_update_linkage()
343 valf = entry[KSZ9477_ACL_PORT_ACCESS_F]; in ksz9477_acl_update_linkage()
350 * RuleSet is filled only for the first entry of the set. in ksz9477_acl_update_linkage()
356 dev_err(dev->dev, "ACL: entry %d has unexpected ActionRule linkage: %d\n", in ksz9477_acl_update_linkage()
358 return -EINVAL; in ksz9477_acl_update_linkage()
364 shift = new_idx - old_idx; in ksz9477_acl_update_linkage()
370 rule_linkage >>= -shift; in ksz9477_acl_update_linkage()
374 dev_err(dev->dev, "ACL RuleSet linkage bits lost during move\n"); in ksz9477_acl_update_linkage()
375 return -EINVAL; in ksz9477_acl_update_linkage()
378 entry[KSZ9477_ACL_PORT_ACCESS_0] = val0; in ksz9477_acl_update_linkage()
380 /* Update the RuleSet bitfields in the entry */ in ksz9477_acl_update_linkage()
381 entry[KSZ9477_ACL_PORT_ACCESS_E] = (rule_linkage >> 8) & 0xFF; in ksz9477_acl_update_linkage()
382 entry[KSZ9477_ACL_PORT_ACCESS_F] = rule_linkage & 0xFF; in ksz9477_acl_update_linkage()
388 * ksz9477_validate_and_get_src_count - Validate source and destination indices
389 * and determine the source entry count.
392 * @src_idx: Index of the starting ACL entry that needs to be validated.
419 dev_err(dev->dev, "ACL: invalid entry index\n"); in ksz9477_validate_and_get_src_count()
420 return -EINVAL; in ksz9477_validate_and_get_src_count()
430 dev_err(dev->dev, "ACL: source entry is empty\n"); in ksz9477_validate_and_get_src_count()
431 return -EINVAL; in ksz9477_validate_and_get_src_count()
435 dev_err(dev->dev, "ACL: Not enough space at the destination. Move operation will fail.\n"); in ksz9477_validate_and_get_src_count()
436 return -EINVAL; in ksz9477_validate_and_get_src_count()
439 /* Validate if the destination entry is empty or not in the middle of in ksz9477_validate_and_get_src_count()
451 * ksz9477_move_entries_downwards - Move a range of ACL entries downwards in
457 * @end_idx: Destination index where the first entry should be situated post
478 e = &acles->entries[i]; in ksz9477_move_entries_downwards()
479 *e = acles->entries[i + num_entries_to_move]; in ksz9477_move_entries_downwards()
481 ret = ksz9477_acl_update_linkage(dev, &e->entry[0], in ksz9477_move_entries_downwards()
491 * ksz9477_move_entries_upwards - Move a range of ACL entries upwards in the
497 * @target_idx: The destination index where the first entry should be placed
515 for (i = start_idx; i > target_idx; i--) { in ksz9477_move_entries_upwards()
516 b = i + num_entries_to_move - 1; in ksz9477_move_entries_upwards()
518 e = &acles->entries[b]; in ksz9477_move_entries_upwards()
519 *e = acles->entries[i - 1]; in ksz9477_move_entries_upwards()
521 ret = ksz9477_acl_update_linkage(dev, &e->entry[0], i - 1, b); in ksz9477_move_entries_upwards()
530 * ksz9477_acl_move_entries - Move a block of contiguous ACL entries from a
534 * @src_idx: Index of the starting source ACL entry.
535 * @dst_idx: Index of the starting destination ACL entry.
544 * Return: 0 if the move operation is successful. Returns -EINVAL for validation
551 struct ksz9477_acl_priv *acl = dev->ports[port].acl_priv; in ksz9477_acl_move_entries()
552 struct ksz9477_acl_entries *acles = &acl->acles; in ksz9477_acl_move_entries()
566 * downwards and the size of the entry located at dst_idx. in ksz9477_acl_move_entries()
569 dst_idx = dst_idx + dst_count - src_count; in ksz9477_acl_move_entries()
573 buffer[i] = acles->entries[src_idx + i]; in ksz9477_acl_move_entries()
574 ret = ksz9477_acl_update_linkage(dev, &buffer[i].entry[0], in ksz9477_acl_move_entries()
593 acles->entries[dst_idx + i] = buffer[i]; in ksz9477_acl_move_entries()
599 * ksz9477_get_next_block_start - Identify the starting index of the next ACL
611 * - The starting index of the next valid ACL block.
612 * - KSZ9477_ACL_MAX_ENTRIES if no other valid blocks are found after 'start'.
613 * - A negative error code if an error occurs while checking.
622 if (block_size < 0 && block_size != -ENOTEMPTY) in ksz9477_get_next_block_start()
634 * ksz9477_swap_acl_blocks - Swap two ACL blocks
647 * - 0 on successful swapping of blocks.
648 * - -EINVAL if the block at index 'i' is empty.
649 * - A negative error code if any other error occurs during the swap.
661 dev_err(dev->dev, "ACL: swapping empty entry %d\n", i); in ksz9477_swap_acl_blocks()
662 return -EINVAL; in ksz9477_swap_acl_blocks()
669 ret = ksz9477_acl_move_entries(dev, port, j - current_block_size, i); in ksz9477_swap_acl_blocks()
677 * ksz9477_sort_acl_entr_no_back - Sort ACL entries for a given port based on
693 * - 0 on successful sorting of entries.
694 * - A negative error code if any issue arises during sorting, e.g.,
699 struct ksz9477_acl_priv *acl = dev->ports[port].acl_priv; in ksz9477_sort_acl_entr_no_back()
700 struct ksz9477_acl_entries *acles = &acl->acles; in ksz9477_sort_acl_entr_no_back()
706 curr = &acles->entries[i]; in ksz9477_sort_acl_entr_no_back()
713 next = &acles->entries[j]; in ksz9477_sort_acl_entr_no_back()
715 if (curr->prio > next->prio) { in ksz9477_sort_acl_entr_no_back()
735 * ksz9477_sort_acl_entries - Sort the ACL entries for a given port.
750 struct ksz9477_acl_priv *acl = dev->ports[port].acl_priv; in ksz9477_sort_acl_entries()
751 struct ksz9477_acl_entries *acles = &acl->acles; in ksz9477_sort_acl_entries()
757 memcpy(backup, acles->entries, sizeof(backup)); in ksz9477_sort_acl_entries()
761 dev_err(dev->dev, "ACL: failed to sort entries for port %d\n", in ksz9477_sort_acl_entries()
763 dev_err(dev->dev, "ACL dump before sorting:\n"); in ksz9477_sort_acl_entries()
765 dev_err(dev->dev, "ACL dump after sorting:\n"); in ksz9477_sort_acl_entries()
766 ksz9477_dump_acl(dev, acles->entries); in ksz9477_sort_acl_entries()
768 memcpy(acles->entries, backup, sizeof(backup)); in ksz9477_sort_acl_entries()
775 * ksz9477_acl_wait_ready - Waits for the ACL operation to complete on a given
792 reg = dev->dev_ops->get_port_addr(port, KSZ9477_PORT_ACL_CTRL_0); in ksz9477_acl_wait_ready()
794 ret = regmap_read_poll_timeout(dev->regmap[0], reg, val, in ksz9477_acl_wait_ready()
797 dev_err(dev->dev, "Failed to read/write ACL table\n"); in ksz9477_acl_wait_ready()
803 * ksz9477_acl_entry_write - Writes an ACL entry to a given port at the
806 * @port: The port number to write the ACL entry to.
807 * @entry: A pointer to the ACL entry data.
808 * @idx: The index at which to write the ACL entry.
810 * This function writes the provided ACL entry to the specified port at the
816 static int ksz9477_acl_entry_write(struct ksz_device *dev, int port, u8 *entry, in ksz9477_acl_entry_write() argument
823 ret = ksz_pwrite8(dev, port, KSZ9477_PORT_ACL_0 + i, entry[i]); in ksz9477_acl_entry_write()
825 dev_err(dev->dev, "Failed to write ACL entry %d\n", i); in ksz9477_acl_entry_write()
841 * ksz9477_acl_port_enable - Enables ACL functionality on a given port.
849 * 0xn801 - KSZ9477S 5.2.8.2 Port Priority Control Register
850 * Bit 7 - Highest Priority
851 * Bit 6 - OR'ed Priority
852 * Bit 4 - MAC Address Priority Classification
853 * Bit 3 - VLAN Priority Classification
854 * Bit 2 - 802.1p Priority Classification
855 * Bit 1 - Diffserv Priority Classification
856 * Bit 0 - ACL Priority Classification
862 * 0xn803 - KSZ9477S 5.2.8.4 Port Authentication Control Register
863 * Bit 2 - Access Control List (ACL) Enable
864 * Bits 1:0 - Authentication Mode
897 * ksz9477_acl_port_disable - Disables ACL functionality on a given port.
920 * ksz9477_acl_write_list - Write a list of ACL entries to a given port.
933 struct ksz9477_acl_priv *acl = dev->ports[port].acl_priv; in ksz9477_acl_write_list()
934 struct ksz9477_acl_entries *acles = &acl->acles; in ksz9477_acl_write_list()
943 for (i = 0; i < ARRAY_SIZE(acles->entries); i++) { in ksz9477_acl_write_list()
944 u8 *entry = acles->entries[i].entry; in ksz9477_acl_write_list() local
946 /* Check if entry was removed and should be zeroed. in ksz9477_acl_write_list()
947 * If last fields of the entry are not zero, it means in ksz9477_acl_write_list()
951 if (i >= acles->entries_count && in ksz9477_acl_write_list()
952 entry[KSZ9477_ACL_PORT_ACCESS_10] == 0 && in ksz9477_acl_write_list()
953 entry[KSZ9477_ACL_PORT_ACCESS_11] == 0) in ksz9477_acl_write_list()
956 ret = ksz9477_acl_entry_write(dev, port, entry, i); in ksz9477_acl_write_list()
960 /* now removed entry is clean on HW side, so it can in ksz9477_acl_write_list()
963 if (i >= acles->entries_count && in ksz9477_acl_write_list()
964 entry[KSZ9477_ACL_PORT_ACCESS_10] != 0 && in ksz9477_acl_write_list()
965 entry[KSZ9477_ACL_PORT_ACCESS_11] != 0) { in ksz9477_acl_write_list()
966 entry[KSZ9477_ACL_PORT_ACCESS_10] = 0; in ksz9477_acl_write_list()
967 entry[KSZ9477_ACL_PORT_ACCESS_11] = 0; in ksz9477_acl_write_list()
971 if (!acles->entries_count) in ksz9477_acl_write_list()
978 * ksz9477_acl_remove_entries - Remove ACL entries with a given cookie from a
983 * @cookie: The cookie value to match for entry removal.
993 int entries_count = acles->entries_count; in ksz9477_acl_remove_entries()
995 int src_idx = -1; in ksz9477_acl_remove_entries()
1002 if (acles->entries[i].cookie == cookie) { in ksz9477_acl_remove_entries()
1009 if (src_idx == -1) in ksz9477_acl_remove_entries()
1012 /* Get the size of the cookie entry. We may have complex entries. */ in ksz9477_acl_remove_entries()
1017 /* Move all entries down to overwrite removed entry with the cookie */ in ksz9477_acl_remove_entries()
1020 entries_count - src_count); in ksz9477_acl_remove_entries()
1022 dev_err(dev->dev, "Failed to move ACL entries down\n"); in ksz9477_acl_remove_entries()
1030 for (i = entries_count - src_count; i < entries_count; i++) { in ksz9477_acl_remove_entries()
1031 struct ksz9477_acl_entry *entry = &acles->entries[i]; in ksz9477_acl_remove_entries() local
1033 memset(entry, 0, sizeof(*entry)); in ksz9477_acl_remove_entries()
1035 /* Set all access bits to be able to write zeroed entry to HW */ in ksz9477_acl_remove_entries()
1036 entry->entry[KSZ9477_ACL_PORT_ACCESS_10] = 0xff; in ksz9477_acl_remove_entries()
1037 entry->entry[KSZ9477_ACL_PORT_ACCESS_11] = 0xff; in ksz9477_acl_remove_entries()
1041 acles->entries_count -= src_count; in ksz9477_acl_remove_entries()
1045 * ksz9477_port_acl_init - Initialize the ACL for a specified port on a ksz
1065 return -ENOMEM; in ksz9477_port_acl_init()
1067 dev->ports[port].acl_priv = acl; in ksz9477_port_acl_init()
1069 acles = &acl->acles; in ksz9477_port_acl_init()
1071 for (i = 0; i < ARRAY_SIZE(acles->entries); i++) { in ksz9477_port_acl_init()
1072 u8 *entry = acles->entries[i].entry; in ksz9477_port_acl_init() local
1075 * entry in ksz9477_port_acl_init()
1077 entry[KSZ9477_ACL_PORT_ACCESS_10] = 0xff; in ksz9477_port_acl_init()
1078 entry[KSZ9477_ACL_PORT_ACCESS_11] = 0xff; in ksz9477_port_acl_init()
1088 kfree(dev->ports[port].acl_priv); in ksz9477_port_acl_init()
1089 dev->ports[port].acl_priv = NULL; in ksz9477_port_acl_init()
1095 * ksz9477_port_acl_free - Free the ACL resources for a specified port on a ksz
1104 if (!dev->ports[port].acl_priv) in ksz9477_port_acl_free()
1109 kfree(dev->ports[port].acl_priv); in ksz9477_port_acl_free()
1110 dev->ports[port].acl_priv = NULL; in ksz9477_port_acl_free()
1114 * ksz9477_acl_set_reg - Set entry[16] and entry[17] depending on the updated
1115 * entry[]
1116 * @entry: An array containing the entries
1117 * @reg: The register of the entry that needs to be updated
1118 * @value: The value to be assigned to the updated entry
1120 * This function updates the entry[] array based on the provided register and
1121 * value. It also sets entry[0x10] and entry[0x11] according to the ACL byte
1124 * 0x10 - Byte Enable [15:8]
1134 * 0x11 - Byte Enable [7:0]
1144 static void ksz9477_acl_set_reg(u8 *entry, enum ksz9477_acl_port_access reg, in ksz9477_acl_set_reg() argument
1149 entry[KSZ9477_ACL_PORT_ACCESS_10] |= in ksz9477_acl_set_reg()
1150 BIT(KSZ9477_ACL_PORT_ACCESS_7 - reg); in ksz9477_acl_set_reg()
1153 entry[KSZ9477_ACL_PORT_ACCESS_11] |= in ksz9477_acl_set_reg()
1154 BIT(KSZ9477_ACL_PORT_ACCESS_F - reg); in ksz9477_acl_set_reg()
1160 entry[reg] = value; in ksz9477_acl_set_reg()
1164 * ksz9477_acl_matching_rule_cfg_l2 - Configure an ACL filtering entry to match
1166 * @entry: Pointer to ACL entry buffer
1168 * @eth_addr: Pointer to Ethernet address
1169 * @is_src: If true, match the source MAC address; if false, match the
1170 * destination MAC address
1173 * entry to match Layer 2 types of Ethernet frames based on the provided
1174 * ethertype and Ethernet address. Additionally, it can match either the source
1175 * or destination MAC address depending on the value of the is_src parameter.
1180 * 0x01 - Mode and Enable
1181 * Bits 5:4 - MD (Mode)
1183 * Bits 3:2 - ENB (Enable)
1185 * 10 = Comparison is performed only on the MAC Address value
1186 * 11 = Both the MAC Address and TYPE are tested
1187 * Bit 1 - S/D (Source / Destination)
1188 * 0 = Destination address
1189 * 1 = Source address
1190 * Bit 0 - EQ (Equal / Not Equal)
1194 * 0x02-0x07 - MAC Address
1195 * 0x02 - MAC Address [47:40]
1196 * 0x03 - MAC Address [39:32]
1197 * 0x04 - MAC Address [31:24]
1198 * 0x05 - MAC Address [23:16]
1199 * 0x06 - MAC Address [15:8]
1200 * 0x07 - MAC Address [7:0]
1202 * 0x08-0x09 - EtherType
1203 * 0x08 - EtherType [15:8]
1204 * 0x09 - EtherType [7:0]
1206 static void ksz9477_acl_matching_rule_cfg_l2(u8 *entry, u16 ethertype, in ksz9477_acl_matching_rule_cfg_l2() argument
1220 ksz9477_acl_set_reg(entry, KSZ9477_ACL_PORT_ACCESS_1, val); in ksz9477_acl_matching_rule_cfg_l2()
1226 ksz9477_acl_set_reg(entry, in ksz9477_acl_matching_rule_cfg_l2()
1232 ksz9477_acl_set_reg(entry, KSZ9477_ACL_PORT_ACCESS_8, ethertype >> 8); in ksz9477_acl_matching_rule_cfg_l2()
1233 ksz9477_acl_set_reg(entry, KSZ9477_ACL_PORT_ACCESS_9, ethertype & 0xff); in ksz9477_acl_matching_rule_cfg_l2()
1237 * ksz9477_acl_action_rule_cfg - Set action for an ACL entry
1238 * @entry: Pointer to the ACL entry
1242 * This function sets the action for the specified ACL entry. It prepares
1243 * the priority mode and traffic class values and updates the entry's
1247 * ACL Action Rule Parameters for Non-Count Modes (MD ≠ 01 or ENB ≠ 00)
1249 * 0x0A - PM, P, RPE, RP[2:1]
1250 * Bits 7:6 - PM[1:0] - Priority Mode
1258 * Bits 5:3 - P[2:0] - Priority value
1259 * Bit 2 - RPE - Remark Priority Enable
1260 * Bits 1:0 - RP[2:1] - Remarked Priority value (bits 2:1)
1265 * 0x0B - RP[0], MM
1266 * Bit 7 - RP[0] - Remarked Priority value (bit 0)
1267 * Bits 6:5 - MM[1:0] - Map Mode
1270 * map from the Address Lookup Table.
1272 * map from the Address Lookup Table.
1274 * from the Address Lookup Table.
1275 * 0x0D - FORWARD[n:0]
1276 * Bits 7:0 - FORWARD[n:0] - Forwarding map. Bit 0 = port 1,
1281 void ksz9477_acl_action_rule_cfg(u8 *entry, bool force_prio, u8 prio_val) in ksz9477_acl_action_rule_cfg() argument
1292 ksz9477_acl_set_reg(entry, KSZ9477_ACL_PORT_ACCESS_A, val); in ksz9477_acl_action_rule_cfg()
1295 ksz9477_acl_set_reg(entry, KSZ9477_ACL_PORT_ACCESS_B, 0); in ksz9477_acl_action_rule_cfg()
1296 ksz9477_acl_set_reg(entry, KSZ9477_ACL_PORT_ACCESS_D, 0); in ksz9477_acl_action_rule_cfg()
1300 * ksz9477_acl_processing_rule_set_action - Set the action for the processing
1302 * @entry: Pointer to the ACL entry
1306 * appropriate register in the entry. There can be only one action per
1311 * 0x00 - First Rule Number (FRN)
1312 * Bits 3:0 - First Rule Number. Pointer to an Action rule entry.
1314 void ksz9477_acl_processing_rule_set_action(u8 *entry, u8 action_idx) in ksz9477_acl_processing_rule_set_action() argument
1316 ksz9477_acl_set_reg(entry, KSZ9477_ACL_PORT_ACCESS_0, action_idx); in ksz9477_acl_processing_rule_set_action()
1320 * ksz9477_acl_processing_rule_add_match - Add a matching rule to the rule set
1321 * @entry: Pointer to the ACL entry
1325 * appropriate bits in the entry's rule set registers.
1329 * 0x0E - RuleSet [15:8]
1330 * Bits 7:0 - RuleSet [15:8] Specifies a set of one or more Matching rule
1337 * 0x0F - RuleSet [7:0]
1338 * Bits 7:0 - RuleSet [7:0]
1340 static void ksz9477_acl_processing_rule_add_match(u8 *entry, u8 match_idx) in ksz9477_acl_processing_rule_add_match() argument
1342 u8 vale = entry[KSZ9477_ACL_PORT_ACCESS_E]; in ksz9477_acl_processing_rule_add_match()
1343 u8 valf = entry[KSZ9477_ACL_PORT_ACCESS_F]; in ksz9477_acl_processing_rule_add_match()
1348 vale |= BIT(match_idx - 8); in ksz9477_acl_processing_rule_add_match()
1350 ksz9477_acl_set_reg(entry, KSZ9477_ACL_PORT_ACCESS_E, vale); in ksz9477_acl_processing_rule_add_match()
1351 ksz9477_acl_set_reg(entry, KSZ9477_ACL_PORT_ACCESS_F, valf); in ksz9477_acl_processing_rule_add_match()
1355 * ksz9477_acl_get_init_entry - Get a new uninitialized entry for a specified
1358 * @port: The port number to get the uninitialized entry for.
1359 * @cookie: The cookie to associate with the entry.
1360 * @prio: The priority to associate with the entry.
1362 * This function retrieves the next available ACL entry for the specified port,
1365 * Returns: A pointer to the new uninitialized ACL entry.
1371 struct ksz9477_acl_priv *acl = dev->ports[port].acl_priv; in ksz9477_acl_get_init_entry()
1372 struct ksz9477_acl_entries *acles = &acl->acles; in ksz9477_acl_get_init_entry()
1373 struct ksz9477_acl_entry *entry; in ksz9477_acl_get_init_entry() local
1375 entry = &acles->entries[acles->entries_count]; in ksz9477_acl_get_init_entry()
1376 entry->cookie = cookie; in ksz9477_acl_get_init_entry()
1377 entry->prio = prio; in ksz9477_acl_get_init_entry()
1380 entry->entry[KSZ9477_ACL_PORT_ACCESS_10] = 0; in ksz9477_acl_get_init_entry()
1381 entry->entry[KSZ9477_ACL_PORT_ACCESS_11] = 0; in ksz9477_acl_get_init_entry()
1383 return entry; in ksz9477_acl_get_init_entry()
1387 * ksz9477_acl_match_process_l2 - Configure Layer 2 ACL matching rules and
1392 * @src_mac: Source MAC address.
1393 * @dst_mac: Destination MAC address.
1394 * @cookie: The cookie to associate with the entry.
1395 * @prio: The priority of the entry.
1398 * It takes into account that only one MAC per entry is supported.
1404 struct ksz9477_acl_priv *acl = dev->ports[port].acl_priv; in ksz9477_acl_match_process_l2()
1405 struct ksz9477_acl_entries *acles = &acl->acles; in ksz9477_acl_match_process_l2()
1406 struct ksz9477_acl_entry *entry; in ksz9477_acl_match_process_l2() local
1408 entry = ksz9477_acl_get_init_entry(dev, port, cookie, prio); in ksz9477_acl_match_process_l2()
1410 /* ACL supports only one MAC per entry */ in ksz9477_acl_match_process_l2()
1412 ksz9477_acl_matching_rule_cfg_l2(entry->entry, ethtype, src_mac, in ksz9477_acl_match_process_l2()
1416 ksz9477_acl_processing_rule_add_match(entry->entry, in ksz9477_acl_match_process_l2()
1417 acles->entries_count); in ksz9477_acl_match_process_l2()
1418 acles->entries_count++; in ksz9477_acl_match_process_l2()
1419 ksz9477_acl_processing_rule_add_match(entry->entry, in ksz9477_acl_match_process_l2()
1420 acles->entries_count); in ksz9477_acl_match_process_l2()
1422 entry = ksz9477_acl_get_init_entry(dev, port, cookie, prio); in ksz9477_acl_match_process_l2()
1423 ksz9477_acl_matching_rule_cfg_l2(entry->entry, 0, dst_mac, in ksz9477_acl_match_process_l2()
1425 acles->entries_count++; in ksz9477_acl_match_process_l2()
1430 ksz9477_acl_matching_rule_cfg_l2(entry->entry, ethtype, mac, in ksz9477_acl_match_process_l2()
1432 ksz9477_acl_processing_rule_add_match(entry->entry, in ksz9477_acl_match_process_l2()
1433 acles->entries_count); in ksz9477_acl_match_process_l2()
1434 acles->entries_count++; in ksz9477_acl_match_process_l2()