+ /* Obtain the MAC node used by this interface except macless */
+ mac_phandle = of_get_property(dpa_node, mprop, &lenp);
+ if (!mac_phandle) {
+ FMAN_ERR(-EINVAL, "%s: no %s\n", dname, mprop);
+ return -EINVAL;
+ }
+ assert(lenp == sizeof(phandle));
+ mac_node = of_find_node_by_phandle(*mac_phandle);
+ if (!mac_node) {
+ FMAN_ERR(-ENXIO, "%s: bad 'fsl,fman-mac\n", dname);
+ return -ENXIO;
+ }
+ mname = mac_node->full_name;
+
+ /* Extract the Rx and Tx ports */
+ ports_phandle = of_get_property(mac_node, "fsl,port-handles",
+ &lenp);
+ if (!ports_phandle)
+ ports_phandle = of_get_property(mac_node, "fsl,fman-ports",
+ &lenp);
+ if (!ports_phandle) {
+ FMAN_ERR(-EINVAL, "%s: no fsl,port-handles\n",
+ mname);
+ return -EINVAL;
+ }
+ assert(lenp == (2 * sizeof(phandle)));
+ rx_node = of_find_node_by_phandle(ports_phandle[0]);
+ if (!rx_node) {
+ FMAN_ERR(-ENXIO, "%s: bad fsl,port-handle[0]\n", mname);
+ return -ENXIO;
+ }
+ tx_node = of_find_node_by_phandle(ports_phandle[1]);
+ if (!tx_node) {
+ FMAN_ERR(-ENXIO, "%s: bad fsl,port-handle[1]\n", mname);
+ return -ENXIO;
+ }
+
+ /* Check if the port is shared interface */
+ if (of_device_is_compatible(dpa_node, "fsl,dpa-ethernet")) {
+ port_cell_idx = of_get_property(rx_node, "cell-index", &lenp);
+ if (!port_cell_idx) {
+ FMAN_ERR(-ENXIO,
+ "%s: no cell-index for port\n", mname);
+ return -ENXIO;
+ }
+ assert(lenp == sizeof(*port_cell_idx));
+ port_cell_idx_val =
+ of_read_number(port_cell_idx, lenp / sizeof(phandle));
+
+ if (of_device_is_compatible(rx_node, "fsl,fman-port-1g-rx"))
+ port_cell_idx_val -= 0x8;
+ else if (of_device_is_compatible(
+ rx_node, "fsl,fman-port-10g-rx"))
+ port_cell_idx_val -= 0x10;
+
+ parent_node_ext_args = of_find_compatible_node(NULL,
+ NULL, "fsl,fman-extended-args");
+ if (!parent_node_ext_args)
+ return 0;
+
+ for_each_child_node(parent_node_ext_args, ext_args_node) {
+ ext_args_cell_idx = of_get_property(ext_args_node,
+ "cell-index", &lenp);
+ if (!ext_args_cell_idx) {
+ FMAN_ERR(-ENXIO,
+ "%s: no cell-index for ext args\n",
+ mname);
+ return -ENXIO;
+ }
+ assert(lenp == sizeof(*ext_args_cell_idx));
+ ext_args_cell_idx_val =
+ of_read_number(ext_args_cell_idx, lenp /
+ sizeof(phandle));
+
+ if (port_cell_idx_val == ext_args_cell_idx_val) {
+ if (of_device_is_compatible(ext_args_node,
+ "fsl,fman-port-1g-rx-extended-args") &&
+ of_device_is_compatible(rx_node,
+ "fsl,fman-port-1g-rx")) {
+ if (of_get_property(ext_args_node,
+ "vsp-window", &lenp))
+ is_shared = 1;
+ break;
+ }
+ if (of_device_is_compatible(ext_args_node,
+ "fsl,fman-port-10g-rx-extended-args") &&
+ of_device_is_compatible(rx_node,
+ "fsl,fman-port-10g-rx")) {
+ if (of_get_property(ext_args_node,
+ "vsp-window", &lenp))
+ is_shared = 1;
+ break;
+ }
+ }
+ }
+ if (!is_shared)
+ return 0;
+ }
+