drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cpplib.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cpplib.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cpplib.c
Extension
.c
Size
7107 bytes
Lines
299
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (i + incr > len) {
			incr = len - i;
			nfp_cpp_explicit_set_target(expl, cpp_id,
						    incr / width_read - 1,
						    0xff);
		}

		err = nfp_cpp_explicit_do(expl, addr);
		if (err < 0)
			goto exit_release;

		err = nfp_cpp_explicit_get(expl, tmp, incr);
		if (err < 0)
			goto exit_release;
	}
	err = len;
exit_release:
	nfp_cpp_explicit_release(expl);

	return err;
}

int nfp_cpp_explicit_write(struct nfp_cpp *cpp, u32 cpp_id, u64 addr,
			   const void *buff, size_t len, int width_write)
{
	struct nfp_cpp_explicit *expl;
	const char *tmp = buff;
	int err, i, incr;
	u8 byte_mask;

	if (len & (width_write - 1))
		return -EINVAL;

	expl = nfp_cpp_explicit_acquire(cpp);
	if (!expl)
		return -EBUSY;

	incr = min_t(int, 16 * width_write, 128);
	incr = min_t(int, incr, len);

	/* Translate a NFP_CPP_ACTION_RW to action 1 */
	if (NFP_CPP_ID_ACTION_of(cpp_id) == NFP_CPP_ACTION_RW)
		cpp_id = NFP_CPP_ID(NFP_CPP_ID_TARGET_of(cpp_id), 1,
				    NFP_CPP_ID_TOKEN_of(cpp_id));

	byte_mask = nfp_bytemask(width_write, addr);

	nfp_cpp_explicit_set_target(expl, cpp_id,
				    incr / width_write - 1, byte_mask);
	nfp_cpp_explicit_set_posted(expl, 1, 0, NFP_SIGNAL_PULL,
				    0, NFP_SIGNAL_NONE);

	for (i = 0; i < len; i += incr, addr += incr, tmp += incr) {
		if (i + incr > len) {
			incr = len - i;
			nfp_cpp_explicit_set_target(expl, cpp_id,
						    incr / width_write - 1,
						    0xff);
		}

		err = nfp_cpp_explicit_put(expl, tmp, incr);
		if (err < 0)
			goto exit_release;

		err = nfp_cpp_explicit_do(expl, addr);
		if (err < 0)
			goto exit_release;
	}
	err = len;
exit_release:
	nfp_cpp_explicit_release(expl);

	return err;
}

/**
 * nfp_cpp_map_area() - Helper function to map an area
 * @cpp:    NFP CPP handler
 * @name:   Name for the area
 * @cpp_id: CPP ID for operation
 * @addr:   CPP address
 * @size:   Size of the area
 * @area:   Area handle (output)
 *
 * Map an area of IOMEM access.  To undo the effect of this function call
 * @nfp_cpp_area_release_free(*area).
 *
 * Return: Pointer to memory mapped area or ERR_PTR
 */
u8 __iomem *

Annotation

Implementation Notes