/* * linux/drivers/video/arcfb.c -- FB driver for Arc monochrome LCD board * * Copyright (C) 2005, Jaya Kumar * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive for * more details. * * Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven. * * This driver was written to be used with the Arc LCD board. Arc uses a * set of KS108 chips that control individual 64x64 LCD matrices. The board * can be paneled in a variety of setups such as 2x1=128x64, 4x4=256x256 and * so on. The interface between the board and the host is TTL based GPIO. The * GPIO requirements are 8 writable data lines and 4+n lines for control. On a * GPIO-less system, the board can be tested by connecting the respective sigs * up to a parallel port connector. The driver requires the IO addresses for * data and control GPIO at load time. It is unable to probe for the * existence of the LCD so it must be told at load time whether it should * be enabled or not. * * Todo: * - testing with 4x4 * - testing with interrupt hw * * General notes: * - User must set tuhold. It's in microseconds. According to the 108 spec, * the hold time is supposed to be at least 1 microsecond. * - User must set num_cols=x num_rows=y, eg: x=2 means 128 * - User must set arcfb_enable=1 to enable it * - User must set dio_addr=0xIOADDR cio_addr=0xIOADDR * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #define floor8(a) (a&(~0x07)) #define floorXres(a,xres) (a&(~(xres - 1))) #define iceil8(a) (((int)((a+7)/8))*8) #define ceil64(a) (a|0x3F) #define ceilXres(a,xres) (a|(xres - 1)) /* ks108 chipset specific defines and code */ #define KS_SET_DPY_START_LINE 0xC0 #define KS_SET_PAGE_NUM 0xB8 #define KS_SET_X 0x40 #define KS_CEHI 0x01 #define KS_CELO 0x00 #define KS_SEL_CMD 0x08 #define KS_SEL_DATA 0x00 #define KS_DPY_ON 0x3F #define KS_DPY_OFF 0x3E #define KS_INTACK 0x40 #define KS_CLRINT 0x02 struct arcfb_par { unsigned long dio_addr; unsigned long cio_addr; unsigned long c2io_addr; atomic_t ref_count; unsigned char cslut[9]; struct fb_info *info; unsigned int irq; spinlock_t lock; }; static const struct fb_fix_screeninfo arcfb_fix = { .id = "arcfb", .type = FB_TYPE_PACKED_PIXELS, .visual = FB_VISUAL_MONO01, .xpanstep = 0, .ypanstep = 1, .ywrapstep = 0, .accel = FB_ACCEL_NONE, }; static const struct fb_var_screeninfo arcfb_var = { .xres = 128, .yres = 64, .xres_virtual = 128, .yres_virtual = 64, .bits_per_pixel = 1, .nonstd = 1, }; static unsigned long num_cols; static unsigned long num_rows; static unsigned long dio_addr; static unsigned long cio_addr; static unsigned long c2io_addr; static unsigned long splashval; static unsigned long tuhold; static unsigned int nosplash; static unsigned int arcfb_enable; static unsigned int irq; static DECLARE_WAIT_QUEUE_HEAD(arcfb_waitq); static void ks108_writeb_ctl(struct arcfb_par *par, unsigned int chipindex, unsigned char value) { unsigned char chipselval = par->cslut[chipindex]; outb(chipselval|KS_CEHI|KS_SEL_CMD, par->cio_addr); outb(value, par->dio_addr); udelay(tuhold); outb(chipselval|KS_CELO|KS_SEL_CMD, par->cio_addr); } static void ks108_writeb_mainctl(struct arcfb_par *par, unsigned char value) { outb(value, par->cio_addr); udelay(tuhold); } static unsigned char ks108_readb_ctl2(struct arcfb_par *par) { return inb(par->c2io_addr); } static void ks108_writeb_data(struct arcfb_par *par, unsigned int chipindex, unsigned char value) { unsigned char chipselval = par->cslut[chipindex]; outb(chipselval|KS_CEHI|KS_SEL_DATA, par->cio_addr); outb(value, par->dio_addr); udelay(tuhold); outb(chipselval|KS_CELO|KS_SEL_DATA, par->cio_addr); } static void ks108_set_start_line(struct arcfb_par *par, unsigned int chipindex, unsigned char y) { ks108_writeb_ctl(par, chipindex, KS_SET_DPY_START_LINE|y); } static void ks108_set_yaddr(struct arcfb_par *par, unsigned int chipindex, unsigned char y) { ks108_writeb_ctl(par, chipindex, KS_SET_PAGE_NUM|y); } static void ks108_set_xaddr(struct arcfb_par *par, unsigned int chipindex, unsigned char x) { ks108_writeb_ctl(par, chipindex, KS_SET_X|x); } static void ks108_clear_lcd(struct arcfb_par *par, unsigned int chipindex) { int i,j; for (i = 0; i <= 8; i++) { ks108_set_yaddr(par, chipindex, i); ks108_set_xaddr(par, chipindex, 0); for (j = 0; j < 64; j++) { ks108_writeb_data(par, chipindex, (unsigned char) splashval); } } } /* main arcfb functions */ static int arcfb_open(struct fb_info *info, int user) { struct arcfb_par *par = info->par; atomic_inc(&par->ref_count); return 0; } static int arcfb_release(struct fb_info *info, int user) { struct arcfb_par *par = info->par; int count = atomic_read(&par->ref_count); if (!count) return -EINVAL; atomic_dec(&par->ref_count); return 0; } static int arcfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { int i; struct arcfb_par *par = info->par; if ((var->vmode & FB_VMODE_YWRAP) && (var->yoffset < 64) && (info->var.yres <= 64)) { for (i = 0; i < num_cols; i++) { ks108_set_start_line(par, i, var->yoffset); } info->var.yoffset = var->yoffset; return 0; } return -EINVAL; } static irqreturn_t arcfb_interrupt(int vec, void *dev_instance) { struct fb_info *info = dev_instance; unsigned char ctl2status; struct arcfb_par *par = info->par; ctl2status = ks108_readb_ctl2(par); if (!(ctl2status & KS_INTACK)) /* not arc generated interrupt */ return IRQ_NONE; ks108_writeb_mainctl(par, KS_CLRINT); spin_lock(&par->lock); if (waitqueue_active(&arcfb_waitq)) { wake_up(&arcfb_waitq); } spin_unlock(&par->lock); return IRQ_HANDLED; } /* * here we handle a specific page on the lcd. the complexity comes from * the fact that the fb is laidout in 8xX vertical columns. we extract * each write of 8 vertical pixels. then we shift out as we move along * X. That's what rightshift does. bitmask selects the desired input bit. */ static void arcfb_lcd_update_page(struct arcfb_par *par, unsigned int upper, unsigned int left, unsigned int right, unsigned int distance) { unsigned char *src; unsigned int xindex, yindex, chipindex, linesize; int i; unsigned char val; unsigned char bitmask, rightshift; xindex = left >> 6; yindex = upper >> 6; chipindex = (xindex + (yindex*num_cols)); ks108_set_yaddr(par, chipindex, upper/8); linesize = par->info->var.xres/8; src = (unsigned char __force *) par->info->screen_base + (left/8) + (upper * linesize); ks108_set_xaddr(par, chipindex, left); bitmask=1; rightshift=0; while (left <= right) { val = 0; for (i = 0; i < 8; i++) { if ( i > rightshift) { val |= (*(src + (i*linesize)) & bitmask) << (i - rightshift); } else { val |= (*(src + (i*linesize)) & bitmask) >> (rightshift - i); } } ks108_writeb_data(par, chipindex, val); left++; if (bitmask == 0x80) { bitmask = 1; src++; rightshift=0; } else { bitmask <<= 1; rightshift++; } } } /* * here we handle the entire vertical page of the update. we write across * lcd chips. update_page uses the upper/left values to decide which * chip to select for the right. upper is needed for setting the page * desired for the write. */ static void arcfb_lcd_update_vert(struct arcfb_par *par, unsigned int top, unsigned int bottom, unsigned int left, unsigned int right) { unsigned int distance, upper, lower; distance = (bottom - top) + 1; upper = top; lower = top + 7; while (distance > 0) { distance -= 8; arcfb_lcd_update_page(par, upper, left, right, 8); upper = lower + 1; lower = upper + 7; } } /* * here we handle horizontal blocks for the update. update_vert will * handle spaning multiple pages. we break out each horizontal * block in to individual blocks no taller than 64 pixels. */ static void arcfb_lcd_update_horiz(struct arcfb_par *par, unsigned int left, unsigned int right, unsigned int top, unsigned int h) { unsigned int distance, upper, lower; distance = h; upper = floor8(top); lower = min(upper + distance - 1, ceil64(upper)); while (distance > 0) { distance -= ((lower - upper) + 1 ); arcfb_lcd_update_vert(par, upper, lower, left, right); upper = lower + 1; lower = min(upper + distance - 1, ceil64(upper)); } } /* * here we start the process of splitting out the fb update into * individual blocks of pixels. we end up splitting into 64x64 blocks * and finally down to 64x8 pages. */ static void arcfb_lcd_update(struct arcfb_par *par, unsigned int dx, unsigned int dy, unsigned int w, unsigned int h) { unsigned int left, right, distance, y; /* align the request first */ y = floor8(dy); h += dy - y; h = iceil8(h); distance = w; left = dx; right = min(left + w - 1, ceil64(left)); while (distance > 0) { arcfb_lcd_update_horiz(par, left, right, y, h); distance -= ((right - left) + 1); left = right + 1; right = min(left + distance - 1, ceil64(left)); } } static void arcfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) { struct arcfb_par *par = info->par; sys_fillrect(info, rect); /* update the physical lcd */ arcfb_lcd_update(par, rect->dx, rect->dy, rect->width, rect->height); } static void arcfb_copyarea(struct fb_info *info, const struct fb_copyarea *area) { struct arcfb_par *par = info->par; sys_copyarea(info, area); /* update the physical lcd */ arcfb_lcd_update(par, area->dx, area->dy, area->width, area->height); } static void arcfb_imageblit(struct fb_info *info, const struct fb_image *image) { struct arcfb_par *par = info->par; sys_imageblit(info, image); /* update the physical lcd */ arcfb_lcd_update(par, image->dx, image->dy, image->width, image->height); } static int arcfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; struct arcfb_par *par = info->par; unsigned long flags; switch (cmd) { case FBIO_WAITEVENT: { DEFINE_WAIT(wait); /* illegal to wait on arc if no irq will occur */ if (!par->irq) return -EINVAL; /* wait until the Arc has generated an interrupt * which will wake us up */ spin_lock_irqsave(&par->lock, flags); prepare_to_wait(&arcfb_waitq, &wait, TASK_INTERRUPTIBLE); spin_unlock_irqrestore(&par->lock, flags); schedule(); finish_wait(&arcfb_waitq, &wait); } case FBIO_GETCONTROL2: { unsigned char ctl2; ctl2 = ks108_readb_ctl2(info->par); if (copy_to_user(argp, &ctl2, sizeof(ctl2))) return -EFAULT; return 0; } default: return -EINVAL; } } /* * this is the access path from userspace. they can seek and write to * the fb. it's inefficient for them to do anything less than 64*8 * writes since we update the lcd in each write() anyway. */ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf, size_t count, loff_t *ppos) { /* modded from epson 1355 */ unsigned long p; int err=-EINVAL; unsigned int fbmemlength,x,y,w,h, bitppos, startpos, endpos, bitcount; struct arcfb_par *par; unsigned int xres; p = *ppos; par = info->par; xres = info->var.xres; fbmemlength = (xres * info->var.yres)/8; if (p > fbmemlength) return -ENOSPC; err = 0; if ((count + p) > fbmemlength) { count = fbmemlength - p; err = -ENOSPC; } if (count) { char *base_addr; base_addr = (char __force *)info->screen_base; count -= copy_from_user(base_addr + p, buf, count); *ppos += count; err = -EFAULT; } bitppos = p*8; startpos = floorXres(bitppos, xres); endpos = ceilXres((bitppos + (count*8)), xres); bitcount = endpos - startpos; x = startpos % xres; y = startpos / xres; w = xres; h = bitcount / xres; arcfb_lcd_update(par, x, y, w, h); if (count) return count; return err; } static struct fb_ops arcfb_ops = { .owner = THIS_MODULE, .fb_open = arcfb_open, .fb_read = fb_sys_read, .fb_write = arcfb_write, .fb_release = arcfb_release, .fb_pan_display = arcfb_pan_display, .fb_fillrect = arcfb_fillrect, .fb_copyarea = arcfb_copyarea, .fb_imageblit = arcfb_imageblit, .fb_ioctl = arcfb_ioctl, }; static int arcfb_probe(struct platform_device *dev) { struct fb_info *info; int retval = -ENOMEM; int videomemorysize; unsigned char *videomemory; struct arcfb_par *par; int i; videomemorysize = (((64*64)*num_cols)*num_rows)/8; /* We need a flat backing store for the Arc's less-flat actual paged framebuffer */ videomemory = vzalloc(videomemorysize); if (!videomemory) return retval; info = framebuffer_alloc(sizeof(struct arcfb_par), &dev->dev); if (!info) goto err; info->screen_base = (char __iomem *)videomemory; info->fbops = &arcfb_ops; info->var = arcfb_var; info->fix = arcfb_fix; par = info->par; par->info = info; if (!dio_addr || !cio_addr || !c2io_addr) { printk(KERN_WARNING "no IO addresses supplied\n"); goto err1; } par->dio_addr = dio_addr; par->cio_addr = cio_addr; par->c2io_addr = c2io_addr; par->cslut[0] = 0x00; par->cslut[1] = 0x06; info->flags = FBINFO_FLAG_DEFAULT; spin_lock_init(&par->lock); retval = register_framebuffer(info); if (retval < 0) goto err1; platform_set_drvdata(dev, info); if (irq) { par->irq = irq; if (request_irq(par->irq, &arcfb_interrupt, IRQF_SHARED, "arcfb", info)) { printk(KERN_INFO "arcfb: Failed req IRQ %d\n", par->irq); retval = -EBUSY; goto err1; } } fb_info(info, "Arc frame buffer device, using %dK of video memory\n", videomemorysize >> 10); /* this inits the lcd but doesn't clear dirty pixels */ for (i = 0; i < num_cols * num_rows; i++) { ks108_writeb_ctl(par, i, KS_DPY_OFF); ks108_set_start_line(par, i, 0); ks108_set_yaddr(par, i, 0); ks108_set_xaddr(par, i, 0); ks108_writeb_ctl(par, i, KS_DPY_ON); } /* if we were told to splash the screen, we just clear it */ if (!nosplash) { for (i = 0; i < num_cols * num_rows; i++) { fb_info(info, "splashing lcd %d\n", i); ks108_set_start_line(par, i, 0); ks108_clear_lcd(par, i); } } return 0; err1: framebuffer_release(info); err: vfree(videomemory); return retval; } static int arcfb_remove(struct platform_device *dev) { struct fb_info *info = platform_get_drvdata(dev); if (info) { unregister_framebuffer(info); vfree((void __force *)info->screen_base); framebuffer_release(info); } return 0; } static struct platform_driver arcfb_driver = { .probe = arcfb_probe, .remove = arcfb_remove, .driver = { .name = "arcfb", }, }; static struct platform_device *arcfb_device; static int __init arcfb_init(void) { int ret; if (!arcfb_enable) return -ENXIO; ret = platform_driver_register(&arcfb_driver); if (!ret) { arcfb_device = platform_device_alloc("arcfb", 0); if (arcfb_device) { ret = platform_device_add(arcfb_device); } else { ret = -ENOMEM; } if (ret) { platform_device_put(arcfb_device); platform_driver_unregister(&arcfb_driver); } } return ret; } static void __exit arcfb_exit(void) { platform_device_unregister(arcfb_device); platform_driver_unregister(&arcfb_driver); } module_param(num_cols, ulong, 0); MODULE_PARM_DESC(num_cols, "Num horiz panels, eg: 2 = 128 bit wide"); module_param(num_rows, ulong, 0); MODULE_PARM_DESC(num_rows, "Num vert panels, eg: 1 = 64 bit high"); module_param(nosplash, uint, 0); MODULE_PARM_DESC(nosplash, "Disable doing the splash screen"); module_param(arcfb_enable, uint, 0); MODULE_PARM_DESC(arcfb_enable, "Enable communication with Arc board"); module_param(dio_addr, ulong, 0); MODULE_PARM_DESC(dio_addr, "IO address for data, eg: 0x480"); module_param(cio_addr, ulong, 0); MODULE_PARM_DESC(cio_addr, "IO address for control, eg: 0x400"); module_param(c2io_addr, ulong, 0); MODULE_PARM_DESC(c2io_addr, "IO address for secondary control, eg: 0x408"); module_param(splashval, ulong, 0); MODULE_PARM_DESC(splashval, "Splash pattern: 0xFF is black, 0x00 is green"); module_param(tuhold, ulong, 0); MODULE_PARM_DESC(tuhold, "Time to hold between strobing data to Arc board"); module_param(irq, uint, 0); MODULE_PARM_DESC(irq, "IRQ for the Arc board"); module_init(arcfb_init); module_exit(arcfb_exit); MODULE_DESCRIPTION("fbdev driver for Arc monochrome LCD board"); MODULE_AUTHOR("Jaya Kumar"); MODULE_LICENSE("GPL"); dded these ndos to stacked devices such as team and bond, so that calls will be propagated to mlxsw. However, previous commit removed the reliance on these ndos and no new users of these ndos have appeared since above mentioned commit. We can therefore safely remove this dead code. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-05net: remove __napi_complete()Eric Dumazet1-21/+3 All __napi_complete() callers have been converted to use the more standard napi_complete_done(), we can now remove this NAPI method for good. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-04net: ipv6: Use compressed IPv6 addresses showing route replace errorDavid Ahern1-1/+1 ip6_print_replace_route_err logs an error if a route replace fails with IPv6 addresses in the full format. e.g,: IPv6: IPV6: multipath route replace failed (check consistency of installed routes): 2001:0db8:0200:0000:0000:0000:0000:0000 nexthop 2001:0db8:0001:0000:0000:0000:0000:0016 ifi 0 Change the message to dump the addresses in the compressed format. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-04net: ipv6: Change notifications for multipath delete to RTA_MULTIPATHDavid Ahern2-1/+28 If an entire multipath route is deleted using prefix and len (without any nexthops), send a single RTM_DELROUTE notification with the full route using RTA_MULTIPATH. This is done by generating the skb before the route delete when all of the sibling routes are still present but sending it after the route has been removed from the FIB. The skip_notify flag is used to tell the lower fib code not to send notifications for the individual nexthop routes. If a route is deleted using RTA_MULTIPATH for any nexthops or a single nexthop entry is deleted, then the nexthops are deleted one at a time with notifications sent as each hop is deleted. This is necessary given that IPv6 allows individual hops within a route to be deleted. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-04net: ipv6: Change notifications for multipath add to RTA_MULTIPATHDavid Ahern2-3/+53 Change ip6_route_multipath_add to send one notifciation with the full route encoded with RTA_MULTIPATH instead of a series of individual routes. This is done by adding a skip_notify flag to the nl_info struct. The flag is used to skip sending of the notification in the fib code that actually inserts the route. Once the full route has been added, a notification is generated with all nexthops. ip6_route_multipath_add handles 3 use cases: new routes, route replace, and route append. The multipath notification generated needs to be consistent with the order of the nexthops and it should be consistent with the order in a FIB dump which means the route with the first nexthop needs to be used as the route reference. For the first 2 cases (new and replace), a reference to the route used to send the notification is obtained by saving the first route added. For the append case, the last route added is used to loop back to its first sibling route which is the first nexthop in the multipath route. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-04net: ipv6: Add support to dump multipath routes via RTA_MULTIPATH attributeDavid Ahern2-17/+105 IPv6 returns multipath routes as a series of individual routes making their display and handling by userspace different and more complicated than IPv4, putting the burden on the user to see that a route is part of a multipath route and internally creating a multipath route if desired (e.g., libnl does this as of commit 29b71371e764). This patch addresses this difference, allowing multipath routes to be returned using the RTA_MULTIPATH attribute. The end result is that IPv6 multipath routes can be treated and displayed in a format similar to IPv4: $ ip -6 ro ls vrf red 2001:db8:1::/120 dev eth1 proto kernel metric 256 pref medium 2001:db8:2::/120 dev eth2 proto kernel metric 256 pref medium 2001:db8:200::/120 metric 1024 nexthop via 2001:db8:1::2 dev eth1 weight 1 nexthop via 2001:db8:2::2 dev eth2 weight 1 Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-04net: ipv6: Allow shorthand delete of all nexthops in multipath routeDavid Ahern1-2/+36 IPv4 allows multipath routes to be deleted using just the prefix and length. For example: $ ip ro ls vrf red unreachable default metric 8192 1.1.1.0/24 nexthop via 10.100.1.254 dev eth1 weight 1 nexthop via 10.11.200.2 dev eth11.200 weight 1 10.11.200.0/24 dev eth11.200 proto kernel scope link src 10.11.200.3 10.100.1.0/24 dev eth1 proto kernel scope link src 10.100.1.3 $ ip ro del 1.1.1.0/24 vrf red $ ip ro ls vrf red unreachable default metric 8192 10.11.200.0/24 dev eth11.200 proto kernel scope link src 10.11.200.3 10.100.1.0/24 dev eth1 proto kernel scope link src 10.100.1.3 The same notation does not work with IPv6 because of how multipath routes are implemented for IPv6. For IPv6 only the first nexthop of a multipath route is deleted if the request contains only a prefix and length. This leads to unnecessary complexity in userspace dealing with IPv6 multipath routes. This patch allows all nexthops to be deleted without specifying each one in the delete request. Internally, this is done by walking the sibling list of the route matching the specifications given (prefix, length, metric, protocol, etc). $ ip -6 ro ls vrf red 2001:db8:1::/120 dev eth1 proto kernel metric 256 pref medium 2001:db8:2::/120 dev eth2 proto kernel metric 256 pref medium 2001:db8:200::/120 via 2001:db8:1::2 dev eth1 metric 1024 pref medium 2001:db8:200::/120 via 2001:db8:2::2 dev eth2 metric 1024 pref medium ... $ ip -6 ro del vrf red 2001:db8:200::/120 $ ip -6 ro ls vrf red 2001:db8:1::/120 dev eth1 proto kernel metric 256 pref medium 2001:db8:2::/120 dev eth2 proto kernel metric 256 pref medium ... Because IPv6 allows individual nexthops to be deleted without deleting the entire route, the ip6_route_multipath_del and non-multipath code path (ip6_route_del) have to be discriminated so that all nexthops are only deleted for the latter case. This is done by making the existing fc_type in fib6_config a u16 and then adding a new u16 field with fc_delete_all_nh as the first bit. Suggested-by: Dinesh Dutt <ddutt@cumulusnetworks.com> Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-03net: skb_needs_check() accepts CHECKSUM_NONE for txEric Dumazet1-3/+4 My recent change missed fact that UFO would perform a complete UDP checksum before segmenting in frags. In this case skb->ip_summed is set to CHECKSUM_NONE. We need to add this valid case to skb_needs_check() Fixes: b2504a5dbef3 ("net: reduce skb_warn_bad_offload() noise") Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-03net: remove support for per driver ndo_busy_poll()Eric Dumazet2-16/+0 We added generic support for busy polling in NAPI layer in linux-4.5 No network driver uses ndo_busy_poll() anymore, we can get rid of the pointer in struct net_device_ops, and its use in sk_busy_loop() Saves NETIF_F_BUSY_POLL features bit. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-03Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-nextDavid S. Miller53-640/+576 Pablo Neira Ayuso says: ==================== Netfilter updates for net-next The following patchset contains Netfilter updates for your net-next tree, they are: 1) Stash ctinfo 3-bit field into pointer to nf_conntrack object from sk_buff so we only access one single cacheline in the conntrack hotpath. Patchset from Florian Westphal. 2) Don't leak pointer to internal structures when exporting x_tables ruleset back to userspace, from Willem DeBruijn. This includes new helper functions to copy data to userspace such as xt_data_to_user() as well as conversions of our ip_tables, ip6_tables and arp_tables clients to use it. Not surprinsingly, ebtables requires an ad-hoc update. There is also a new field in x_tables extensions to indicate the amount of bytes that we copy to userspace. 3) Add nf_log_all_netns sysctl: This new knob allows you to enable logging via nf_log infrastructure for all existing netnamespaces. Given the effort to provide pernet syslog has been discontinued, let's provide a way to restore logging using netfilter kernel logging facilities in trusted environments. Patch from Michal Kubecek. 4) Validate SCTP checksum from conntrack helper, from Davide Caratti. 5) Merge UDPlite conntrack and NAT helpers into UDP, this was mostly a copy&paste from the original helper, from Florian Westphal. 6) Reset netfilter state when duplicating packets, also from Florian. 7) Remove unnecessary check for broadcast in IPv6 in pkttype match and nft_meta, from Liping Zhang. 8) Add missing code to deal with loopback packets from nft_meta when used by the netdev family, also from Liping. 9) Several cleanups on nf_tables, one to remove unnecessary check from the netlink control plane path to add table, set and stateful objects and code consolidation when unregister chain hooks, from Gao Feng. 10) Fix harmless reference counter underflow in IPVS that, however, results in problems with the introduction of the new refcount_t type, from David Windsor. 11) Enable LIBCRC32C from nf_ct_sctp instead of nf_nat_sctp, from Davide Caratti. 12) Missing documentation on nf_tables uapi header, from Liping Zhang. 13) Use rb_entry() helper in xt_connlimit, from Geliang Tang. ==================== Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-03sched: cls_flower: expose priority to offloading netdeviceJiri Pirko1-0/+3 The driver that offloads flower rules needs to know with which priority user inserted the rules. So add this information into offload struct. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Acked-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-03tcp: clear pfmemalloc on outgoing skbEric Dumazet1-0/+7 Josef Bacik diagnosed following problem : I was seeing random disconnects while testing NBD over loopback. This turned out to be because NBD sets pfmemalloc on it's socket, however the receiving side is a user space application so does not have pfmemalloc set on its socket. This means that sk_filter_trim_cap will simply drop this packet, under the assumption that the other side will simply retransmit. Well we do retransmit, and then the packet is just dropped again for the same reason. It seems the better way to address this problem is to clear pfmemalloc in the TCP transmit path. pfmemalloc strict control really makes sense on the receive path. Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-03net: ipv6: Set protocol to kernel for local routesDavid Ahern1-0/+1 IPv6 stack does not set the protocol for local routes, so those routes show up with proto "none": $ ip -6 ro ls table local local ::1 dev lo proto none metric 0 pref medium local 2100:3:: dev lo proto none metric 0 pref medium local 2100:3::4 dev lo proto none metric 0 pref medium local fe80:: dev lo proto none metric 0 pref medium ... Set rt6i_protocol to RTPROT_KERNEL for consistency with IPv4. Now routes show up with proto "kernel": $ ip -6 ro ls table local local ::1 dev lo proto kernel metric 0 pref medium local 2100:3:: dev lo proto kernel metric 0 pref medium local 2100:3::4 dev lo proto kernel metric 0 pref medium local fe80:: dev lo proto kernel metric 0 pref medium ... Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-03bridge: vlan dst_metadata hooks in ingress and egress pathsRoopa Prabhu6-2/+82 - ingress hook: - if port is a tunnel port, use tunnel info in attached dst_metadata to map it to a local vlan - egress hook: - if port is a tunnel port, use tunnel info attached to vlan to set dst_metadata on the skb CC: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-03bridge: per vlan dst_metadata netlink supportRoopa Prabhu7-48/+641 This patch adds support to attach per vlan tunnel info dst metadata. This enables bridge driver to map vlan to tunnel_info at ingress and egress. It uses the kernel dst_metadata infrastructure. The initial use case is vlan to vni bridging, but the api is generic to extend to any tunnel_info in the future: - Uapi to configure/unconfigure/dump per vlan tunnel data - netlink functions to configure vlan and tunnel_info mapping - Introduces bridge port flag BR_LWT_VLAN to enable attach/detach dst_metadata to bridged packets on ports. off by default. - changes to existing code is mainly refactor some existing vlan handling netlink code + hooks for new vlan tunnel code - I have kept the vlan tunnel code isolated in separate files. - most of the netlink vlan tunnel code is handling of vlan-tunid ranges (follows the vlan range handling code). To conserve space vlan-tunid by default are always dumped in ranges if applicable. Use case: example use for this is a vxlan bridging gateway or vtep which maps vlans to vn-segments (or vnis). iproute2 example (patched and pruned iproute2 output to just show relevant fdb entries): example shows same host mac learnt on two vni's and vlan 100 maps to vni 1000, vlan 101 maps to vni 1001 before (netdev per vni): $bridge fdb show | grep "00:02:00:00:00:03" 00:02:00:00:00:03 dev vxlan1001 vlan 101 master bridge 00:02:00:00:00:03 dev vxlan1001 dst 12.0.0.8 self 00:02:00:00:00:03 dev vxlan1000 vlan 100 master bridge 00:02:00:00:00:03 dev vxlan1000 dst 12.0.0.8 self after this patch with collect metdata in bridged mode (single netdev): $bridge fdb show | grep "00:02:00:00:00:03" 00:02:00:00:00:03 dev vxlan0 vlan 101 master bridge 00:02:00:00:00:03 dev vxlan0 src_vni 1001 dst 12.0.0.8 self 00:02:00:00:00:03 dev vxlan0 vlan 100 master bridge 00:02:00:00:00:03 dev vxlan0 src_vni 1000 dst 12.0.0.8 self CC: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-03net/sched: act_ife: Change to use ife moduleYotam Gigi2-78/+33 Use the encode/decode functionality from the ife module instead of using implementation inside the act_ife. Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Yotam Gigi <yotamg@mellanox.com> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Roman Mashak <mrv@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-03net: Introduce ife encapsulation moduleYotam Gigi5-0/+165 This module is responsible for the ife encapsulation protocol encode/decode logics. That module can: - ife_encode: encode skb and reserve space for the ife meta header - ife_decode: decode skb and extract the meta header size - ife_tlv_meta_encode - encodes one tlv entry into the reserved ife header space. - ife_tlv_meta_decode - decodes one tlv entry from the packet - ife_tlv_meta_next - advance to the next tlv Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Yotam Gigi <yotamg@mellanox.com> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Roman Mashak <mrv@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-03net/sched: act_ife: Unexport ife_tlv_meta_encodeYotam Gigi1-2/+2 As the function ife_tlv_meta_encode is not used by any other module, unexport it and make it static for the act_ife module. Signed-off-by: Yotam Gigi <yotamg@mellanox.com> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Roman Mashak <mrv@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-03tcp: add tcp_mss_clamp() helperEric Dumazet