202-core-linux-support-layerscape.patch 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. From 74243154052af635ee9ce9d07aab273ce219c855 Mon Sep 17 00:00:00 2001
  2. From: Biwen Li <[email protected]>
  3. Date: Thu, 13 Dec 2018 13:23:52 +0800
  4. Subject: [PATCH] core-linux: support layerscape
  5. This is an integrated patch of core-linux for layerscape.
  6. Signed-off-by: Abhijit Ayarekar <[email protected]>
  7. Signed-off-by: Amrita Kumari <[email protected]>
  8. Signed-off-by: Ashish Kumar <[email protected]>
  9. Signed-off-by: Camelia Groza <[email protected]>
  10. Signed-off-by: Christoph Hellwig <[email protected]>
  11. Signed-off-by: David Ahern <[email protected]>
  12. Signed-off-by: David S. Miller <[email protected]>
  13. Signed-off-by: Guanhua Gao <[email protected]>
  14. Signed-off-by: Jiri Pirko <[email protected]>
  15. Signed-off-by: Joel Fernandes <[email protected]>
  16. Signed-off-by: Li Yang <[email protected]>
  17. Signed-off-by: Madalin Bucur <[email protected]>
  18. Signed-off-by: Madalin Bucur <[email protected]>
  19. Signed-off-by: Nikhil Badola <[email protected]>
  20. Signed-off-by: Nipun Gupta <[email protected]>
  21. Signed-off-by: Ramneek Mehresh <[email protected]>
  22. Signed-off-by: Robin Murphy <[email protected]>
  23. Signed-off-by: Suresh Gupta <[email protected]>
  24. Signed-off-by: Yangbo Lu <[email protected]>
  25. Signed-off-by: yinbo.zhu <[email protected]>
  26. Signed-off-by: Biwen Li <[email protected]>
  27. ---
  28. drivers/base/dma-mapping.c | 7 ++
  29. drivers/net/bonding/bond_main.c | 5 +-
  30. drivers/net/bonding/bond_options.c | 2 +-
  31. drivers/net/team/team.c | 3 +-
  32. drivers/net/vrf.c | 3 +-
  33. drivers/of/device.c | 13 +++-
  34. drivers/soc/fsl/guts.c | 3 +
  35. include/linux/fsl_devices.h | 2 +
  36. include/linux/netdevice.h | 13 +++-
  37. include/linux/skbuff.h | 2 +
  38. include/net/bonding.h | 3 +-
  39. net/batman-adv/soft-interface.c | 3 +-
  40. net/bridge/br_device.c | 3 +-
  41. net/core/dev.c | 81 ++++++++++++++---------
  42. net/core/rtnetlink.c | 10 +--
  43. net/core/skbuff.c | 29 +++++++-
  44. samples/bpf/Makefile | 12 +++-
  45. samples/bpf/map_perf_test_kern.c | 2 +-
  46. samples/bpf/map_perf_test_user.c | 2 +-
  47. tools/testing/selftests/bpf/bpf_helpers.h | 56 ++++++++++++++--
  48. 20 files changed, 193 insertions(+), 61 deletions(-)
  49. --- a/drivers/base/dma-mapping.c
  50. +++ b/drivers/base/dma-mapping.c
  51. @@ -335,6 +335,7 @@ void dma_common_free_remap(void *cpu_add
  52. * Common configuration to enable DMA API use for a device
  53. */
  54. #include <linux/pci.h>
  55. +#include <linux/fsl/mc.h>
  56. int dma_configure(struct device *dev)
  57. {
  58. @@ -350,6 +351,12 @@ int dma_configure(struct device *dev)
  59. dma_dev = dma_dev->parent;
  60. }
  61. + if (dev_is_fsl_mc(dev)) {
  62. + dma_dev = dev;
  63. + while (dev_is_fsl_mc(dma_dev))
  64. + dma_dev = dma_dev->parent;
  65. + }
  66. +
  67. if (dma_dev->of_node) {
  68. ret = of_dma_configure(dev, dma_dev->of_node);
  69. } else if (has_acpi_companion(dma_dev)) {
  70. --- a/drivers/net/bonding/bond_main.c
  71. +++ b/drivers/net/bonding/bond_main.c
  72. @@ -1337,7 +1337,8 @@ void bond_lower_state_changed(struct sla
  73. }
  74. /* enslave device <slave> to bond device <master> */
  75. -int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
  76. +int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
  77. + struct netlink_ext_ack *extack)
  78. {
  79. struct bonding *bond = netdev_priv(bond_dev);
  80. const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
  81. @@ -3509,7 +3510,7 @@ static int bond_do_ioctl(struct net_devi
  82. switch (cmd) {
  83. case BOND_ENSLAVE_OLD:
  84. case SIOCBONDENSLAVE:
  85. - res = bond_enslave(bond_dev, slave_dev);
  86. + res = bond_enslave(bond_dev, slave_dev, NULL);
  87. break;
  88. case BOND_RELEASE_OLD:
  89. case SIOCBONDRELEASE:
  90. --- a/drivers/net/bonding/bond_options.c
  91. +++ b/drivers/net/bonding/bond_options.c
  92. @@ -1389,7 +1389,7 @@ static int bond_option_slaves_set(struct
  93. switch (command[0]) {
  94. case '+':
  95. netdev_dbg(bond->dev, "Adding slave %s\n", dev->name);
  96. - ret = bond_enslave(bond->dev, dev);
  97. + ret = bond_enslave(bond->dev, dev, NULL);
  98. break;
  99. case '-':
  100. --- a/drivers/net/team/team.c
  101. +++ b/drivers/net/team/team.c
  102. @@ -1932,7 +1932,8 @@ static int team_netpoll_setup(struct net
  103. }
  104. #endif
  105. -static int team_add_slave(struct net_device *dev, struct net_device *port_dev)
  106. +static int team_add_slave(struct net_device *dev, struct net_device *port_dev,
  107. + struct netlink_ext_ack *extack)
  108. {
  109. struct team *team = netdev_priv(dev);
  110. int err;
  111. --- a/drivers/net/vrf.c
  112. +++ b/drivers/net/vrf.c
  113. @@ -791,7 +791,8 @@ err:
  114. return ret;
  115. }
  116. -static int vrf_add_slave(struct net_device *dev, struct net_device *port_dev)
  117. +static int vrf_add_slave(struct net_device *dev, struct net_device *port_dev,
  118. + struct netlink_ext_ack *extack)
  119. {
  120. if (netif_is_l3_master(port_dev) || netif_is_l3_slave(port_dev))
  121. return -EINVAL;
  122. --- a/drivers/of/device.c
  123. +++ b/drivers/of/device.c
  124. @@ -15,6 +15,9 @@
  125. #include <asm/errno.h>
  126. #include "of_private.h"
  127. +#ifdef CONFIG_FSL_MC_BUS
  128. +#include <linux/fsl/mc.h>
  129. +#endif
  130. /**
  131. * of_match_device - Tell if a struct device matches an of_device_id list
  132. @@ -105,6 +108,9 @@ int of_dma_configure(struct device *dev,
  133. #ifdef CONFIG_ARM_AMBA
  134. dev->bus != &amba_bustype &&
  135. #endif
  136. +#ifdef CONFIG_FSL_MC_BUS
  137. + dev->bus != &fsl_mc_bus_type &&
  138. +#endif
  139. dev->bus != &platform_bus_type)
  140. return ret == -ENODEV ? 0 : ret;
  141. @@ -155,7 +161,12 @@ int of_dma_configure(struct device *dev,
  142. dev->coherent_dma_mask &= mask;
  143. *dev->dma_mask &= mask;
  144. - coherent = of_dma_is_coherent(np);
  145. +#ifdef CONFIG_FSL_MC_BUS
  146. + if (dev_is_fsl_mc(dev))
  147. + coherent = fsl_mc_is_dev_coherent(dev);
  148. + else
  149. +#endif
  150. + coherent = of_dma_is_coherent(np);
  151. dev_dbg(dev, "device is%sdma coherent\n",
  152. coherent ? " " : " not ");
  153. --- a/drivers/soc/fsl/guts.c
  154. +++ b/drivers/soc/fsl/guts.c
  155. @@ -213,6 +213,9 @@ static const struct of_device_id fsl_gut
  156. { .compatible = "fsl,ls1021a-dcfg", },
  157. { .compatible = "fsl,ls1043a-dcfg", },
  158. { .compatible = "fsl,ls2080a-dcfg", },
  159. + { .compatible = "fsl,ls1088a-dcfg", },
  160. + { .compatible = "fsl,ls1012a-dcfg", },
  161. + { .compatible = "fsl,ls1046a-dcfg", },
  162. {}
  163. };
  164. MODULE_DEVICE_TABLE(of, fsl_guts_of_match);
  165. --- a/include/linux/fsl_devices.h
  166. +++ b/include/linux/fsl_devices.h
  167. @@ -99,7 +99,9 @@ struct fsl_usb2_platform_data {
  168. unsigned suspended:1;
  169. unsigned already_suspended:1;
  170. unsigned has_fsl_erratum_a007792:1;
  171. + unsigned has_fsl_erratum_14:1;
  172. unsigned has_fsl_erratum_a005275:1;
  173. + unsigned has_fsl_erratum_a006918:1;
  174. unsigned has_fsl_erratum_a005697:1;
  175. unsigned check_phy_clk_valid:1;
  176. --- a/include/linux/netdevice.h
  177. +++ b/include/linux/netdevice.h
  178. @@ -1260,7 +1260,8 @@ struct net_device_ops {
  179. u32 flow_id);
  180. #endif
  181. int (*ndo_add_slave)(struct net_device *dev,
  182. - struct net_device *slave_dev);
  183. + struct net_device *slave_dev,
  184. + struct netlink_ext_ack *extack);
  185. int (*ndo_del_slave)(struct net_device *dev,
  186. struct net_device *slave_dev);
  187. netdev_features_t (*ndo_fix_features)(struct net_device *dev,
  188. @@ -2341,7 +2342,8 @@ int register_netdevice_notifier(struct n
  189. int unregister_netdevice_notifier(struct notifier_block *nb);
  190. struct netdev_notifier_info {
  191. - struct net_device *dev;
  192. + struct net_device *dev;
  193. + struct netlink_ext_ack *extack;
  194. };
  195. struct netdev_notifier_info_ext {
  196. @@ -2373,6 +2375,7 @@ static inline void netdev_notifier_info_
  197. struct net_device *dev)
  198. {
  199. info->dev = dev;
  200. + info->extack = NULL;
  201. }
  202. static inline struct net_device *
  203. @@ -2381,6 +2384,12 @@ netdev_notifier_info_to_dev(const struct
  204. return info->dev;
  205. }
  206. +static inline struct netlink_ext_ack *
  207. +netdev_notifier_info_to_extack(const struct netdev_notifier_info *info)
  208. +{
  209. + return info->extack;
  210. +}
  211. +
  212. int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
  213. --- a/include/linux/skbuff.h
  214. +++ b/include/linux/skbuff.h
  215. @@ -964,6 +964,7 @@ void kfree_skb_list(struct sk_buff *segs
  216. void skb_tx_error(struct sk_buff *skb);
  217. void consume_skb(struct sk_buff *skb);
  218. void __consume_stateless_skb(struct sk_buff *skb);
  219. +void skb_recycle(struct sk_buff *skb);
  220. void __kfree_skb(struct sk_buff *skb);
  221. extern struct kmem_cache *skbuff_head_cache;
  222. @@ -3294,6 +3295,7 @@ static inline void skb_free_datagram_loc
  223. }
  224. int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags);
  225. int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len);
  226. +void copy_skb_header(struct sk_buff *new, const struct sk_buff *old);
  227. int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
  228. __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
  229. int len, __wsum csum);
  230. --- a/include/net/bonding.h
  231. +++ b/include/net/bonding.h
  232. @@ -592,7 +592,8 @@ void bond_destroy_sysfs(struct bond_net
  233. void bond_prepare_sysfs_group(struct bonding *bond);
  234. int bond_sysfs_slave_add(struct slave *slave);
  235. void bond_sysfs_slave_del(struct slave *slave);
  236. -int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev);
  237. +int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
  238. + struct netlink_ext_ack *extack);
  239. int bond_release(struct net_device *bond_dev, struct net_device *slave_dev);
  240. u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb);
  241. int bond_set_carrier(struct bonding *bond);
  242. --- a/net/batman-adv/soft-interface.c
  243. +++ b/net/batman-adv/soft-interface.c
  244. @@ -872,7 +872,8 @@ free_bat_counters:
  245. * Return: 0 if successful or error otherwise.
  246. */
  247. static int batadv_softif_slave_add(struct net_device *dev,
  248. - struct net_device *slave_dev)
  249. + struct net_device *slave_dev,
  250. + struct netlink_ext_ack *extack)
  251. {
  252. struct batadv_hard_iface *hard_iface;
  253. struct net *net = dev_net(dev);
  254. --- a/net/bridge/br_device.c
  255. +++ b/net/bridge/br_device.c
  256. @@ -324,7 +324,8 @@ void br_netpoll_disable(struct net_bridg
  257. #endif
  258. -static int br_add_slave(struct net_device *dev, struct net_device *slave_dev)
  259. +static int br_add_slave(struct net_device *dev, struct net_device *slave_dev,
  260. + struct netlink_ext_ack *extack)
  261. {
  262. struct net_bridge *br = netdev_priv(dev);
  263. --- a/net/core/dev.c
  264. +++ b/net/core/dev.c
  265. @@ -162,7 +162,6 @@ static struct list_head offload_base __r
  266. static int netif_rx_internal(struct sk_buff *skb);
  267. static int call_netdevice_notifiers_info(unsigned long val,
  268. - struct net_device *dev,
  269. struct netdev_notifier_info *info);
  270. static struct napi_struct *napi_by_id(unsigned int napi_id);
  271. @@ -1312,10 +1311,11 @@ EXPORT_SYMBOL(netdev_features_change);
  272. void netdev_state_change(struct net_device *dev)
  273. {
  274. if (dev->flags & IFF_UP) {
  275. - struct netdev_notifier_change_info change_info;
  276. + struct netdev_notifier_change_info change_info = {
  277. + .info.dev = dev,
  278. + };
  279. - change_info.flags_changed = 0;
  280. - call_netdevice_notifiers_info(NETDEV_CHANGE, dev,
  281. + call_netdevice_notifiers_info(NETDEV_CHANGE,
  282. &change_info.info);
  283. rtmsg_ifinfo(RTM_NEWLINK, dev, 0, GFP_KERNEL);
  284. }
  285. @@ -1536,9 +1536,10 @@ EXPORT_SYMBOL(dev_disable_lro);
  286. static int call_netdevice_notifier(struct notifier_block *nb, unsigned long val,
  287. struct net_device *dev)
  288. {
  289. - struct netdev_notifier_info info;
  290. + struct netdev_notifier_info info = {
  291. + .dev = dev,
  292. + };
  293. - netdev_notifier_info_init(&info, dev);
  294. return nb->notifier_call(nb, val, &info);
  295. }
  296. @@ -1663,11 +1664,9 @@ EXPORT_SYMBOL(unregister_netdevice_notif
  297. */
  298. static int call_netdevice_notifiers_info(unsigned long val,
  299. - struct net_device *dev,
  300. struct netdev_notifier_info *info)
  301. {
  302. ASSERT_RTNL();
  303. - netdev_notifier_info_init(info, dev);
  304. return raw_notifier_call_chain(&netdev_chain, val, info);
  305. }
  306. @@ -1682,9 +1681,11 @@ static int call_netdevice_notifiers_info
  307. int call_netdevice_notifiers(unsigned long val, struct net_device *dev)
  308. {
  309. - struct netdev_notifier_info info;
  310. + struct netdev_notifier_info info = {
  311. + .dev = dev,
  312. + };
  313. - return call_netdevice_notifiers_info(val, dev, &info);
  314. + return call_netdevice_notifiers_info(val, &info);
  315. }
  316. EXPORT_SYMBOL(call_netdevice_notifiers);
  317. @@ -1707,7 +1708,7 @@ static int call_netdevice_notifiers_mtu(
  318. BUILD_BUG_ON(offsetof(struct netdev_notifier_info_ext, info) != 0);
  319. - return call_netdevice_notifiers_info(val, dev, &info.info);
  320. + return call_netdevice_notifiers_info(val, &info.info);
  321. }
  322. #ifdef CONFIG_NET_INGRESS
  323. @@ -6338,7 +6339,15 @@ static int __netdev_upper_dev_link(struc
  324. struct net_device *upper_dev, bool master,
  325. void *upper_priv, void *upper_info)
  326. {
  327. - struct netdev_notifier_changeupper_info changeupper_info;
  328. + struct netdev_notifier_changeupper_info changeupper_info = {
  329. + .info = {
  330. + .dev = dev,
  331. + },
  332. + .upper_dev = upper_dev,
  333. + .master = master,
  334. + .linking = true,
  335. + .upper_info = upper_info,
  336. + };
  337. int ret = 0;
  338. ASSERT_RTNL();
  339. @@ -6356,12 +6365,7 @@ static int __netdev_upper_dev_link(struc
  340. if (master && netdev_master_upper_dev_get(dev))
  341. return -EBUSY;
  342. - changeupper_info.upper_dev = upper_dev;
  343. - changeupper_info.master = master;
  344. - changeupper_info.linking = true;
  345. - changeupper_info.upper_info = upper_info;
  346. -
  347. - ret = call_netdevice_notifiers_info(NETDEV_PRECHANGEUPPER, dev,
  348. + ret = call_netdevice_notifiers_info(NETDEV_PRECHANGEUPPER,
  349. &changeupper_info.info);
  350. ret = notifier_to_errno(ret);
  351. if (ret)
  352. @@ -6373,7 +6377,7 @@ static int __netdev_upper_dev_link(struc
  353. return ret;
  354. netdev_update_addr_mask(dev);
  355. - ret = call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, dev,
  356. + ret = call_netdevice_notifiers_info(NETDEV_CHANGEUPPER,
  357. &changeupper_info.info);
  358. ret = notifier_to_errno(ret);
  359. if (ret)
  360. @@ -6437,21 +6441,25 @@ EXPORT_SYMBOL(netdev_master_upper_dev_li
  361. void netdev_upper_dev_unlink(struct net_device *dev,
  362. struct net_device *upper_dev)
  363. {
  364. - struct netdev_notifier_changeupper_info changeupper_info;
  365. + struct netdev_notifier_changeupper_info changeupper_info = {
  366. + .info = {
  367. + .dev = dev,
  368. + },
  369. + .upper_dev = upper_dev,
  370. + .linking = false,
  371. + };
  372. ASSERT_RTNL();
  373. - changeupper_info.upper_dev = upper_dev;
  374. changeupper_info.master = netdev_master_upper_dev_get(dev) == upper_dev;
  375. - changeupper_info.linking = false;
  376. - call_netdevice_notifiers_info(NETDEV_PRECHANGEUPPER, dev,
  377. + call_netdevice_notifiers_info(NETDEV_PRECHANGEUPPER,
  378. &changeupper_info.info);
  379. __netdev_adjacent_dev_unlink_neighbour(dev, upper_dev);
  380. netdev_update_addr_mask(dev);
  381. - call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, dev,
  382. + call_netdevice_notifiers_info(NETDEV_CHANGEUPPER,
  383. &changeupper_info.info);
  384. }
  385. EXPORT_SYMBOL(netdev_upper_dev_unlink);
  386. @@ -6467,11 +6475,13 @@ EXPORT_SYMBOL(netdev_upper_dev_unlink);
  387. void netdev_bonding_info_change(struct net_device *dev,
  388. struct netdev_bonding_info *bonding_info)
  389. {
  390. - struct netdev_notifier_bonding_info info;
  391. + struct netdev_notifier_bonding_info info = {
  392. + .info.dev = dev,
  393. + };
  394. memcpy(&info.bonding_info, bonding_info,
  395. sizeof(struct netdev_bonding_info));
  396. - call_netdevice_notifiers_info(NETDEV_BONDING_INFO, dev,
  397. + call_netdevice_notifiers_info(NETDEV_BONDING_INFO,
  398. &info.info);
  399. }
  400. EXPORT_SYMBOL(netdev_bonding_info_change);
  401. @@ -6597,11 +6607,13 @@ EXPORT_SYMBOL(dev_get_nest_level);
  402. void netdev_lower_state_changed(struct net_device *lower_dev,
  403. void *lower_state_info)
  404. {
  405. - struct netdev_notifier_changelowerstate_info changelowerstate_info;
  406. + struct netdev_notifier_changelowerstate_info changelowerstate_info = {
  407. + .info.dev = lower_dev,
  408. + };
  409. ASSERT_RTNL();
  410. changelowerstate_info.lower_state_info = lower_state_info;
  411. - call_netdevice_notifiers_info(NETDEV_CHANGELOWERSTATE, lower_dev,
  412. + call_netdevice_notifiers_info(NETDEV_CHANGELOWERSTATE,
  413. &changelowerstate_info.info);
  414. }
  415. EXPORT_SYMBOL(netdev_lower_state_changed);
  416. @@ -6892,11 +6904,14 @@ void __dev_notify_flags(struct net_devic
  417. if (dev->flags & IFF_UP &&
  418. (changes & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI | IFF_VOLATILE))) {
  419. - struct netdev_notifier_change_info change_info;
  420. + struct netdev_notifier_change_info change_info = {
  421. + .info = {
  422. + .dev = dev,
  423. + },
  424. + .flags_changed = changes,
  425. + };
  426. - change_info.flags_changed = changes;
  427. - call_netdevice_notifiers_info(NETDEV_CHANGE, dev,
  428. - &change_info.info);
  429. + call_netdevice_notifiers_info(NETDEV_CHANGE, &change_info.info);
  430. }
  431. }
  432. --- a/net/core/rtnetlink.c
  433. +++ b/net/core/rtnetlink.c
  434. @@ -1912,7 +1912,8 @@ static int do_setvfinfo(struct net_devic
  435. return err;
  436. }
  437. -static int do_set_master(struct net_device *dev, int ifindex)
  438. +static int do_set_master(struct net_device *dev, int ifindex,
  439. + struct netlink_ext_ack *extack)
  440. {
  441. struct net_device *upper_dev = netdev_master_upper_dev_get(dev);
  442. const struct net_device_ops *ops;
  443. @@ -1937,7 +1938,7 @@ static int do_set_master(struct net_devi
  444. return -EINVAL;
  445. ops = upper_dev->netdev_ops;
  446. if (ops->ndo_add_slave) {
  447. - err = ops->ndo_add_slave(upper_dev, dev);
  448. + err = ops->ndo_add_slave(upper_dev, dev, extack);
  449. if (err)
  450. return err;
  451. } else {
  452. @@ -2074,7 +2075,7 @@ static int do_setlink(const struct sk_bu
  453. }
  454. if (tb[IFLA_MASTER]) {
  455. - err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]));
  456. + err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]), extack);
  457. if (err)
  458. goto errout;
  459. status |= DO_SETLINK_MODIFIED;
  460. @@ -2723,7 +2724,8 @@ replay:
  461. goto out_unregister;
  462. }
  463. if (tb[IFLA_MASTER]) {
  464. - err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]));
  465. + err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]),
  466. + extack);
  467. if (err)
  468. goto out_unregister;
  469. }
  470. --- a/net/core/skbuff.c
  471. +++ b/net/core/skbuff.c
  472. @@ -799,6 +799,32 @@ void napi_consume_skb(struct sk_buff *sk
  473. }
  474. EXPORT_SYMBOL(napi_consume_skb);
  475. +/**
  476. + * skb_recycle - clean up an skb for reuse
  477. + * @skb: buffer
  478. + *
  479. + * Recycles the skb to be reused as a receive buffer. This
  480. + * function does any necessary reference count dropping, and
  481. + * cleans up the skbuff as if it just came from __alloc_skb().
  482. + */
  483. +void skb_recycle(struct sk_buff *skb)
  484. +{
  485. + struct skb_shared_info *shinfo;
  486. + u8 head_frag = skb->head_frag;
  487. +
  488. + skb_release_head_state(skb);
  489. +
  490. + shinfo = skb_shinfo(skb);
  491. + memset(shinfo, 0, offsetof(struct skb_shared_info, dataref));
  492. + atomic_set(&shinfo->dataref, 1);
  493. +
  494. + memset(skb, 0, offsetof(struct sk_buff, tail));
  495. + skb->data = skb->head + NET_SKB_PAD;
  496. + skb->head_frag = head_frag;
  497. + skb_reset_tail_pointer(skb);
  498. +}
  499. +EXPORT_SYMBOL(skb_recycle);
  500. +
  501. /* Make sure a field is enclosed inside headers_start/headers_end section */
  502. #define CHECK_SKB_FIELD(field) \
  503. BUILD_BUG_ON(offsetof(struct sk_buff, field) < \
  504. @@ -1318,7 +1344,7 @@ static void skb_headers_offset_update(st
  505. skb->inner_mac_header += off;
  506. }
  507. -static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
  508. +void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
  509. {
  510. __copy_skb_header(new, old);
  511. @@ -1326,6 +1352,7 @@ static void copy_skb_header(struct sk_bu
  512. skb_shinfo(new)->gso_segs = skb_shinfo(old)->gso_segs;
  513. skb_shinfo(new)->gso_type = skb_shinfo(old)->gso_type;
  514. }
  515. +EXPORT_SYMBOL(copy_skb_header);
  516. static inline int skb_alloc_rx_flag(const struct sk_buff *skb)
  517. {
  518. --- a/samples/bpf/Makefile
  519. +++ b/samples/bpf/Makefile
  520. @@ -178,6 +178,12 @@ HOSTLOADLIBES_syscall_tp += -lelf
  521. LLC ?= llc
  522. CLANG ?= clang
  523. +# Detect that we're cross compiling and use the cross compiler
  524. +ifdef CROSS_COMPILE
  525. +HOSTCC = $(CROSS_COMPILE)gcc
  526. +CLANG_ARCH_ARGS = -target $(ARCH)
  527. +endif
  528. +
  529. # Trick to allow make to be run from this directory
  530. all: $(LIBBPF)
  531. $(MAKE) -C ../../ $(CURDIR)/
  532. @@ -228,9 +234,9 @@ $(obj)/tracex5_kern.o: $(obj)/syscall_nr
  533. $(obj)/%.o: $(src)/%.c
  534. $(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \
  535. -I$(srctree)/tools/testing/selftests/bpf/ \
  536. - -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
  537. - -Wno-compare-distinct-pointer-types \
  538. + -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \
  539. + -D__TARGET_ARCH_$(ARCH) -Wno-compare-distinct-pointer-types \
  540. -Wno-gnu-variable-sized-type-not-at-end \
  541. -Wno-address-of-packed-member -Wno-tautological-compare \
  542. - -Wno-unknown-warning-option \
  543. + -Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \
  544. -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
  545. --- a/samples/bpf/map_perf_test_kern.c
  546. +++ b/samples/bpf/map_perf_test_kern.c
  547. @@ -266,7 +266,7 @@ int stress_hash_map_lookup(struct pt_reg
  548. return 0;
  549. }
  550. -SEC("kprobe/sys_getpgrp")
  551. +SEC("kprobe/sys_getppid")
  552. int stress_array_map_lookup(struct pt_regs *ctx)
  553. {
  554. u32 key = 1, i;
  555. --- a/samples/bpf/map_perf_test_user.c
  556. +++ b/samples/bpf/map_perf_test_user.c
  557. @@ -282,7 +282,7 @@ static void test_array_lookup(int cpu)
  558. start_time = time_get_ns();
  559. for (i = 0; i < max_cnt; i++)
  560. - syscall(__NR_getpgrp, 0);
  561. + syscall(__NR_getppid, 0);
  562. printf("%d:array_lookup %lld lookups per sec\n",
  563. cpu, max_cnt * 1000000000ll * 64 / (time_get_ns() - start_time));
  564. }
  565. --- a/tools/testing/selftests/bpf/bpf_helpers.h
  566. +++ b/tools/testing/selftests/bpf/bpf_helpers.h
  567. @@ -110,7 +110,47 @@ static int (*bpf_skb_under_cgroup)(void
  568. static int (*bpf_skb_change_head)(void *, int len, int flags) =
  569. (void *) BPF_FUNC_skb_change_head;
  570. +/* Scan the ARCH passed in from ARCH env variable (see Makefile) */
  571. +#if defined(__TARGET_ARCH_x86)
  572. + #define bpf_target_x86
  573. + #define bpf_target_defined
  574. +#elif defined(__TARGET_ARCH_s930x)
  575. + #define bpf_target_s930x
  576. + #define bpf_target_defined
  577. +#elif defined(__TARGET_ARCH_arm64)
  578. + #define bpf_target_arm64
  579. + #define bpf_target_defined
  580. +#elif defined(__TARGET_ARCH_mips)
  581. + #define bpf_target_mips
  582. + #define bpf_target_defined
  583. +#elif defined(__TARGET_ARCH_powerpc)
  584. + #define bpf_target_powerpc
  585. + #define bpf_target_defined
  586. +#elif defined(__TARGET_ARCH_sparc)
  587. + #define bpf_target_sparc
  588. + #define bpf_target_defined
  589. +#else
  590. + #undef bpf_target_defined
  591. +#endif
  592. +
  593. +/* Fall back to what the compiler says */
  594. +#ifndef bpf_target_defined
  595. #if defined(__x86_64__)
  596. + #define bpf_target_x86
  597. +#elif defined(__s390x__)
  598. + #define bpf_target_s930x
  599. +#elif defined(__aarch64__)
  600. + #define bpf_target_arm64
  601. +#elif defined(__mips__)
  602. + #define bpf_target_mips
  603. +#elif defined(__powerpc__)
  604. + #define bpf_target_powerpc
  605. +#elif defined(__sparc__)
  606. + #define bpf_target_sparc
  607. +#endif
  608. +#endif
  609. +
  610. +#if defined(bpf_target_x86)
  611. #define PT_REGS_PARM1(x) ((x)->di)
  612. #define PT_REGS_PARM2(x) ((x)->si)
  613. @@ -123,7 +163,7 @@ static int (*bpf_skb_change_head)(void *
  614. #define PT_REGS_SP(x) ((x)->sp)
  615. #define PT_REGS_IP(x) ((x)->ip)
  616. -#elif defined(__s390x__)
  617. +#elif defined(bpf_target_s390x)
  618. #define PT_REGS_PARM1(x) ((x)->gprs[2])
  619. #define PT_REGS_PARM2(x) ((x)->gprs[3])
  620. @@ -136,7 +176,7 @@ static int (*bpf_skb_change_head)(void *
  621. #define PT_REGS_SP(x) ((x)->gprs[15])
  622. #define PT_REGS_IP(x) ((x)->psw.addr)
  623. -#elif defined(__aarch64__)
  624. +#elif defined(bpf_target_arm64)
  625. #define PT_REGS_PARM1(x) ((x)->regs[0])
  626. #define PT_REGS_PARM2(x) ((x)->regs[1])
  627. @@ -149,7 +189,7 @@ static int (*bpf_skb_change_head)(void *
  628. #define PT_REGS_SP(x) ((x)->sp)
  629. #define PT_REGS_IP(x) ((x)->pc)
  630. -#elif defined(__mips__)
  631. +#elif defined(bpf_target_mips)
  632. #define PT_REGS_PARM1(x) ((x)->regs[4])
  633. #define PT_REGS_PARM2(x) ((x)->regs[5])
  634. @@ -162,7 +202,7 @@ static int (*bpf_skb_change_head)(void *
  635. #define PT_REGS_SP(x) ((x)->regs[29])
  636. #define PT_REGS_IP(x) ((x)->cp0_epc)
  637. -#elif defined(__powerpc__)
  638. +#elif defined(bpf_target_powerpc)
  639. #define PT_REGS_PARM1(x) ((x)->gpr[3])
  640. #define PT_REGS_PARM2(x) ((x)->gpr[4])
  641. @@ -173,7 +213,7 @@ static int (*bpf_skb_change_head)(void *
  642. #define PT_REGS_SP(x) ((x)->sp)
  643. #define PT_REGS_IP(x) ((x)->nip)
  644. -#elif defined(__sparc__)
  645. +#elif defined(bpf_target_sparc)
  646. #define PT_REGS_PARM1(x) ((x)->u_regs[UREG_I0])
  647. #define PT_REGS_PARM2(x) ((x)->u_regs[UREG_I1])
  648. @@ -183,6 +223,8 @@ static int (*bpf_skb_change_head)(void *
  649. #define PT_REGS_RET(x) ((x)->u_regs[UREG_I7])
  650. #define PT_REGS_RC(x) ((x)->u_regs[UREG_I0])
  651. #define PT_REGS_SP(x) ((x)->u_regs[UREG_FP])
  652. +
  653. +/* Should this also be a bpf_target check for the sparc case? */
  654. #if defined(__arch64__)
  655. #define PT_REGS_IP(x) ((x)->tpc)
  656. #else
  657. @@ -191,10 +233,10 @@ static int (*bpf_skb_change_head)(void *
  658. #endif
  659. -#ifdef __powerpc__
  660. +#ifdef bpf_target_powerpc
  661. #define BPF_KPROBE_READ_RET_IP(ip, ctx) ({ (ip) = (ctx)->link; })
  662. #define BPF_KRETPROBE_READ_RET_IP BPF_KPROBE_READ_RET_IP
  663. -#elif defined(__sparc__)
  664. +#elif bpf_target_sparc
  665. #define BPF_KPROBE_READ_RET_IP(ip, ctx) ({ (ip) = PT_REGS_RET(ctx); })
  666. #define BPF_KRETPROBE_READ_RET_IP BPF_KPROBE_READ_RET_IP
  667. #else