| 1934 | }; |
| 1935 | |
| 1936 | static int |
| 1937 | sfc_journal_ctx_add_controller(struct sfc_mport_journal_ctx *ctx, |
| 1938 | efx_pcie_interface_t intf) |
| 1939 | { |
| 1940 | efx_pcie_interface_t *new_controllers; |
| 1941 | size_t i, target; |
| 1942 | size_t new_size; |
| 1943 | |
| 1944 | if (ctx->controllers == NULL) { |
| 1945 | ctx->controllers = rte_malloc("sfc_controller_mapping", |
| 1946 | sizeof(ctx->controllers[0]), 0); |
| 1947 | if (ctx->controllers == NULL) |
| 1948 | return ENOMEM; |
| 1949 | |
| 1950 | ctx->controllers[0] = intf; |
| 1951 | ctx->nb_controllers = 1; |
| 1952 | |
| 1953 | return 0; |
| 1954 | } |
| 1955 | |
| 1956 | for (i = 0; i < ctx->nb_controllers; i++) { |
| 1957 | if (ctx->controllers[i] == intf) |
| 1958 | return 0; |
| 1959 | if (ctx->controllers[i] > intf) |
| 1960 | break; |
| 1961 | } |
| 1962 | target = i; |
| 1963 | |
| 1964 | ctx->nb_controllers += 1; |
| 1965 | new_size = ctx->nb_controllers * sizeof(ctx->controllers[0]); |
| 1966 | |
| 1967 | new_controllers = rte_realloc(ctx->controllers, new_size, 0); |
| 1968 | if (new_controllers == NULL) { |
| 1969 | rte_free(ctx->controllers); |
| 1970 | return ENOMEM; |
| 1971 | } |
| 1972 | ctx->controllers = new_controllers; |
| 1973 | |
| 1974 | for (i = target + 1; i < ctx->nb_controllers; i++) |
| 1975 | ctx->controllers[i] = ctx->controllers[i - 1]; |
| 1976 | |
| 1977 | ctx->controllers[target] = intf; |
| 1978 | |
| 1979 | return 0; |
| 1980 | } |
| 1981 | |
| 1982 | static efx_rc_t |
| 1983 | sfc_process_mport_journal_entry(struct sfc_mport_journal_ctx *ctx, |
no test coverage detected