/* * netsniff-ng - the packet sniffing beast * Copyright 2009, 2010 Daniel Borkmann. * Subject to the GPL, version 2. */ #include #include #include #include #include #include #include #include #include #include "xmalloc.h" #include "die.h" #include "ring_rx.h" #include "built_in.h" void destroy_rx_ring(int sock, struct ring *ring) { int ret; munmap(ring->mm_space, ring->mm_len); ring->mm_len = 0; fmemset(&ring->layout, 0, sizeof(ring->layout)); ret = setsockopt(sock, SOL_PACKET, PACKET_RX_RING, &ring->layout, sizeof(ring->layout)); if (unlikely(ret)) panic("Cannot destroy the RX_RING: %s!\n", strerror(errno)); xfree(ring->frames); } void setup_rx_ring_layout(int sock, struct ring *ring, unsigned int size, int jumbo_support) { fmemset(&ring->layout, 0, sizeof(ring->layout)); ring->layout.tp_block_size = (jumbo_support ? getpagesize() << 4 : getpagesize() << 2); ring->layout.tp_frame_size = (jumbo_support ? TPACKET_ALIGNMENT << 12 : TPACKET_ALIGNMENT << 7); ring->layout.tp_block_nr = size / ring->layout.tp_block_size; ring->layout.tp_frame_nr = ring->layout.tp_block_size / ring->layout.tp_frame_size * ring->layout.tp_block_nr; bug_on(ring->layout.tp_block_size < ring->layout.tp_frame_size); bug_on((ring->layout.tp_block_size % ring->layout.tp_frame_size) != 0); bug_on((ring->layout.tp_block_size % getpagesize()) != 0); } void create_rx_ring(int sock, struct ring *ring, int verbose) { int ret; set_sockopt_tpacket(sock); retry: ret = setsockopt(sock, SOL_PACKET, PACKET_RX_RING, &ring->layout, sizeof(ring->layout)); if (errno == ENOMEM && ring->layout.tp_block_nr > 1) { ring->layout.tp_block_nr >>= 1; ring->layout.tp_frame_nr = ring->layout.tp_block_size / ring->layout.tp_frame_size * ring->layout.tp_block_nr; goto retry; } if (ret < 0) panic("Cannot allocate RX_RING!\n"); ring->mm_len = ring->layout.tp_block_size * ring->layout.tp_block_nr; if (verbose) { printf("RX: %.2Lf MiB, %u Frames, each %u Byte allocated\n", (long double) ring->mm_len / (1 << 20), ring->layout.tp_frame_nr, ring->layout.tp_frame_size); } } void mmap_rx_ring(int sock, struct ring *ring) { ring->mm_space = mmap(0, ring->mm_len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED | MAP_POPULATE, sock, 0); if (ring->mm_space == MAP_FAILED) { destroy_rx_ring(sock, ring); panic("Cannot mmap RX_RING!\n"); } } void alloc_rx_ring_frames(struct ring *ring) { int i; size_t len = ring->layout.tp_frame_nr * sizeof(*ring->frames); ring->frames = xmalloc_aligned(len, CO_CACHE_LINE_SIZE); fmemset(ring->frames, 0, len); for (i = 0; i < ring->layout.tp_frame_nr; ++i) { ring->frames[i].iov_len = ring->layout.tp_frame_size; ring->frames[i].iov_base = ring->mm_space + (i * ring->layout.tp_frame_size); } } void bind_rx_ring(int sock, struct ring *ring, int ifindex) { int ret; /* * The RX_RING registers itself to the networking stack with * dev_add_pack(), so we have one single RX_RING for all devs * otherwise you'll get the packet twice. */ fmemset(&ring->s_ll, 0, sizeof(ring->s_ll)); ring->s_ll.sll_family = AF_PACKET; ring->s_ll.sll_protocol = htons(ETH_P_ALL); ring->s_ll.sll_ifindex = ifindex; ring->s_ll.sll_hatype = 0; ring->s_ll.sll_halen = 0; ring->s_ll.sll_pkttype = 0; ret = bind(sock, (struct sockaddr *) &ring->s_ll, sizeof(ring->s_ll)); if (ret < 0) { destroy_rx_ring(sock, ring); panic("Cannot bind RX_RING!\n"); } } onchange='this.form.submit();'>mode:
authorArnd Bergmann <arnd@arndb.de>2016-08-10 23:54:09 +0200
committerPhilipp Zabel <p.zabel@pengutronix.de>2016-08-11 08:42:01 +0200
commit851da9ac53a5e7121f7c38a052f74b574dd73ec3 (patch)
tree5b1d399bb7a4ea09f439cedb6ec3cc53bb24e27e
parent29b4817d4018df78086157ea3a55c1d9424a7cfc (diff)
drm/mediatek: add COMMON_CLK dependency
On kernel builds without COMMON_CLK, the newly added mediatek drm driver fails to build: drivers/gpu/drm/mediatek/mtk_mipi_tx.c:130:16: error: field 'pll_hw' has incomplete type struct clk_hw pll_hw; ^~~~~~ In file included from ../include/linux/clk.h:16:0, from ../drivers/gpu/drm/mediatek/mtk_mipi_tx.c:14: drivers/gpu/drm/mediatek/mtk_mipi_tx.c: In function 'mtk_mipi_tx_from_clk_hw': include/linux/kernel.h:831:48: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] const typeof( ((type *)0)->member ) *__mptr = (ptr); \ ^ /drivers/gpu/drm/mediatek/mtk_mipi_tx.c:136:9: note: in expansion of macro 'container_of' return container_of(hw, struct mtk_mipi_tx, pll_hw); ^~~~~~~~~~~~ drivers/gpu/drm/mediatek/mtk_mipi_tx.c: At top level: drivers/gpu/drm/mediatek/mtk_mipi_tx.c:302:21: error: variable 'mtk_mipi_tx_pll_ops' has initializer but incomplete type static const struct clk_ops mtk_mipi_tx_pll_ops = { This adds the required Kconfig dependency. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Philipp Zabel <p.zabel@pengutronix.de> Link: https://patchwork.kernel.org/patch/9069061/ Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>