/* * IMG parallel output controller driver * * Copyright (C) 2015 Imagination Technologies Ltd. * * Author: Damien Horsley * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define IMG_PRL_OUT_TX_FIFO 0 #define IMG_PRL_OUT_CTL 0x4 #define IMG_PRL_OUT_CTL_CH_MASK BIT(4) #define IMG_PRL_OUT_CTL_PACKH_MASK BIT(3) #define IMG_PRL_OUT_CTL_EDGE_MASK BIT(2) #define IMG_PRL_OUT_CTL_ME_MASK BIT(1) #define IMG_PRL_OUT_CTL_SRST_MASK BIT(0) struct img_prl_out { void __iomem *base; struct clk *clk_sys; struct clk *clk_ref; struct snd_dmaengine_dai_dma_data dma_data; struct device *dev; struct reset_control *rst; }; static int img_prl_out_suspend(struct device *dev) { struct img_prl_out *prl = dev_get_drvdata(dev); clk_disable_unprepare(prl->clk_ref); return 0; } static int img_prl_out_resume(struct device *dev) { struct img_prl_out *prl = dev_get_drvdata(dev); int ret; ret = clk_prepare_enable(prl->clk_ref); if (ret) { dev_err(dev, "clk_enable failed: %d\n", ret); return ret; } return 0; } static inline void img_prl_out_writel(struct img_prl_out *prl, u32 val, u32 reg) { writel(val, prl->base + reg); } static inline u32 img_prl_out_readl(struct img_prl_out *prl, u32 reg) { return readl(prl->base + reg); } static void img_prl_out_reset(struct img_prl_out *prl) { u32 ctl; ctl = img_prl_out_readl(prl, IMG_PRL_OUT_CTL) & ~IMG_PRL_OUT_CTL_ME_MASK; reset_control_assert(prl->rst); reset_control_deassert(prl->rst); img_prl_out_writel(prl, ctl, IMG_PRL_OUT_CTL); } static int img_prl_out_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct img_prl_out *prl = snd_soc_dai_get_drvdata(dai); u32 reg; switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: reg = img_prl_out_readl(prl, IMG_PRL_OUT_CTL); reg |= IMG_PRL_OUT_CTL_ME_MASK; img_prl_out_writel(prl, reg, IMG_PRL_OUT_CTL); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: img_prl_out_reset(prl); break; default: return -EINVAL; } return 0; } static int img_prl_out_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct img_prl_out *prl = snd_soc_dai_get_drvdata(dai); unsigned int rate, channels; u32 reg, control_set = 0; snd_pcm_format_t format; rate = params_rate(params); format = params_format(params); channels = params_channels(params); switch (params_format(params)) { case SNDRV_PCM_FORMAT_S32_LE: control_set |= IMG_PRL_OUT_CTL_PACKH_MASK; break; case SNDRV_PCM_FORMAT_S24_LE: break; default: return -EINVAL; } if (channels != 2) return -EINVAL; clk_set_rate(prl->clk_ref, rate * 256); reg = img_prl_out_readl(prl, IMG_PRL_OUT_CTL); reg = (reg & ~IMG_PRL_OUT_CTL_PACKH_MASK) | control_set; img_prl_out_writel(prl, reg, IMG_PRL_OUT_CTL); return 0; } static int img_prl_out_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { struct img_prl_out *prl = snd_soc_dai_get_drvdata(dai); u32 reg, control_set = 0; switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_NB_NF: break; case SND_SOC_DAIFMT_NB_IF: control_set |= IMG_PRL_OUT_CTL_EDGE_MASK; break; default: return -EINVAL; } reg = img_prl_out_readl(prl, IMG_PRL_OUT_CTL); reg = (reg & ~IMG_PRL_OUT_CTL_EDGE_MASK) | control_set; img_prl_out_writel(prl, reg, IMG_PRL_OUT_CTL); return 0; } static const struct snd_soc_dai_ops img_prl_out_dai_ops = { .trigger = img_prl_out_trigger, .hw_params = img_prl_out_hw_params, .set_fmt = img_prl_out_set_fmt }; static int img_prl_out_dai_probe(struct snd_soc_dai *dai) { struct img_prl_out *prl = snd_soc_dai_get_drvdata(dai); snd_soc_dai_init_dma_data(dai, &prl->dma_data, NULL); return 0; } static struct snd_soc_dai_driver img_prl_out_dai = { .probe = img_prl_out_dai_probe, .playback = { .channels_min = 2, .channels_max = 2, .rates = SNDRV_PCM_RATE_8000_192000, .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE }, .ops = &img_prl_out_dai_ops }; static const struct snd_soc_component_driver img_prl_out_component = { .name = "img-prl-out" }; static int img_prl_out_probe(struct platform_device *pdev) { struct img_prl_out *prl; struct resource *res; void __iomem *base; int ret; struct device *dev = &pdev->dev; prl = devm_kzalloc(&pdev->dev, sizeof(*prl), GFP_KERNEL); if (!prl) return -ENOMEM; platform_set_drvdata(pdev, prl); prl->dev = &pdev->dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(base)) return PTR_ERR(base); prl->base = base; prl->rst = devm_reset_control_get(&pdev->dev, "rst"); if (IS_ERR(prl->rst)) { if (PTR_ERR(prl->rst) != -EPROBE_DEFER) dev_err(&pdev->dev, "No top level reset found\n"); return PTR_ERR(prl->rst); } prl->clk_sys = devm_clk_get(&pdev->dev, "sys"); if (IS_ERR(prl->clk_sys)) { if (PTR_ERR(prl->clk_sys) != -EPROBE_DEFER) dev_err(dev, "Failed to acquire clock 'sys'\n"); return PTR_ERR(prl->clk_sys); } prl->clk_ref = devm_clk_get(&pdev->dev, "ref"); if (IS_ERR(prl->clk_ref)) { if (PTR_ERR(prl->clk_ref) != -EPROBE_DEFER) dev_err(dev, "Failed to acquire clock 'ref'\n"); return PTR_ERR(prl->clk_ref); } ret = clk_prepare_enable(prl->clk_sys); if (ret) return ret; img_prl_out_writel(prl, IMG_PRL_OUT_CTL_EDGE_MASK, IMG_PRL_OUT_CTL); img_prl_out_reset(prl); pm_runtime_enable(&pdev->dev); if (!pm_runtime_enabled(&pdev->dev)) { ret = img_prl_out_resume(&pdev->dev); if (ret) goto err_pm_disable; } prl->dma_data.addr = res->start + IMG_PRL_OUT_TX_FIFO; prl->dma_data.addr_width = 4; prl->dma_data.maxburst = 4; ret = devm_snd_soc_register_component(&pdev->dev, &img_prl_out_component, &img_prl_out_dai, 1); if (ret) goto err_suspend; ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); if (ret) goto err_suspend; return 0; err_suspend: if (!pm_runtime_status_suspended(&pdev->dev)) img_prl_out_suspend(&pdev->dev); err_pm_disable: pm_runtime_disable(&pdev->dev); clk_disable_unprepare(prl->clk_sys); return ret; } static int img_prl_out_dev_remove(struct platform_device *pdev) { struct img_prl_out *prl = platform_get_drvdata(pdev); pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) img_prl_out_suspend(&pdev->dev); clk_disable_unprepare(prl->clk_sys); return 0; } static const struct of_device_id img_prl_out_of_match[] = { { .compatible = "img,parallel-out" }, {} }; MODULE_DEVICE_TABLE(of, img_prl_out_of_match); static const struct dev_pm_ops img_prl_out_pm_ops = { SET_RUNTIME_PM_OPS(img_prl_out_suspend, img_prl_out_resume, NULL) }; static struct platform_driver img_prl_out_driver = { .driver = { .name = "img-parallel-out", .of_match_table = img_prl_out_of_match, .pm = &img_prl_out_pm_ops }, .probe = img_prl_out_probe, .remove = img_prl_out_dev_remove }; module_platform_driver(img_prl_out_driver); MODULE_AUTHOR("Damien Horsley "); MODULE_DESCRIPTION("IMG Parallel Output Driver"); MODULE_LICENSE("GPL v2"); ping. 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-03bridge: uapi: add per vlan tunnel infoRoopa Prabhu2-0/+12 New nested netlink attribute to associate tunnel info per vlan. This is used by bridge driver to send tunnel metadata to bridge ports in vlan tunnel mode. This patch also adds new per port flag IFLA_BRPORT_VLAN_TUNNEL to enable vlan tunnel mode. off by default. One example use for this is a vxlan bridging gateway or vtep which maps vlans to vn-segments (or vnis). User can configure per-vlan tunnel information which the bridge driver can use to bridge vlan into the corresponding vn-segment. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-03vxlan: support fdb and learning in COLLECT_METADATA modeRoopa Prabhu1-0/+1 Vxlan COLLECT_METADATA mode today solves the per-vni netdev scalability problem in l3 networks. It expects all forwarding information to be present in dst_metadata. This patch series enhances collect metadata mode to include the case where only vni is present in dst_metadata, and the vxlan driver can then use the rest of the forwarding information datbase to make forwarding decisions. There is no change to default COLLECT_METADATA behaviour. These changes only apply to COLLECT_METADATA when used with the bridging use-case with a special dst_metadata tunnel info flag (eg: where vxlan device is part of a bridge). For all this to work, the vxlan driver will need to now support a single fdb table hashed by mac + vni. This series essentially makes this happen. use-case and workflow: vxlan collect metadata device participates in bridging vlan to vn-segments. Bridge driver above the vxlan device, sends the vni corresponding to the vlan in the dst_metadata. vxlan driver will lookup forwarding database with (mac + vni) for the required remote destination information to forward the packet. Changes introduced by this patch: - allow learning and forwarding database state in vxlan netdev in COLLECT_METADATA mode. Current behaviour is not changed by default. tunnel info flag IP_TUNNEL_INFO_BRIDGE is used to support the new bridge friendly mode. - A single fdb table hashed by (mac, vni) to allow fdb entries with multiple vnis in the same fdb table - rx path already has the vni - tx path expects a vni in the packet with dst_metadata - prior to this series, fdb remote_dsts carried remote vni and the vxlan device carrying the fdb table represented the source vni. With the vxlan device now representing multiple vnis, this patch adds a src vni attribute to the fdb entry. The remote vni already uses NDA_VNI attribute. This patch introduces NDA_SRC_VNI netlink attribute to represent the src vni in a multi vni fdb table. iproute2 example (patched and pruned iproute2 output to just show relevant fdb entries): example shows same host mac learnt on two vni's. before (netdev per vni): $bridge fdb show | grep "00:02:00:00:00:03" 00:02:00:00:00:03 dev vxlan1001 dst 12.0.0.8 self 00:02:00:00:00:03 dev vxlan1000 dst 12.0.0.8 self after this patch with collect metadata in bridged mode (single netdev): $bridge fdb show | grep "00:02:00:00:00:03" 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 src_vni 1000 dst 12.0.0.8 self 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 Gigi1-9/+1 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 Gigi2-0/+19 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-02net: add LINUX_MIB_PFMEMALLOCDROP counterEric Dumazet1-0/+1 Debugging issues caused by pfmemalloc is often tedious. Add a new SNMP counter to more easily diagnose these problems. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Josef Bacik <jbacik@fb.com> Acked-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-02unix: add ioctl to open a unix socket file with O_PATHAndrey Vagin1-0/+2 This ioctl opens a file to which a socket is bound and returns a file descriptor. The caller has to have CAP_NET_ADMIN in the socket network namespace. Currently it is impossible to get a path and a mount point for a socket file. socket_diag reports address, device ID and inode number for unix sockets. An address can contain a relative path or a file may be moved somewhere. And these properties say nothing about a mount namespace and a mount point of a socket file. With the introduced ioctl, we can get a path by reading /proc/self/fd/X and get mnt_id from /proc/self/fdinfo/X. In CRIU we are going to use this ioctl to dump and restore unix socket. Here is an example how it can be used: $ strace -e socket,bind,ioctl ./test /tmp/test_sock socket(AF_UNIX, SOCK_STREAM, 0) = 3 bind(3, {sa_family=AF_UNIX, sun_path="test_sock"}, 11) = 0 ioctl(3, SIOCUNIXFILE, 0) = 4 ^Z $ ss -a | grep test_sock u_str LISTEN 0 1 test_sock 17798 * 0 $ ls -l /proc/760/fd/{3,4} lrwx------ 1 root root 64 Feb 1 09:41 3 -> 'socket:[17798]' l--------- 1 root root 64 Feb 1 09:41 4 -> /tmp/test_sock $ cat /proc/760/fdinfo/4 pos: 0 flags: 012000000 mnt_id: 40 $ cat /proc/self/mountinfo | grep "^40\s" 40 19 0:37 / /tmp rw shared:23 - tmpfs tmpfs rw Signed-off-by: Andrei Vagin <avagin@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-02Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller1-1/+3 All merge conflicts were simple overlapping changes. Signed-off-by: David S. Miller <davem@davemloft.net>