Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ipa: reduce arguments to ipa_table_init_add()

Recently ipa_table_mem() was added as a way to look up one of 8
possible memory regions by indicating whether it was a filter or
route table, hashed or not, and IPv6 or not.

We can simplify the interface to ipa_table_init_add() by passing two
flags to it instead of the opcode and both hashed and non-hashed
memory region IDs. The "filter" and "ipv6" flags are sufficient to
determine the opcode to use, and with ipa_table_mem() can look up
the correct memory region as well.

It's possible to not have hashed tables, but we already verify the
number of entries in a filter or routing table is nonzero. Stop
assuming a hashed table entry exists in ipa_table_init_add().

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Alex Elder and committed by
David S. Miller
5cb76899 d28c0e73

+18 -19
+18 -19
drivers/net/ipa/ipa_table.c
··· 376 376 return 0; 377 377 } 378 378 379 - static void ipa_table_init_add(struct gsi_trans *trans, bool filter, 380 - enum ipa_cmd_opcode opcode, 381 - enum ipa_mem_id mem_id, 382 - enum ipa_mem_id hash_mem_id) 379 + static void ipa_table_init_add(struct gsi_trans *trans, bool filter, bool ipv6) 383 380 { 384 381 struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); 385 - const struct ipa_mem *hash_mem = ipa_mem_find(ipa, hash_mem_id); 386 - const struct ipa_mem *mem = ipa_mem_find(ipa, mem_id); 382 + const struct ipa_mem *hash_mem; 383 + enum ipa_cmd_opcode opcode; 384 + const struct ipa_mem *mem; 387 385 dma_addr_t hash_addr; 388 386 dma_addr_t addr; 389 387 u32 zero_offset; ··· 391 393 u16 count; 392 394 u16 size; 393 395 396 + opcode = filter ? ipv6 ? IPA_CMD_IP_V6_FILTER_INIT 397 + : IPA_CMD_IP_V4_FILTER_INIT 398 + : ipv6 ? IPA_CMD_IP_V6_ROUTING_INIT 399 + : IPA_CMD_IP_V4_ROUTING_INIT; 400 + 401 + mem = ipa_table_mem(ipa, filter, false, ipv6); 402 + hash_mem = ipa_table_mem(ipa, filter, true, ipv6); 403 + 394 404 /* Compute the number of table entries to initialize */ 395 405 if (filter) { 396 406 /* The number of filtering endpoints determines number of ··· 407 401 * table is either the same as the non-hashed one, or zero. 408 402 */ 409 403 count = 1 + hweight32(ipa->filter_map); 410 - hash_count = hash_mem->size ? count : 0; 404 + hash_count = hash_mem && hash_mem->size ? count : 0; 411 405 } else { 412 406 /* The size of a route table region determines the number 413 407 * of entries it has. 414 408 */ 415 409 count = mem->size / sizeof(__le64); 416 - hash_count = hash_mem->size / sizeof(__le64); 410 + hash_count = hash_mem && hash_mem->size / sizeof(__le64); 417 411 } 418 412 size = count * sizeof(__le64); 419 413 hash_size = hash_count * sizeof(__le64); ··· 464 458 return -EBUSY; 465 459 } 466 460 467 - ipa_table_init_add(trans, false, IPA_CMD_IP_V4_ROUTING_INIT, 468 - IPA_MEM_V4_ROUTE, IPA_MEM_V4_ROUTE_HASHED); 469 - 470 - ipa_table_init_add(trans, false, IPA_CMD_IP_V6_ROUTING_INIT, 471 - IPA_MEM_V6_ROUTE, IPA_MEM_V6_ROUTE_HASHED); 472 - 473 - ipa_table_init_add(trans, true, IPA_CMD_IP_V4_FILTER_INIT, 474 - IPA_MEM_V4_FILTER, IPA_MEM_V4_FILTER_HASHED); 475 - 476 - ipa_table_init_add(trans, true, IPA_CMD_IP_V6_FILTER_INIT, 477 - IPA_MEM_V6_FILTER, IPA_MEM_V6_FILTER_HASHED); 461 + ipa_table_init_add(trans, false, false); 462 + ipa_table_init_add(trans, false, true); 463 + ipa_table_init_add(trans, true, false); 464 + ipa_table_init_add(trans, true, true); 478 465 479 466 gsi_trans_commit_wait(trans); 480 467