Lines Matching +full:offset +full:- +full:x

1 // SPDX-License-Identifier: GPL-2.0
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2019-2020 Linaro Ltd.
11 #include <linux/dma-direction.h>
30 * command has a well-defined format, having a payload of a known length.
81 __le16 offset; member
152 * might not be used, non-hashed and hashed tables have the same in ipa_cmd_validate_build()
171 struct device *dev = &ipa->pdev->dev; in ipa_cmd_table_valid()
176 if (mem->offset > offset_max || in ipa_cmd_table_valid()
177 ipa->mem_offset > offset_max - mem->offset) { in ipa_cmd_table_valid()
178 dev_err(dev, "IPv%c %s%s table region offset too large " in ipa_cmd_table_valid()
179 "(0x%04x + 0x%04x > 0x%04x)\n", in ipa_cmd_table_valid()
182 ipa->mem_offset, mem->offset, offset_max); in ipa_cmd_table_valid()
186 if (mem->offset > ipa->mem_size || in ipa_cmd_table_valid()
187 mem->size > ipa->mem_size - mem->offset) { in ipa_cmd_table_valid()
189 "(0x%04x + 0x%04x > 0x%04x)\n", in ipa_cmd_table_valid()
192 mem->offset, mem->size, ipa->mem_size); in ipa_cmd_table_valid()
202 const struct ipa_mem *mem = &ipa->mem[IPA_MEM_MODEM_HEADER]; in ipa_cmd_header_valid()
203 struct device *dev = &ipa->pdev->dev; in ipa_cmd_header_valid()
209 if (mem->offset > offset_max || in ipa_cmd_header_valid()
210 ipa->mem_offset > offset_max - mem->offset) { in ipa_cmd_header_valid()
211 dev_err(dev, "header table region offset too large " in ipa_cmd_header_valid()
212 "(0x%04x + 0x%04x > 0x%04x)\n", in ipa_cmd_header_valid()
213 ipa->mem_offset + mem->offset, offset_max); in ipa_cmd_header_valid()
218 size = ipa->mem[IPA_MEM_MODEM_HEADER].size; in ipa_cmd_header_valid()
219 size += ipa->mem[IPA_MEM_AP_HEADER].size; in ipa_cmd_header_valid()
220 if (mem->offset > ipa->mem_size || size > ipa->mem_size - mem->offset) { in ipa_cmd_header_valid()
222 "(0x%04x + 0x%04x > 0x%04x)\n", in ipa_cmd_header_valid()
223 mem->offset, size, ipa->mem_size); in ipa_cmd_header_valid()
230 /* Indicate whether an offset can be used with a register_write command */
232 const char *name, u32 offset) in ipa_cmd_register_write_offset_valid() argument
235 struct device *dev = &ipa->pdev->dev; in ipa_cmd_register_write_offset_valid()
239 /* The maximum offset in a register_write immediate command depends in ipa_cmd_register_write_offset_valid()
240 * on the version of IPA. IPA v3.5.1 supports a 16 bit offset, but in ipa_cmd_register_write_offset_valid()
241 * newer versions allow some additional high-order bits. in ipa_cmd_register_write_offset_valid()
243 bit_count = BITS_PER_BYTE * sizeof(payload->offset); in ipa_cmd_register_write_offset_valid()
244 if (ipa->version != IPA_VERSION_3_5_1) in ipa_cmd_register_write_offset_valid()
247 offset_max = ~0 >> (32 - bit_count); in ipa_cmd_register_write_offset_valid()
249 if (offset > offset_max || ipa->mem_offset > offset_max - offset) { in ipa_cmd_register_write_offset_valid()
250 dev_err(dev, "%s offset too large 0x%04x + 0x%04x > 0x%04x)\n", in ipa_cmd_register_write_offset_valid()
251 ipa->mem_offset + offset, offset_max); in ipa_cmd_register_write_offset_valid()
262 u32 offset; in ipa_cmd_register_write_valid() local
264 offset = ipa_reg_filt_rout_hash_flush_offset(ipa->version); in ipa_cmd_register_write_valid()
266 if (!ipa_cmd_register_write_offset_valid(ipa, name, offset)) in ipa_cmd_register_write_valid()
269 offset = IPA_REG_ENDP_STATUS_N_OFFSET(IPA_ENDPOINT_COUNT); in ipa_cmd_register_write_valid()
271 if (!ipa_cmd_register_write_offset_valid(ipa, name, offset)) in ipa_cmd_register_write_valid()
292 struct gsi_trans_info *trans_info = &channel->trans_info; in ipa_cmd_pool_init()
293 struct device *dev = channel->gsi->dev; in ipa_cmd_pool_init()
303 ret = gsi_trans_pool_init_dma(dev, &trans_info->cmd_pool, in ipa_cmd_pool_init()
305 tre_max, channel->tlv_count); in ipa_cmd_pool_init()
310 ret = gsi_trans_pool_init(&trans_info->info_pool, in ipa_cmd_pool_init()
312 tre_max, channel->tlv_count); in ipa_cmd_pool_init()
314 gsi_trans_pool_exit_dma(dev, &trans_info->cmd_pool); in ipa_cmd_pool_init()
321 struct gsi_trans_info *trans_info = &channel->trans_info; in ipa_cmd_pool_exit()
322 struct device *dev = channel->gsi->dev; in ipa_cmd_pool_exit()
324 gsi_trans_pool_exit(&trans_info->info_pool); in ipa_cmd_pool_exit()
325 gsi_trans_pool_exit_dma(dev, &trans_info->cmd_pool); in ipa_cmd_pool_exit()
334 endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX]; in ipa_cmd_payload_alloc()
335 trans_info = &ipa->gsi.channel[endpoint->channel_id].trans_info; in ipa_cmd_payload_alloc()
337 return gsi_trans_pool_alloc_dma(&trans_info->cmd_pool, addr); in ipa_cmd_payload_alloc()
342 enum ipa_cmd_opcode opcode, u16 size, u32 offset, in ipa_cmd_table_init_add() argument
346 struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); in ipa_cmd_table_init_add()
353 /* Record the non-hash table offset and size */ in ipa_cmd_table_init_add()
354 offset += ipa->mem_offset; in ipa_cmd_table_init_add()
355 val = u64_encode_bits(offset, IP_FLTRT_FLAGS_NHASH_ADDR_FMASK); in ipa_cmd_table_init_add()
358 /* The hash table offset and address are zero if its size is 0 */ in ipa_cmd_table_init_add()
360 /* Record the hash table offset and size */ in ipa_cmd_table_init_add()
361 hash_offset += ipa->mem_offset; in ipa_cmd_table_init_add()
369 payload = &cmd_payload->table_init; in ipa_cmd_table_init_add()
371 /* Fill in all offsets and sizes and the non-hash table address */ in ipa_cmd_table_init_add()
373 payload->hash_rules_addr = cpu_to_le64(hash_addr); in ipa_cmd_table_init_add()
374 payload->flags = cpu_to_le64(val); in ipa_cmd_table_init_add()
375 payload->nhash_rules_addr = cpu_to_le64(addr); in ipa_cmd_table_init_add()
381 /* Initialize header space in IPA-local memory */
382 void ipa_cmd_hdr_init_local_add(struct gsi_trans *trans, u32 offset, u16 size, in ipa_cmd_hdr_init_local_add() argument
385 struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); in ipa_cmd_hdr_init_local_add()
393 offset += ipa->mem_offset; in ipa_cmd_hdr_init_local_add()
401 payload = &cmd_payload->hdr_init_local; in ipa_cmd_hdr_init_local_add()
403 payload->hdr_table_addr = cpu_to_le64(addr); in ipa_cmd_hdr_init_local_add()
405 flags |= u32_encode_bits(offset, HDR_INIT_LOCAL_FLAGS_HDR_ADDR_FMASK); in ipa_cmd_hdr_init_local_add()
406 payload->flags = cpu_to_le32(flags); in ipa_cmd_hdr_init_local_add()
412 void ipa_cmd_register_write_add(struct gsi_trans *trans, u32 offset, u32 value, in ipa_cmd_register_write_add() argument
415 struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); in ipa_cmd_register_write_add()
427 if (ipa->version != IPA_VERSION_3_5_1) { in ipa_cmd_register_write_add()
437 /* Extract the high 4 bits from the offset */ in ipa_cmd_register_write_add()
438 offset_high = (u16)u32_get_bits(offset, GENMASK(19, 16)); in ipa_cmd_register_write_add()
439 offset &= (1 << 16) - 1; in ipa_cmd_register_write_add()
453 payload = &cmd_payload->register_write; in ipa_cmd_register_write_add()
455 payload->flags = cpu_to_le16(flags); in ipa_cmd_register_write_add()
456 payload->offset = cpu_to_le16((u16)offset); in ipa_cmd_register_write_add()
457 payload->value = cpu_to_le32(value); in ipa_cmd_register_write_add()
458 payload->value_mask = cpu_to_le32(mask); in ipa_cmd_register_write_add()
459 payload->clear_options = cpu_to_le32(options); in ipa_cmd_register_write_add()
468 struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); in ipa_cmd_ip_packet_init_add()
479 payload = &cmd_payload->ip_packet_init; in ipa_cmd_ip_packet_init_add()
481 payload->dest_endpoint = u8_encode_bits(endpoint_id, in ipa_cmd_ip_packet_init_add()
488 /* Use a DMA command to read or write a block of IPA-resident memory */
489 void ipa_cmd_dma_shared_mem_add(struct gsi_trans *trans, u32 offset, u16 size, in ipa_cmd_dma_shared_mem_add() argument
492 struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); in ipa_cmd_dma_shared_mem_add()
500 /* size and offset must fit in 16 bit fields */ in ipa_cmd_dma_shared_mem_add()
502 /* assert(offset <= U16_MAX && ipa->mem_offset <= U16_MAX - offset); */ in ipa_cmd_dma_shared_mem_add()
504 offset += ipa->mem_offset; in ipa_cmd_dma_shared_mem_add()
507 payload = &cmd_payload->dma_shared_mem; in ipa_cmd_dma_shared_mem_add()
509 /* payload->clear_after_read was reserved prior to IPA v4.0. It's in ipa_cmd_dma_shared_mem_add()
512 payload->size = cpu_to_le16(size); in ipa_cmd_dma_shared_mem_add()
513 payload->local_addr = cpu_to_le16(offset); in ipa_cmd_dma_shared_mem_add()
514 /* payload->flags: in ipa_cmd_dma_shared_mem_add()
523 payload->flags = cpu_to_le16(flags); in ipa_cmd_dma_shared_mem_add()
524 payload->system_addr = cpu_to_le64(addr); in ipa_cmd_dma_shared_mem_add()
534 struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); in ipa_cmd_ip_tag_status_add()
544 payload = &cmd_payload->ip_packet_tag_status; in ipa_cmd_ip_tag_status_add()
546 payload->tag = u64_encode_bits(tag, IP_PACKET_TAG_STATUS_TAG_FMASK); in ipa_cmd_ip_tag_status_add()
555 struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); in ipa_cmd_transfer_add()
563 /* Just transfer a zero-filled payload structure */ in ipa_cmd_transfer_add()
572 struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); in ipa_cmd_tag_process_add()
575 endpoint = ipa->name_map[IPA_ENDPOINT_AP_LAN_RX]; in ipa_cmd_tag_process_add()
578 ipa_cmd_ip_packet_init_add(trans, endpoint->endpoint_id); in ipa_cmd_tag_process_add()
599 dev_err(&ipa->pdev->dev, in ipa_cmd_tag_process()
609 channel = &endpoint->ipa->gsi.channel[endpoint->channel_id]; in ipa_cmd_info_alloc()
611 return gsi_trans_pool_alloc(&channel->trans_info.info_pool, tre_count); in ipa_cmd_info_alloc()
620 endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX]; in ipa_cmd_trans_alloc()
622 trans = gsi_channel_trans_alloc(&ipa->gsi, endpoint->channel_id, in ipa_cmd_trans_alloc()
625 trans->info = ipa_cmd_info_alloc(endpoint, tre_count); in ipa_cmd_trans_alloc()